1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Check for ansible_facts in results for with_ tasks

that loop over a lookup plugin. Fixes #3704 and #3735
This commit is contained in:
Serge van Ginderachter 2013-08-08 16:21:03 +02:00 committed by James Cammarata
parent 40e60c947d
commit 1a4e6e415e

View file

@ -361,8 +361,15 @@ class PlayBook(object):
# add facts to the global setup cache
for host, result in contacted.iteritems():
facts = result.get('ansible_facts', {})
self.SETUP_CACHE[host].update(facts)
if 'results' in result:
# task ran with_ lookup plugin, so facts are encapsulated in
# multiple list items in the results key
for res in result['results']:
facts = res.get('ansible_facts', {})
self.SETUP_CACHE[host].update(facts)
else:
facts = result.get('ansible_facts', {})
self.SETUP_CACHE[host].update(facts)
# extra vars need to always trump - so update again following the facts
self.SETUP_CACHE[host].update(self.extra_vars)
if task.register: