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

Merge pull request #1945 from skvidal/extravars

- make extra-vars override all other vars and facts in playbooks
This commit is contained in:
Daniel Hokka Zakrisson 2013-01-31 08:33:59 -08:00
commit 923929081a
2 changed files with 5 additions and 1 deletions

View file

@ -315,6 +315,8 @@ class PlayBook(object):
continue continue
facts = result.get('ansible_facts', {}) facts = result.get('ansible_facts', {})
self.SETUP_CACHE[host].update(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 task.register:
if 'stdout' in result: if 'stdout' in result:
result['stdout_lines'] = result['stdout'].splitlines() result['stdout_lines'] = result['stdout'].splitlines()
@ -390,7 +392,6 @@ class PlayBook(object):
''' run a list of tasks for a given pattern, in order ''' ''' run a list of tasks for a given pattern, in order '''
self.callbacks.on_play_start(play.name) self.callbacks.on_play_start(play.name)
# if no hosts matches this play, drop out # if no hosts matches this play, drop out
if not self.inventory.list_hosts(play.hosts): if not self.inventory.list_hosts(play.hosts):
self.callbacks.on_no_hosts_matched() self.callbacks.on_no_hosts_matched()

View file

@ -186,6 +186,9 @@ class Play(object):
else: else:
vars.update(self.vars) vars.update(self.vars)
if type(self.playbook.extra_vars) == dict:
vars.update(self.playbook.extra_vars)
if type(self.vars_prompt) == list: if type(self.vars_prompt) == list:
for var in self.vars_prompt: for var in self.vars_prompt:
if not 'name' in var: if not 'name' in var: