Skip to main content

Test your servers environments by using fabric.

Requirements

  • python 2.6 or later

  • fabric

How to Use

  1. install

    % pip install envassert
  2. write fabfile.py.

    from fabric.api import env, task
    from envassert import file, process, package, user, group, port, cron, detect
    
    env.use_ssh_config = True
    
    @task
    def check():
        env.platform_family = detect.detect()
    
        assert file.exists("/etc/hosts")
        assert file.is_file("/etc/hosts")
        assert file.is_dir("/tmp/")
        assert file.dir_exists("/tmp/")
        assert file.has_line("/etc/passwd", "sshd")
        assert file.owner_is("/bin/sh", "root")
        assert file.group_is("/bin/sh", "root")
        assert file.mode_is("/bin/sh", "777")
    
        if env.platform_family == "freebsd":
            assert file.is_link("/compat")
        else:
            assert file.is_link("/usr/tmp")
    
        assert package.installed("wget.x86_64")
    
        assert user.exists("sshd")
        assert user.is_belonging_group("shirou", "users")
        assert group.exists("wheel")
    
        assert port.is_listening(22)
        assert port.is_listening(80, "tcp")
    
        assert process.is_up("http") is False
        assert service.is_enabled("httpd")
    
        assert cron.has_entry('shirou', 'python')
    
        assert filesystem.is_type('ext4', '/')
  3. run fab

    % fab -H somehost check
    [somehost] Executing task 'check'
    
    Done.
    Disconnecting from root@192.168.22.98... done.

    You can use any other fabric arguments like hosts or parallel.

Detecting OS

The detect.detect() function can detect target OS and distribution. Setting this variable to env.platform_family, functions can dispatch according to that value.

This function is a minimal port of ohai.

Currently, these platform can be detected. (but not tested yet)

  • rhel (redhat, centos, oracle, scientific, enterpriseenterprise, amazon)

  • debian (debian, ubuntu, linuxmint, raspbian)

  • fedora

  • suse

  • gentoo

  • arch

  • freebsd

  • netbsd

  • openbsd

  • darwin

However, every functions are not implemented for these all platform. Pull Requests are welcome.

The giants on whose shoulders this works stands

License

MIT License

FYI

  • cuisine: BSD

  • serverspec: MIT

  • ohai: Apache 2

Metadata

Release files for envassert 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for envassert 0.1.10
File Size Uploaded
envassert-0.1.10.tar.gz 7.7 kB Details

Release files / envassert-0.1.10.tar.gz

Download URL envassert-0.1.10.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4b6c4fee34e9a7526706f7c0d0318501c51f48bb148b8bba25c89be76579a0c9
BLAKE2b-256 checksum
How to use checksums
83b135f68f1408fee211e9ffea275f07a28d60a45e377012b27db65cc7bc62ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.10 This release

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page