mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
check_systemd is not inline but a private fact function now
This commit is contained in:
parent
e9efd008ed
commit
d194e2c788
1 changed files with 11 additions and 13 deletions
|
@ -575,19 +575,7 @@ class Facts(object):
|
|||
self.facts['service_mgr'] = 'svcs'
|
||||
elif self.facts['system'] == 'Linux':
|
||||
|
||||
def check_systemd(module):
|
||||
# tools must be installed
|
||||
if module.get_bin_path('systemctl'):
|
||||
|
||||
# this should show if systemd is the boot init system, if check_init faild to mark as systemd
|
||||
# these mirror systemd's own sd_boot test http://www.freedesktop.org/software/systemd/man/sd_booted.html
|
||||
for canary in ["/run/systemd/system/", "/dev/.run/systemd/", "/dev/.systemd/"]:
|
||||
if os.path.exists(canary):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
if check_systemd(module):
|
||||
if self._check_systemd(module):
|
||||
self.facts['service_mgr'] = 'systemd'
|
||||
elif module.get_bin_path('initctl') and os.path.exists("/etc/init/"):
|
||||
self.facts['service_mgr'] = 'upstart'
|
||||
|
@ -709,6 +697,16 @@ class Facts(object):
|
|||
self.facts['date_time']['tz'] = time.strftime("%Z")
|
||||
self.facts['date_time']['tz_offset'] = time.strftime("%z")
|
||||
|
||||
def _check_systemd(self):
|
||||
# tools must be installed
|
||||
if module.get_bin_path('systemctl'):
|
||||
|
||||
# this should show if systemd is the boot init system, if check_init faild to mark as systemd
|
||||
# these mirror systemd's own sd_boot test http://www.freedesktop.org/software/systemd/man/sd_booted.html
|
||||
for canary in ["/run/systemd/system/", "/dev/.run/systemd/", "/dev/.systemd/"]:
|
||||
if os.path.exists(canary):
|
||||
return True
|
||||
return False
|
||||
|
||||
# User
|
||||
def get_user_facts(self):
|
||||
|
|
Loading…
Reference in a new issue