diff --git a/tests/test_ntp.py b/tests/test_ntp.py index 9156d53083cde56359ccc45e5cd4d3302fb51e2c..fa65ea8fcc7d619c16f887a2812cd6bd27c5d02e 100644 --- a/tests/test_ntp.py +++ b/tests/test_ntp.py @@ -3,11 +3,16 @@ from testinfra.utils.ansible_runner import AnsibleRunner testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') -def test_ntp(Service): - assert Service('systemd-timesyncd').is_running or Service( - 'ntpd').is_running or Service('openntpd').is_running +def test_ntp(Service, SystemInfo): + if SystemInfo.type == 'openbsd': + service = Service('ntpd') + elif SystemInfo.type == 'linux': + if SystemInfo.codename in ['jessie', 'stretch', 'xenial']: + service = Service('systemd-timesyncd') + else: + service = Service('openntpd') + assert service.is_running try: - Service('systemd-timesyncd').is_enabled or Service( - 'ntpd').is_enabled or Service('openntpd').is_enabled + assert service.is_enabled except NotImplementedError: pass