Skip to content

Commit

Permalink
- make extra-vars override all other vars and facts in playbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
skvidal committed Jan 30, 2013
1 parent 0243b7b commit f649777
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ansible/playbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ def _run_task(self, play, task, is_handler):
continue
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:
if 'stdout' in result:
result['stdout_lines'] = result['stdout'].splitlines()
Expand Down Expand Up @@ -390,7 +392,7 @@ def _run_play(self, play):
''' run a list of tasks for a given pattern, in order '''

self.callbacks.on_play_start(play.name)

self.SETUP_CACHE.update(play.vars)
# if no hosts matches this play, drop out
if not self.inventory.list_hosts(play.hosts):
self.callbacks.on_no_hosts_matched()
Expand Down
3 changes: 3 additions & 0 deletions lib/ansible/playbook/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ def _get_vars(self):
else:
vars.update(self.vars)

if type(self.playbook.extra_vars) == dict:
vars.update(self.playbook.extra_vars)

if type(self.vars_prompt) == list:
for var in self.vars_prompt:
if not 'name' in var:
Expand Down

0 comments on commit f649777

Please sign in to comment.