Skip to content

Instantly share code, notes, and snippets.

@jimi-c
Created August 9, 2013 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimi-c/6190604 to your computer and use it in GitHub Desktop.
Save jimi-c/6190604 to your computer and use it in GitHub Desktop.
diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py
index 716ac59..15ac998 100644
--- a/lib/ansible/playbook/__init__.py
+++ b/lib/ansible/playbook/__init__.py
@@ -361,8 +361,16 @@ 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']:
+ 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
self.SETUP_CACHE[host].update(self.extra_vars)
if task.register:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment