using delegated host's facts when delegating (#17489)

fixes #17313
This commit is contained in:
Brian Coca 2016-09-09 17:26:47 -04:00 committed by GitHub
parent af2ce7725b
commit 0aaee0272a
2 changed files with 8 additions and 2 deletions

View file

@ -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!

View file

@ -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!