1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Make ServiceMgrFactCollector.is_systemd_managed() a static method (#25316)

Fix 'hostname' module Facts is not defined by updating
'hostname' module to use it.

is_systemd_managed() was previously on the module_utils.facts.Facts
class that no longer exists.

Fixes #25289
This commit is contained in:
Adrian Likins 2017-06-05 09:39:05 -04:00 committed by GitHub
parent 8f7c8ef3a5
commit 087b5277f1
2 changed files with 4 additions and 3 deletions

View file

@ -39,7 +39,8 @@ class ServiceMgrFactCollector(BaseFactCollector):
name = 'service_mgr' name = 'service_mgr'
_fact_ids = set() _fact_ids = set()
def is_systemd_managed(self, module): @staticmethod
def is_systemd_managed(module):
# tools must be installed # tools must be installed
if module.get_bin_path('systemctl'): if module.get_bin_path('systemctl'):

View file

@ -53,7 +53,7 @@ from distutils.version import LooseVersion
# import module snippets # import module snippets
from ansible.module_utils.basic import * from ansible.module_utils.basic import *
from ansible.module_utils.facts import * from ansible.module_utils.facts.system.service_mgr import ServiceMgrFactCollector
from ansible.module_utils._text import to_bytes, to_native from ansible.module_utils._text import to_bytes, to_native
@ -112,7 +112,7 @@ class Hostname(object):
def __init__(self, module): def __init__(self, module):
self.module = module self.module = module
self.name = module.params['name'] self.name = module.params['name']
if self.platform == 'Linux' and Facts(module).is_systemd_managed(): if self.platform == 'Linux' and ServiceMgrFactCollector.is_systemd_managed(module):
self.strategy = SystemdStrategy(module) self.strategy = SystemdStrategy(module)
else: else:
self.strategy = self.strategy_class(module) self.strategy = self.strategy_class(module)