mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Minor modification to set_fact with_items patch
Previous patch was reverted due to the fact that there was an issue with the results not always being a dictionary (they're sometimes a unicode string, ie. when the with_items is used with yum). This minor change corrects that by checking for a dict object.
This commit is contained in:
parent
8be2fc745b
commit
ceff3b6ba3
1 changed files with 10 additions and 2 deletions
|
@ -361,8 +361,16 @@ class PlayBook(object):
|
||||||
|
|
||||||
# add facts to the global setup cache
|
# add facts to the global setup cache
|
||||||
for host, result in contacted.iteritems():
|
for host, result in contacted.iteritems():
|
||||||
facts = result.get('ansible_facts', {})
|
if 'results' in result:
|
||||||
self.SETUP_CACHE[host].update(facts)
|
# task ran with_ lookup plugin, so facts are encapsulated in
|
||||||
|
# multiple list items in the results key
|
||||||
|
for res in result['results']:
|
||||||
|
if type(res) == dict:
|
||||||
|
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
|
# extra vars need to always trump - so update again following the facts
|
||||||
self.SETUP_CACHE[host].update(self.extra_vars)
|
self.SETUP_CACHE[host].update(self.extra_vars)
|
||||||
if task.register:
|
if task.register:
|
||||||
|
|
Loading…
Reference in a new issue