diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 639f4c065b4..b41c676a7b8 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -855,5 +855,4 @@ class Play(object): # finally, update the VARS_CACHE for the host, if it is set if host is not None: - self.playbook.VARS_CACHE[host].update(self.vars) self.playbook.VARS_CACHE[host].update(self.playbook.extra_vars) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index feda312456e..7b943003f2e 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -570,7 +570,10 @@ class Runner(object): hostvars = HostVars(combined_cache, self.inventory, vault_password=self.vault_pass) # use combined_cache and host_variables to template the module_vars + # we update the inject variables with the data we're about to template + # since some of the variables we'll be replacing may be contained there too module_vars_inject = utils.combine_vars(combined_cache.get(host, {}), host_variables) + module_vars_inject.update(self.module_vars) module_vars = template.template(self.basedir, self.module_vars, module_vars_inject) inject = {}