From 087b5277f15ba35602cf2214014df52744298ec3 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Mon, 5 Jun 2017 09:39:05 -0400 Subject: [PATCH] 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 --- lib/ansible/module_utils/facts/system/service_mgr.py | 3 ++- lib/ansible/modules/system/hostname.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/facts/system/service_mgr.py b/lib/ansible/module_utils/facts/system/service_mgr.py index 07a6bc8989..ff7ee7ab4a 100644 --- a/lib/ansible/module_utils/facts/system/service_mgr.py +++ b/lib/ansible/module_utils/facts/system/service_mgr.py @@ -39,7 +39,8 @@ class ServiceMgrFactCollector(BaseFactCollector): name = 'service_mgr' _fact_ids = set() - def is_systemd_managed(self, module): + @staticmethod + def is_systemd_managed(module): # tools must be installed if module.get_bin_path('systemctl'): diff --git a/lib/ansible/modules/system/hostname.py b/lib/ansible/modules/system/hostname.py index 0c55008b9d..c06836b0b5 100644 --- a/lib/ansible/modules/system/hostname.py +++ b/lib/ansible/modules/system/hostname.py @@ -53,7 +53,7 @@ from distutils.version import LooseVersion # import module snippets 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 @@ -112,7 +112,7 @@ class Hostname(object): def __init__(self, module): self.module = module 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) else: self.strategy = self.strategy_class(module)