Allow gather_facts: False in a playbook as a way of disabling the fact step if you know

you aren't going to need it.
This commit is contained in:
Michael DeHaan 2012-07-14 19:49:42 -04:00
parent 3466ad5e45
commit 60d64251f8
3 changed files with 26 additions and 20 deletions

View file

@ -25,6 +25,7 @@ Ansible Changes By Release
* error reporting if with_items value is unbound * error reporting if with_items value is unbound
* with_items no longer creates lots of tasks, creates one task that makes multiple calls * with_items no longer creates lots of tasks, creates one task that makes multiple calls
* can use host_specific facts inside with_items (see above) * can use host_specific facts inside with_items (see above)
* at the top level of a playbook, set 'gather_facts: False' to skip fact gathering
0.5 "Amsterdam" ------- July 04, 2012 0.5 "Amsterdam" ------- July 04, 2012

View file

@ -274,13 +274,16 @@ class PlayBook(object):
''' get facts from the remote system ''' ''' get facts from the remote system '''
host_list = [ h for h in self.inventory.list_hosts(play.hosts)
if not (h in self.stats.failures or h in self.stats.dark) ]
if not play.gather_facts:
return {}
setup_args = {} setup_args = {}
self.callbacks.on_setup() self.callbacks.on_setup()
host_list = [ h for h in self.inventory.list_hosts(play.hosts)
if not (h in self.stats.failures or h in self.stats.dark) ]
self.inventory.restrict_to(host_list) self.inventory.restrict_to(host_list)
# push any variables down to the system # push any variables down to the system

View file

@ -29,7 +29,7 @@ class Play(object):
'hosts', 'name', 'vars', 'vars_prompt', 'vars_files', 'hosts', 'name', 'vars', 'vars_prompt', 'vars_files',
'handlers', 'remote_user', 'remote_port', 'handlers', 'remote_user', 'remote_port',
'sudo', 'sudo_user', 'transport', 'playbook', 'sudo', 'sudo_user', 'transport', 'playbook',
'tags', '_ds', '_handlers', '_tasks' 'tags', 'gather_facts', '_ds', '_handlers', '_tasks'
] ]
# ************************************************* # *************************************************
@ -63,6 +63,8 @@ class Play(object):
self.sudo_user = ds.get('sudo_user', self.playbook.sudo_user) self.sudo_user = ds.get('sudo_user', self.playbook.sudo_user)
self.transport = ds.get('connection', self.playbook.transport) self.transport = ds.get('connection', self.playbook.transport)
self.tags = ds.get('tags', None) self.tags = ds.get('tags', None)
self.gather_facts = ds.get('gather_facts', True)
print "self.gather_facts: %s" % self.gather_facts
self._update_vars_files_for_host(None) self._update_vars_files_for_host(None)