def lsync_client(): env.platform_family = detect.detect() wordpress_user = "******" web_group = "www-data" ssh_dir = "/var/www/vhosts/example.com/.ssh" auth_keys = os.path.join(ssh_dir, "authorized_keys") assert user.exists(wordpress_user) assert user.is_belonging_group(wordpress_user, web_group) assert file.dir_exists(ssh_dir) assert file.owner_is(ssh_dir, wordpress_user) assert file.owner_is(auth_keys, wordpress_user) assert file.mode_is(auth_keys, 644)
def check(): env.platform_family = detect.detect() dot_npm = "/home/user1/.npm" assert file.exists(dot_npm), \ "%s does not exist" % dot_npm assert file.is_dir(dot_npm), \ "%s is not a directory" % dot_npm assert file.mode_is(dot_npm, '755'), \ "%s is not mode 755" % dot_npm assert file.owner_is(dot_npm, 'user1'), \ "%s is not owned by user1" % dot_npm # directory { should be_grouped_into 'my_nodejs_app' } assert port.is_listening(80), "port 80/apache2 is not listening" assert user.exists("user1"), "user my_nodejs_app does not exist" assert process.is_up("node"), "node process is not up" # its('args') { should match 'server.js|app.js' } assert service.is_enabled("node-app"), \ "node-app service is not enabled" assert nodejs_is_responding(), "node demo app did not respond as expected"
def mysql(): env.platform_family = detect.detect() if env.platform_family == 'debian': mysql_package = 'mysql-server-5.5' mysql_process = 'mysql' holland_package = 'holland' elif env.platform_family == 'rhel': mysql_package = 'mysql-server' mysql_process = 'mysqld' holland_package = 'holland' else: raise ValueError('OS ' + env.platform_family + ' unknown, update tests.') packages = [holland_package, mysql_package] for pkg in packages: assert package.installed(pkg), ('package ' + pkg + 'not found') assert port.is_listening(3306), '3306 not listening' root_my_cnf = "/root/.my.cnf" assert file.exists(root_my_cnf), 'root my.cnf does not exist' assert file.mode_is(root_my_cnf, 600), \ 'permissions are wrong on root my.cnf' assert file.owner_is(root_my_cnf, "root"), 'owner is wrong on root my.cnf' assert process.is_up(mysql_process), 'mysql is not running' assert service.is_enabled(mysql_process), 'mysql is not enabled'
def check(): env.platform_family = detect.detect() config_js = '/var/app/current/config.js' assert file.exists(config_js), \ "%s does not exist" % config_js assert file_contains(config_js, 'StrictHostKeyChecking false'), \ "%s does not turn off StrictHostKeyChecking" % config_js dot_npm = "/home/my_nodejs_app/.npm" assert file.exists(dot_npm), \ "%s does not exist" % dot_npm assert file.is_dir(dot_npm), \ "%s is not a directory" % dot_npm assert file.is_mode(dot_npm, 'r-xr-xr-x'), \ "%s is not mode 755" % dot_npm assert file.owner_is(dot_npm, 'my_nodejs_app'), \ "%s is not owned by my_nodejs_app" % dot_npm # directory { should be_grouped_into 'my_nodejs_app' } assert port.is_listening(80), "port 80/apache2 is not listening" assert user.exists("my_nodejs_app"), "user my_nodejs_app does not exist" assert user_has_shell('my_nodejs_app', ':/bin/bash'), \ "user should have bash shell" assert process.is_up("node"), "node process is not up" # its('args') { should match 'server.js|app.js' } assert service.is_enabled("my_nodejs_app"), \ "my_nodejs_app service is not enabled" assert apache2_is_responding(), "node demo app did not respond as expected"
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
def lsyncd(): env.platform_family = detect.detect() wordpress_user = "******" web_group = "www-data" ssh_dir = "/var/www/vhosts/example.com/.ssh" private_key = os.path.join(ssh_dir, "id_rsa") assert package.installed("lsyncd") assert process.is_up("lsyncd") assert service.is_enabled("lsyncd") assert user.exists(wordpress_user) assert user.is_belonging_group(wordpress_user, web_group) assert file.dir_exists(ssh_dir) assert file.owner_is(ssh_dir, wordpress_user) assert file.owner_is(private_key, wordpress_user) assert file.mode_is(private_key, 600)
def lsyncd(): env.platform_family = detect.detect() wordpress_user = "******" web_group = "www-data" ssh_dir = "/var/www/vhosts/example.com/.ssh" private_key = os.path.join(ssh_dir, "id_rsa") assert package.installed("lsyncd"), 'lsyncd is not installed' check_lsync_up() assert service.is_enabled("lsyncd"), 'lsyncd is not enabled' assert user.exists(wordpress_user), 'wp_user user does not exist' assert user.exists('wp_user').get('passwd') != '!', 'wp_user pass missing' assert user.is_belonging_group(wordpress_user, web_group), 'wp_user does belong to correct group' assert file.dir_exists(ssh_dir), 'ssh directory does not exist' assert file.owner_is(ssh_dir, wordpress_user), 'wp_user does not own ssh directory' assert file.owner_is(private_key, wordpress_user), 'wp_user does not own ssh key' assert file.mode_is(private_key, 600), 'ssh key is not set to correct mode'
def lsyncd(): env.platform_family = detect.detect() wordpress_user = "******" web_group = "www-data" ssh_dir = "/var/www/vhosts/example.com/.ssh" private_key = os.path.join(ssh_dir, "id_rsa") assert package.installed("lsyncd"), 'lsyncd is not installed' assert process.is_up("lsyncd"), 'lsyncd is not up' assert service.is_enabled("lsyncd"), 'lsyncd is not enabled' assert user.exists(wordpress_user), 'wp_user user does not exist' assert user.exists('wp_user').get('passwd') != '!', 'wp_user pass missing' assert user.is_belonging_group( wordpress_user, web_group), 'wp_user does belong to correct group' assert file.dir_exists(ssh_dir), 'ssh directory does not exist' assert file.owner_is(ssh_dir, wordpress_user), 'wp_user does not own ssh directory' assert file.owner_is(private_key, wordpress_user), 'wp_user does not own ssh key' assert file.mode_is(private_key, 600), 'ssh key is not set to correct mode'
def apache(): env.platform_family = detect.detect() apache_config = "/etc/apache2/sites-enabled/wordpress.conf" web_user = "******" www_dir = "/var/www/vhosts/example.com" assert package.installed("apache2") assert process.is_up("apache2") assert service.is_enabled("apache2") assert port.is_listening(8080) assert file.has_line(apache_config, "VirtualHost *:8080") assert file.owner_is(www_dir, web_user)
def mysql(): env.platform_family = detect.detect() packages = ["holland", "mysql-server"] for pkg in packages: assert package.installed(pkg) assert port.is_listening(3306) assert process.is_up("mysqld") root_my_cnf = "/root/.my.cnf" assert file.exists(root_my_cnf) assert file.mode_is(root_my_cnf, 600) assert file.owner_is(root_my_cnf, "root")