Ejemplo n.º 1
0
def check():
    env.platform_family = detect.detect()
    # file
    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")
    if env.platform_family == "freebsd":
        assert file.is_link("/compat")
        assert file.group_is("/bin/sh", "wheel")
        assert file.mode_is("/bin/sh", "555")
    else:
        assert file.is_link("/usr/tmp")
        assert file.group_is("/bin/sh", "root")
        assert file.mode_is("/bin/sh", "777")

    assert package.installed("wget.x86_64")

    assert user.exists("sshd")
    assert user.is_belonging_group("worker", "users")

    assert group.is_exists("wheel")

    assert port.is_listening(22)
    assert cron.has_entry('shirou', 'python')

    if env.platform_family == "freebsd":
        assert service.is_enabled("apache22")
        assert process.is_up("httpd")
    else:
        assert service.is_enabled("http")
        assert process.is_up("http") is False
Ejemplo n.º 2
0
def check():
    env.platform_family = detect.detect()

    for pkg in ["rabbitmq-server",
                "python-pip",
                "curl",
                "unzip",
                "supervisor",
                "dnsmasq"]:
        assert package.installed(pkg), \
            "package {} is not installed".format(pkg)

    for path in ["/var/lib/rabbitmq/.erlang.cookie",
                 "/etc/supervisor/conf.d/consul.conf",
                 "/usr/local/lib/supervisor/start_consul.sh",
                 "/etc/dnsmasq.d/consul_dns.conf"]:
        assert file.exists(path), "file {} does not exist".format(path)

    assert port.is_listening(5672), "port 5672 (RabbitMQ) is not listening"
    assert user.exists("rabbitmq"), "there is no rabbitmq user"
    assert group.is_exists("rabbitmq"), "there is no rabbitmq group"
    assert process.is_up("supervisord"), "supervisord is not running"
    assert process.is_up("consul"), "consul is not running"
    assert process.is_up("epmd"), "epmd is not running"
    assert process.is_up("beam.smp"), "beam.smp is not running"
    assert process.is_up("dnsmasq"), "dnsmasq is not running"
    assert service.is_enabled("rabbitmq-server"), "nginx is not enabled"
    assert service.is_enabled("supervisor"), "supervisor is not enabled"
    assert amqp_works(env.amqp_login, env.amqp_password, env.host), \
        "RabbitMQ did not respond as expected"
Ejemplo n.º 3
0
def check():
    env.platform_family = detect.detect()

    assert file.exists("/etc/redis/redis.conf")
    assert port.is_listening(6379)
    assert user.exists("redis")
    assert group.is_exists("redis")
    assert process.is_up("redis-server")
    assert service.is_enabled("redisredis")
Ejemplo n.º 4
0
def check():
    env.platform_family = detect.detect()

    assert file.exists("/etc/mongod.conf"), "/etc/mongod.conf does not exist"
    assert port.is_listening(27017), "nothing is listening on port 27017"
    assert user.exists("mongodb"), "there is no mongodb user"
    assert group.is_exists("mongodb"), "there is no mongodb group"
    assert process.is_up("mongod"), "mongod is not running"
    assert service.is_enabled("mongod"), "service mongod is not enabled"
    assert replset_is_ok(), "replica set status was not ok"
Ejemplo n.º 5
0
def check():
    env.platform_family = detect.detect()

    assert file.exists("/etc/mongod.conf"), "/etc/mongod.conf does not exist"
    assert port.is_listening(27017), "nothing is listening on port 27017"
    assert user.exists("mongodb"), "there is no mongodb user"
    assert group.is_exists("mongodb"), "there is no mongodb group"
    assert process.is_up("mongod"), "mongod is not running"
    assert service.is_enabled("mongod"), "service mongod is not enabled"
    assert replset_is_ok(), "replica set status was not ok"
Ejemplo n.º 6
0
def check_db_mysql():
    env.platform_family = detect.detect()

    assert file.exists("/etc/mysql/my.cnf"), \
        "/etc/mysql/my.cnf does not exist"
    assert port.is_listening(3306), "port 3306 is not listening"
    assert user.exists("mysql"), "user mysql does not exist"
    assert group.is_exists("mysql"), "group mysql does not exist"
    assert process.is_up("mysqld"), "mysqld process is not up"
    assert service.is_enabled("mysql"), "mysql is not enabled"
Ejemplo n.º 7
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("cassandra")
    assert file.exists("/etc/cassandra/cassandra.yaml")
    assert port.is_listening(7000)
    assert user.exists("cassandra")
    assert group.is_exists("cassandra")
    assert user.is_belonging_group("cassandra", "cassandra")
    assert process.is_up("java")
    assert service.is_enabled("cassandra")
Ejemplo n.º 8
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("td-agent")
    assert file.exists("/etc/td-agent/td-agent.conf")
    assert port.is_listening(8888)
    assert port.is_listening(24224)
    assert user.exists("td-agent")
    assert group.is_exists("td-agent")
    assert user.is_belonging_group("td-agent", "td-agent")
    assert process.is_up("ruby")
    assert service.is_enabled("td-agent")
Ejemplo n.º 9
0
def check():
    env.platform_family = detect.detect()

    assert port.is_listening(443), "port 443 (nginx) is not listening"
    assert port.is_listening(8080), "port 8080 (gitlab) is not listening"
    assert port.is_listening(22), "port 22 (ssh) is not listening"
    assert user.exists("git"), "there is no git user"
    assert group.is_exists("git"), "there is no git group"
    assert user.is_belonging_group("git", "git"), "user git is not in the git group"
    assert process.is_up("nginx"), "nginx is not running"
    assert process.is_up("postgres"), "postgres is not running"
    assert process.is_up("redis-server"), "redis-server is not running"
    assert gitlab_is_responding(), "gitlab did not respond as expected"
Ejemplo n.º 10
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("apache2")
    assert file.exists("/srv/venv/bin/django-admin.py")
    assert file.exists("/etc/apache2/mods-enabled/wsgi.conf")
    assert file.exists("/etc/apache2/mods-enabled/wsgi.load")
    assert port.is_listening(80)
    assert user.exists("pydev")
    assert group.is_exists("pydev")
    assert user.is_belonging_group("pydev", "pydev")
    assert process.is_up("apache2")
    assert service.is_enabled("apache2")
Ejemplo n.º 11
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("chef-server-core")
    assert file.exists("/etc/opscode/chef-server.rb")
    assert port.is_listening(80)
    assert port.is_listening(443)
    assert user.exists("opscode")
    assert group.is_exists("opscode")
    assert user.is_belonging_group("opscode", "opscode")
    assert process.is_up("nginx")
    assert process.is_up("postgres")
    assert service.is_enabled("nginx")
    assert service.is_enabled("postgres")
Ejemplo n.º 12
0
def acceptance_tests_on_ubuntu14_img_for_flocker(distribution):
    """ checks that the Ubuntu 14 image is suitable for running the Flocker
    acceptance tests

        :param string distribution: which OS to use 'centos7', 'ubuntu1404'
    """
    with settings():
        env.platform_family = detect.detect()

        # Jenkins should call the correct interpreter based on the shebang
        # However,
        # We noticed that our Ubuntu /bin/bash call were being executed
        # as /bin/sh.
        # So we as part of the slave image build process symlinked
        # /bin/sh -> /bin/bash.
        # https://clusterhq.atlassian.net/browse/FLOC-2986
        log_green('check that /bin/sh is symlinked to bash')
        assert file.is_link("/bin/sh")
        assert 'bash' in run('ls -l /bin/sh')

        # the client acceptance tests run on docker instances
        log_green('check that docker is enabled')
        assert 'docker' in run('ls -l /etc/init')

        # make sure we installed all the packages we need
        log_green('assert that required deb packages are installed')
        for pkg in ubuntu14_required_packages():
            log_green('... checking package: %s' % pkg)
            assert package.installed(pkg)

        # Our tests require us to run docker as ubuntu.
        # So we add the user ubuntu to the docker group.
        # During bootstrapping of the node, jenkins will update the init
        # file so that docker is running with the correct group.
        # TODO: move that jenkins code here
        log_green('check that ubuntu is part of group docker')
        assert user.exists("ubuntu")
        assert group.is_exists("docker")
        assert user.is_belonging_group("ubuntu", "docker")

        # the acceptance tests look for a package in a yum repository,
        # we provide one by starting a webserver and pointing the tests
        # to look over there.
        # for that we need 'nginx' installed and running
        log_green('check that nginx is running')
        assert package.installed('nginx')
        assert port.is_listening(80, "tcp")
        assert process.is_up("nginx")
        assert 'nginx' in run('ls -l /etc/init.d/')
Ejemplo n.º 13
0
def check_master():
    env.platform_family = detect.detect()

    assert file.exists("/etc/redis/master.conf"), \
        "master.conf does not exist"
    assert file.exists("/etc/redis/sentinel_cluster.conf"), \
        "sentinel_cluster.conf does not exist"
    assert port.is_listening(6379), "port 6379 is not listening"
    assert port.is_listening(26379), "port 26379 is not listening"
    assert user.exists("redis"), "user redis does not exist"
    assert group.is_exists("redis"), "group redis does not exist"
    assert process.is_up("redis-server"), "redis-server process is not up"
    assert service.is_enabled("redismaster"), "redismaster is not enabled"
    assert service.is_enabled("redis_sentinel_cluster"), \
        "redis_sentinel_cluster is not enabled"
Ejemplo n.º 14
0
def check():
    env.platform_family = detect.detect()

    assert file.exists('/srv/minecraft/minecraft_server.1.8.jar'), \
        '/srv/minecraft/minecraft_server.1.8.jar does not exist'

    assert port.is_listening(25565), 'port 25565/java is not listening'

    assert user.exists('mcserver'), 'user mcserver does not exist'

    assert group.is_exists('mcserver'), 'group mcserver does not exist'

    assert process.is_up('java'), 'process java is not running'

    assert service.is_enabled('minecraft'), 'service minecraft is not enabled'
Ejemplo n.º 15
0
def check_app():
    env.platform_family = detect.detect()

    assert file.exists("/home/rails/railsapp/current/config/database.yml"), \
        "database.yml does not exist"
    assert file.exists("/etc/nginx/sites-enabled/railsapp"), \
        "nginx proxy is not configured"
    assert port.is_listening(80), "port 80 is not listening"
    assert user.exists("rails"), "user rails does not exist"
    assert group.is_exists("rails"), "group rails does not exist"
    # envassert uses `ps -A`, which shows `ruby` for the unicorn process name
    assert process.is_up("ruby"), "unicorn process is not up"
    assert service.is_enabled("unicorn"), "unicorn is not enabled"
    assert service.is_enabled("nginx"), \
        "nginx is not enabled"
Ejemplo n.º 16
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("java-common")
    assert package.installed("nginx")
    assert file.exists("/usr/local/bin/elasticsearch")
    assert port.is_listening(9200)
    assert port.is_listening(9300)
    assert port.is_listening(8080)
    assert user.exists("elasticsearch")
    assert group.is_exists("elasticsearch")
    assert user.is_belonging_group("elasticsearch", "elasticsearch")
    assert process.is_up("java")
    assert process.is_up("nginx")
    assert service.is_enabled("nginx")
    assert service.is_enabled("elasticsearch")
Ejemplo n.º 17
0
def check():
    env.platform_family = detect.detect()

    assert file.exists('/home/strongloop/loopback-example-app/package.json'), \
        '/home/strongloop/loopback-example-app/package.json does not exist'
    assert file.exists('/etc/supervisor.d/strongloop.conf'), \
        '/etc/supervisor.d/strongloop.conf does not exist'

    assert port.is_listening(3000), 'port 3000/node is not listening'

    assert user.exists('strongloop'), 'user strongbad does not exist'
    assert group.is_exists('strongloop'), 'group strongloop does not exist'

    assert process.is_up('supervisord'), 'process supervisord is not running'
    assert process.is_up('node'), 'process node is not running'

    assert service.is_enabled('supervisor'), 'service supervisor is not enabled'
Ejemplo n.º 18
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("java-common")
    assert package.installed("nginx")
    assert file.exists("/usr/local/bin/elasticsearch")
    assert port.is_listening(9200)
    assert port.is_listening(9300)
    assert port.is_listening(8080)
    assert user.exists("elasticsearch")
    assert group.is_exists("elasticsearch")
    assert user.is_belonging_group("elasticsearch", "elasticsearch")
    assert process.is_up("java")
    assert process.is_up("nginx")
    assert service.is_enabled("nginx")
    assert service.is_enabled("elasticsearch")
    assert es_cluster_green(), "Cluster status did not return 'green'"
    check_for_newer_es_release()
Ejemplo n.º 19
0
def check():
    env.platform_family = detect.detect()

    assert file.exists('/home/strongloop/loopback-example-app/package.json'), \
        '/home/strongloop/loopback-example-app/package.json does not exist'
    assert file.exists('/etc/supervisor.d/strongloop.conf'), \
        '/etc/supervisor.d/strongloop.conf does not exist'

    assert port.is_listening(3000), 'port 3000/node is not listening'

    assert user.exists('strongloop'), 'user strongbad does not exist'
    assert group.is_exists('strongloop'), 'group strongloop does not exist'

    assert process.is_up('supervisord'), 'process supervisord is not running'
    assert process.is_up('node'), 'process node is not running'

    assert service.is_enabled('supervisor'), \
        'service supervisor is not enabled'
Ejemplo n.º 20
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("nginx")
    assert package.installed("mysql-server-5.5")
    assert file.exists("/usr/local/bin/node")
    assert file.exists("/usr/local/bin/npm")
    assert port.is_listening(80)
    assert port.is_listening(2368)
    assert port.is_listening(3306)
    assert user.exists("ghost")
    assert group.is_exists("ghost")
    assert user.is_belonging_group("ghost", "www-data")
    assert process.is_up("nginx")
    assert process.is_up("node")
    assert process.is_up("mysqld")
    assert service.is_enabled("nginx")
    assert service.is_enabled("mysqld")
Ejemplo n.º 21
0
def check():
    env.platform_family = detect.detect()

    assert file.exists("/etc/apache2/sites-enabled/example.com.conf"), \
        "/etc/apache2/sites-enabled/example.com.conf does not exist"

    assert port.is_listening(80), "port 80/apache2 is not listening"
    assert port.is_listening(11211), "port 11211/memcached is not listening"

    assert user.exists("memcache"), "user memcache does not exist"

    assert group.is_exists("memcache"), "group memcache does not exist"

    assert process.is_up("apache2"), "apache2 process is not up"
    assert process.is_up("memcached"), "memcached process is not up"

    assert service.is_enabled("apache2"), "redismaster is not enabled"
    assert service.is_enabled("memcached"), "memcached is not enabled"

    assert apache2_is_responding(), "php app did not respond as expected"
Ejemplo n.º 22
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("nginx")
    assert package.installed("mysql-server-5.5")
    assert file.exists("/srv/git/gitlab/vendor/bundle/ruby/1.9.1/bin/unicorn_rails")
    assert file.exists("/srv/git/bin/ruby")
    assert port.is_listening(80)
    assert port.is_listening(443)
    assert port.is_listening(3306)
    assert port.is_listening(6379)
    assert user.exists("git")
    assert group.is_exists("git")
    assert user.is_belonging_group("git", "git")
    assert process.is_up("nginx")
    assert process.is_up("mysqld")
    assert process.is_up("redis-server")
    assert service.is_enabled("nginx")
    assert service.is_enabled("mysqld")
    assert service.is_enabled("gitlab")
Ejemplo n.º 23
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("nginx"), 'nginx not installed'
    assert package.installed("mysql-server-5.5"), \
        'mysql-server-5.5 not installed'
    assert file.exists("/usr/local/bin/node"), 'node not found'
    assert file.exists("/usr/local/bin/npm"), 'npm not found'
    assert port.is_listening(80), '80/nginx is not listening'
    assert port.is_listening(2368), '2368/node is not listening'
    assert port.is_listening(3306), '3306/mysqld is not listening'
    assert user.exists("ghost"), 'ghost user does not exist'
    assert group.is_exists("ghost"), 'ghost group does not exist'
    assert user.is_belonging_group("ghost", "www-data"), \
        'ghost user not in group www-data'
    assert process.is_up("nginx"), 'nginx is not running'
    assert process.is_up("node"), 'node is not running'
    assert process.is_up("mysqld"), 'mysqld is not running'
    assert service.is_enabled("nginx"), 'nginx service not enabled'
    assert service.is_enabled("mysqld"), 'mysqld service not enabled'
    assert ghost_is_responding(), 'Ghost did not respond as expected'
Ejemplo n.º 24
0
def check():
    env.platform_family = detect.detect()

    assert file.exists("/var/www/vhosts/application/index.php")

    assert port.is_listening(11211), "port 11211/memcached is not listening"
    assert port.is_listening(80), "port 80/memcached is not listening"
    assert port.is_listening(443), "port 443/memcached is not listening"

    assert user.exists("memcache"), "user memcache does not exist"

    assert group.is_exists("memcache"), "group memcache does not exist"

    assert process.is_up("apache2"), "apache2 process is not running"
    assert process.is_up("memcached"), "memcached process is not running"

    assert service.is_enabled("apache2"), "apache2 service is not enabled"
    assert service.is_enabled("memcached"), "memcached service is not enabled"

    assert apache2_is_responding(), \
        "php application did not respond as expected"
Ejemplo n.º 25
0
def check():
    env.platform_family = detect.detect()

    assert package.installed("ansible-tower"),\
        "package ansible-tower is not installed"
    assert file.exists("/etc/tower/settings.py"),\
        "/etc/tower/settings.py does not exist"
    assert port.is_listening(80), "port 80 is not listening"
    assert port.is_listening(443), "port 443 is not listening"
    assert user.exists("awx"), "user awx does not exist"
    assert group.is_exists("awx"), "group aws does not exist"
    assert process.is_up("apache2"), "process apache2 is not running"
    assert process.is_up("postgres"), "process postgres is not running"
    assert process.is_up("redis-server"), "process redis-server is not running"
    assert process.is_up("supervisor"), "process supervisor is not running"
    assert service.is_enabled("apache2"), "service apache2 is not enabled"
    assert service.is_enabled("postgres"), "service postgres is not enable"
    assert service.is_enabled("redis-server"),\
        "service redis-server is not enabled"
    assert service.is_enabled("supervisor"),\
        "service supervisor is not enabled"
Ejemplo n.º 26
0
def check():
    env.platform_family = detect.detect()
    release = run("/usr/bin/lsb_release -r | awk {'print $2'}")

    assert package.installed("ansible-tower"), "package ansible-tower is not installed"
    assert file.exists("/etc/awx/settings.py"), "/etc/awx/settings.py does not exist"
    assert port.is_listening(80), "port 80 is not listening"
    assert port.is_listening(443), "port 443 is not listening"
    assert user.exists("awx"), "user awx does not exist"
    assert group.is_exists("awx"), "group aws does not exist"
    assert user.is_belonging_group("awx", "awx"), "user awx is not a member of group awx"
    assert process.is_up("apache2"), "process apache2 is not running"
    assert process.is_up("postgres"), "process postgres is not running"
    if release == "12.04":
        assert process.is_up("beam"), "process beam is not running"  # RabbitMQ
    elif release == "14.04":
        assert process.is_up("rabbitmq-server"), "process rabbitmq-server is not running"
    assert process.is_up("supervisor"), "process supervisor is not running"
    assert service.is_enabled("apache2"), "service apache2 is not enabled"
    assert service.is_enabled("postgres"), "service postgres is not enable"
    assert service.is_enabled("rabbitmq-server"), "service rabbitmq-server is not enables"
    assert service.is_enabled("supervisor"), "service supervisor is not enabled"
Ejemplo n.º 27
0
def acceptance_tests_on_centos7_img_for_flocker(distribution):
    """ checks that the CentOS 7 image is suitable for running the Flocker
    acceptance tests

    :param string distribution: which OS to use 'centos7', 'ubuntu1404'
    """
    with settings():

        env.platform_family = detect.detect()

        # disable requiretty
        # http://tinyurl.com/peoffwk
        log_green("check that tty are not required when sudo'ing")
        assert sudo('grep "^\#Defaults.*requiretty" /etc/sudoers')

        # the epel-release repository is required for a bunch of packages
        log_green('assert that EPEL is installed')
        assert package.installed('epel-release')

        # make sure we installed all the packages we need
        log_green('assert that required rpm packages are installed')
        for pkg in centos7_required_packages():
            # we can't check meta-packages
            if '@' not in pkg:
                log_green('... checking %s' % pkg)
                assert package.installed(pkg)

        # ZFS will be required for the ZFS acceptance tests
        log_green('check that the zfs repository is installed')
        assert package.installed('zfs-release')

        log_green('check that zfs from testing repository is installed')
        assert run(
            'grep "SPL_DKMS_DISABLE_STRIP=y" /etc/sysconfig/spl')
        assert run(
            'grep "ZFS_DKMS_DISABLE_STRIP=y" /etc/sysconfig/zfs')
        assert package.installed("zfs")
        assert run('lsmod |grep zfs')

        # We now need SELinux enabled
        log_green('check that SElinux is enforcing')
        assert sudo('getenforce | grep -i "enforcing"')

        # And Firewalld should be running too
        log_green('check that firewalld is enabled')
        assert sudo("systemctl is-enabled firewalld")

        # EL, won't allow us to run docker as non-root
        # http://tinyurl.com/qfuyxjm
        # but our tests require us to, so we add the 'centos' user to the
        # docker group.
        # and the jenkins bootstrapping of the node will change the
        # docker sysconfig file to run as 'docker' group.
        # TODO: move that jenkins code here
        # https://clusterhq.atlassian.net/browse/FLOC-2995
        log_green('check that centos is part of group docker')
        assert user.exists("centos")
        assert group.is_exists("docker")
        assert user.is_belonging_group("centos", "docker")

        # the acceptance tests look for a package in a yum repository,
        # we provide one by starting a webserver and pointing the tests
        # to look over there.
        # for that we need 'nginx' installed and running
        log_green('check that nginx is running')
        assert package.installed('nginx')
        assert port.is_listening(80, "tcp")
        assert process.is_up("nginx")
        assert sudo("systemctl is-enabled nginx")

        # the client acceptance tests run on docker instances
        log_green('check that docker is running')
        assert sudo('rpm -q docker-engine | grep "1.10."')
        assert process.is_up("docker")
        assert sudo("systemctl is-enabled docker")