(cherry picked from commit 21fee95af7)
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- "``package``/``dnf`` action plugins - provide the reason behind the failure to gather the ``ansible_pkg_mgr`` fact to identify the package backend"
|
||||
@ -41,6 +41,13 @@ class ActionModule(ActionBase):
|
||||
facts = self._execute_module(
|
||||
module_name="ansible.legacy.setup", module_args=dict(filter="ansible_pkg_mgr", gather_subset="!all"),
|
||||
task_vars=task_vars)
|
||||
|
||||
if facts.get("failed", False):
|
||||
raise AnsibleActionFail(
|
||||
f"Failed to fetch ansible_pkg_mgr to determine the dnf action backend: {facts.get('msg')}",
|
||||
result=facts,
|
||||
)
|
||||
|
||||
display.debug("Facts %s" % facts)
|
||||
module = facts.get("ansible_facts", {}).get("ansible_pkg_mgr", "auto")
|
||||
if (not self._task.delegate_to or self._task.delegate_facts) and module != 'auto':
|
||||
@ -75,9 +82,4 @@ class ActionModule(ActionBase):
|
||||
result.update(self._execute_module(
|
||||
module_name=module, module_args=new_module_args, task_vars=task_vars, wrap_async=self._task.async_val))
|
||||
|
||||
# Cleanup
|
||||
if not self._task.async_val:
|
||||
# remove a temporary path we created
|
||||
self._remove_tmp_path(self._connection._shell.tmpdir)
|
||||
|
||||
return result
|
||||
|
||||
@ -68,6 +68,11 @@ class ActionModule(ActionBase):
|
||||
module_args=dict(filter='ansible_pkg_mgr', gather_subset='!all'),
|
||||
task_vars=task_vars,
|
||||
)
|
||||
if facts.get("failed", False):
|
||||
raise AnsibleActionFail(
|
||||
f"Failed to fetch ansible_pkg_mgr to determine the package action backend: {facts.get('msg')}",
|
||||
result=facts,
|
||||
)
|
||||
pmgr = 'ansible_pkg_mgr'
|
||||
|
||||
try:
|
||||
@ -103,9 +108,5 @@ class ActionModule(ActionBase):
|
||||
|
||||
except AnsibleAction as e:
|
||||
result.update(e.result)
|
||||
finally:
|
||||
if not self._task.async_val:
|
||||
# remove a temporary path we created
|
||||
self._remove_tmp_path(self._connection._shell.tmpdir)
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user