better reading of 'facts'

This commit is contained in:
Brian Coca 2017-07-19 20:23:13 -04:00 committed by Brian Coca
parent 3401a4b330
commit c7e841e0e4
2 changed files with 2 additions and 4 deletions

View file

@ -52,8 +52,7 @@ class ActionModule(ActionBase):
if module == 'auto':
facts = self._execute_module(module_name='setup', module_args=dict(filter='ansible_pkg_mgr', gather_subset='!all'), task_vars=task_vars)
display.debug("Facts %s" % facts)
if 'ansible_facts' in facts and 'ansible_pkg_mgr' in facts['ansible_facts']:
module = getattr(facts['ansible_facts'], 'ansible_pkg_mgr', 'auto')
module = facts.get('ansible_facts', {}).get('ansible_pkg_mgr', 'auto')
if module != 'auto':

View file

@ -51,8 +51,7 @@ class ActionModule(ActionBase):
if module == 'auto':
facts = self._execute_module(module_name='setup', module_args=dict(gather_subset='!all', filter='ansible_service_mgr'), task_vars=task_vars)
self._display.debug("Facts %s" % facts)
if 'ansible_facts' in facts and 'ansible_service_mgr' in facts['ansible_facts']:
module = facts['ansible_facts']['ansible_service_mgr']
module = facts.get('ansible_facts', {}).get('ansible_service_mgr', 'auto')
if not module or module == 'auto' or module not in self._shared_loader_obj.module_loader:
module = 'service'