2020-01-28 21:39:05 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
import testinfra.utils.ansible_runner
|
|
|
|
|
|
|
|
import warnings
|
2021-06-07 20:14:42 +00:00
|
|
|
|
2020-01-28 21:39:05 +00:00
|
|
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
|
|
|
|
|
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
2021-06-07 20:14:42 +00:00
|
|
|
os.environ['MOLECULE_INVENTORY_FILE']
|
|
|
|
).get_hosts('all')
|
2020-01-28 21:39:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_logrotate_install(host):
|
|
|
|
assert host.package("logrotate").is_installed
|
|
|
|
|
|
|
|
|
|
|
|
def test_logrotate_globals(host):
|
|
|
|
conf = host.file("/etc/logrotate.conf")
|
|
|
|
|
|
|
|
assert conf.exists
|
|
|
|
assert conf.contains("# Ansible managed")
|
|
|
|
assert conf.contains("rotate 4")
|
|
|
|
assert conf.contains("include /etc/logrotate.d")
|
|
|
|
|
|
|
|
|
|
|
|
def test_logrotate_sysconfig(host):
|
|
|
|
conf = host.file("/etc/logrotate.d/syslog")
|
|
|
|
|
|
|
|
assert conf.exists
|
|
|
|
assert conf.contains("# Ansible managed")
|
|
|
|
assert conf.contains("missingok")
|
|
|
|
assert conf.contains("/usr/bin/systemctl kill")
|