Make the actual user used for executing play available as 'ansible_ssh_user' variable
This commit is contained in:
parent
957a7bf373
commit
a58baae2c4
1 changed files with 9 additions and 3 deletions
|
@ -433,7 +433,6 @@ class Runner(object):
|
||||||
complex_args = utils.safe_eval(complex_args)
|
complex_args = utils.safe_eval(complex_args)
|
||||||
if type(complex_args) != dict:
|
if type(complex_args) != dict:
|
||||||
raise errors.AnsibleError("args must be a dictionary, received %s" % complex_args)
|
raise errors.AnsibleError("args must be a dictionary, received %s" % complex_args)
|
||||||
|
|
||||||
result = self._executor_internal_inner(
|
result = self._executor_internal_inner(
|
||||||
host,
|
host,
|
||||||
self.module_name,
|
self.module_name,
|
||||||
|
@ -478,9 +477,8 @@ class Runner(object):
|
||||||
new_args = new_args + "%s='%s' " % (k,v)
|
new_args = new_args + "%s='%s' " % (k,v)
|
||||||
module_args = new_args
|
module_args = new_args
|
||||||
|
|
||||||
|
# module_name may be dynamic (but cannot contain {{ ansible_ssh_user }})
|
||||||
module_name = template.template(self.basedir, module_name, inject)
|
module_name = template.template(self.basedir, module_name, inject)
|
||||||
module_args = template.template(self.basedir, module_args, inject)
|
|
||||||
complex_args = template.template(self.basedir, complex_args, inject)
|
|
||||||
|
|
||||||
if module_name in utils.plugins.action_loader:
|
if module_name in utils.plugins.action_loader:
|
||||||
if self.background != 0:
|
if self.background != 0:
|
||||||
|
@ -536,9 +534,13 @@ class Runner(object):
|
||||||
actual_host = delegate_to
|
actual_host = delegate_to
|
||||||
actual_port = port
|
actual_port = port
|
||||||
|
|
||||||
|
# user/pass may still contain variables at this stage
|
||||||
actual_user = template.template(self.basedir, actual_user, inject)
|
actual_user = template.template(self.basedir, actual_user, inject)
|
||||||
actual_pass = template.template(self.basedir, actual_pass, inject)
|
actual_pass = template.template(self.basedir, actual_pass, inject)
|
||||||
|
|
||||||
|
# make actual_user available as __magic__ ansible_ssh_user variable
|
||||||
|
inject['ansible_ssh_user'] = actual_user
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if actual_port is not None:
|
if actual_port is not None:
|
||||||
actual_port = int(actual_port)
|
actual_port = int(actual_port)
|
||||||
|
@ -561,6 +563,10 @@ class Runner(object):
|
||||||
if getattr(handler, 'NEEDS_TMPPATH', True):
|
if getattr(handler, 'NEEDS_TMPPATH', True):
|
||||||
tmp = self._make_tmp_path(conn)
|
tmp = self._make_tmp_path(conn)
|
||||||
|
|
||||||
|
# render module_args and complex_args templates
|
||||||
|
module_args = template.template(self.basedir, module_args, inject)
|
||||||
|
complex_args = template.template(self.basedir, complex_args, inject)
|
||||||
|
|
||||||
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
|
result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
Loading…
Reference in a new issue