Skip to content
Snippets Groups Projects
Commit f584b139 authored by nimrod's avatar nimrod
Browse files

- Testinfra's Service module can't handle a missing service, so for now I'm...

- Testinfra's Service module can't handle a missing service, so for now I'm guessing the correct service by OS and release.
parent 17705ad0
No related branches found
No related tags found
No related merge requests found
...@@ -3,11 +3,16 @@ from testinfra.utils.ansible_runner import AnsibleRunner ...@@ -3,11 +3,16 @@ from testinfra.utils.ansible_runner import AnsibleRunner
testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all') testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def test_ntp(Service): def test_ntp(Service, SystemInfo):
assert Service('systemd-timesyncd').is_running or Service( if SystemInfo.type == 'openbsd':
'ntpd').is_running or Service('openntpd').is_running 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: try:
Service('systemd-timesyncd').is_enabled or Service( assert service.is_enabled
'ntpd').is_enabled or Service('openntpd').is_enabled
except NotImplementedError: except NotImplementedError:
pass pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment