mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Introduce per task variables and push them to templates.
This commit is contained in:
parent
edd5baad8b
commit
ab86726a15
3 changed files with 38 additions and 8 deletions
|
@ -74,7 +74,7 @@ class Runner(object):
|
|||
remote_user=C.DEFAULT_REMOTE_USER, remote_pass=C.DEFAULT_REMOTE_PASS,
|
||||
remote_port=C.DEFAULT_REMOTE_PORT, background=0, basedir=None, setup_cache=None,
|
||||
transport='paramiko', conditional='True', groups={}, callbacks=None, verbose=False,
|
||||
debug=False, sudo=False, extra_vars=None):
|
||||
debug=False, sudo=False, extra_vars=None, module_vars=None):
|
||||
|
||||
if setup_cache is None:
|
||||
setup_cache = {}
|
||||
|
@ -101,6 +101,7 @@ class Runner(object):
|
|||
self.forks = int(forks)
|
||||
self.pattern = pattern
|
||||
self.module_args = module_args
|
||||
self.module_vars = module_vars
|
||||
self.extra_vars = extra_vars
|
||||
self.timeout = timeout
|
||||
self.debug = debug
|
||||
|
@ -498,8 +499,16 @@ class Runner(object):
|
|||
# install the template module
|
||||
template_module = self._transfer_module(conn, tmp, 'template')
|
||||
|
||||
# transfer module vars
|
||||
if self.module_vars:
|
||||
vars = utils.bigjson(self.module_vars)
|
||||
vars_path = self._transfer_str(conn, tmp, 'module_vars', vars)
|
||||
vars_arg=" vars=%s"%(vars_path)
|
||||
else:
|
||||
vars_arg=""
|
||||
|
||||
# run the template module
|
||||
args = "src=%s dest=%s metadata=%s" % (temppath, dest, metadata)
|
||||
args = "src=%s dest=%s metadata=%s%s" % (temppath, dest, metadata, vars_arg)
|
||||
(result1, err, executed) = self._execute_module(conn, tmp, template_module, args)
|
||||
(host, ok, data, err) = self._return_from_module(conn, host, result1, err, executed)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue