diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2016-09-09 17:26:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-09 17:26:47 -0400 |
commit | 0aaee0272a07fa1cb5081290ec624975ba5b8aa2 (patch) | |
tree | 63d491c6aacfeec9c20df5ac07146ff03d3a1466 | |
parent | af2ce7725b1db4253ef0a14a2eba4a1c640ae2d7 (diff) | |
download | ansible-0aaee0272a07fa1cb5081290ec624975ba5b8aa2.tar.gz |
using delegated host's facts when delegating (#17489)
fixes #17313
-rw-r--r-- | lib/ansible/plugins/action/package.py | 5 | ||||
-rw-r--r-- | lib/ansible/plugins/action/service.py | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/ansible/plugins/action/package.py b/lib/ansible/plugins/action/package.py index 91fefd8ce6..0b725759a9 100644 --- a/lib/ansible/plugins/action/package.py +++ b/lib/ansible/plugins/action/package.py @@ -41,7 +41,10 @@ class ActionModule(ActionBase): if module == 'auto': try: - module = self._templar.template('{{ansible_pkg_mgr}}') + if self._task.delegate_to: # if we delegate, we should use delegated host's facts + module = self._templar.template("{{hostvars['%s']['ansible_pkg_mgr']}}" % self._task.delegate_to) + else: + module = self._templar.template('{{ansible_pkg_mgr}}') except: pass # could not get it from template! diff --git a/lib/ansible/plugins/action/service.py b/lib/ansible/plugins/action/service.py index 3648fa3a44..7a5f99a65f 100644 --- a/lib/ansible/plugins/action/service.py +++ b/lib/ansible/plugins/action/service.py @@ -40,7 +40,10 @@ class ActionModule(ActionBase): if module == 'auto': try: - module = self._templar.template('{{ansible_service_mgr}}') + if self._task.delegate_to: # if we delegate, we should use delegated host's facts + module = self._templar.template("{{hostvars['%s']['ansible_service_mgr']}}" % self._task.delegate_to) + else: + module = self._templar.template('{{ansible_service_mgr}}') except: pass # could not get it from template! |