|
|
@ -335,11 +335,13 @@ class Runner(object):
|
|
|
|
if not found:
|
|
|
|
if not found:
|
|
|
|
results=dict(failed=True, msg="could not find src in first_available_file list")
|
|
|
|
results=dict(failed=True, msg="could not find src in first_available_file list")
|
|
|
|
return ReturnData(host=conn.host, results=results)
|
|
|
|
return ReturnData(host=conn.host, results=results)
|
|
|
|
|
|
|
|
|
|
|
|
if self.module_vars is not None:
|
|
|
|
if self.module_vars is None:
|
|
|
|
inject.update(self.module_vars)
|
|
|
|
self.module_vars = {}
|
|
|
|
|
|
|
|
lookup_table = self.module_vars.copy()
|
|
|
|
|
|
|
|
lookup_table.update(inject)
|
|
|
|
|
|
|
|
|
|
|
|
source = utils.template(source, inject)
|
|
|
|
source = utils.template(source, lookup_table)
|
|
|
|
source = utils.path_dwim(self.basedir, source)
|
|
|
|
source = utils.path_dwim(self.basedir, source)
|
|
|
|
|
|
|
|
|
|
|
|
local_md5 = utils.md5(source)
|
|
|
|
local_md5 = utils.md5(source)
|
|
|
@ -361,7 +363,7 @@ class Runner(object):
|
|
|
|
|
|
|
|
|
|
|
|
# run the copy module
|
|
|
|
# run the copy module
|
|
|
|
args = "src=%s dest=%s" % (tmp_src, dest)
|
|
|
|
args = "src=%s dest=%s" % (tmp_src, dest)
|
|
|
|
exec_rc = self._execute_module(conn, tmp, module, args, inject=inject)
|
|
|
|
exec_rc = self._execute_module(conn, tmp, module, args, inject=lookup_table)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# no need to transfer the file, already correct md5
|
|
|
|
# no need to transfer the file, already correct md5
|
|
|
|
result = dict(changed=False, md5sum=remote_md5, transferred=False)
|
|
|
|
result = dict(changed=False, md5sum=remote_md5, transferred=False)
|
|
|
@ -440,7 +442,6 @@ class Runner(object):
|
|
|
|
options = utils.parse_kv(self.module_args)
|
|
|
|
options = utils.parse_kv(self.module_args)
|
|
|
|
source = options.get('src', None)
|
|
|
|
source = options.get('src', None)
|
|
|
|
dest = options.get('dest', None)
|
|
|
|
dest = options.get('dest', None)
|
|
|
|
metadata = options.get('metadata', None)
|
|
|
|
|
|
|
|
if (source is None and 'first_available_file' not in self.module_vars) or dest is None:
|
|
|
|
if (source is None and 'first_available_file' not in self.module_vars) or dest is None:
|
|
|
|
result = dict(failed=True, msg="src and dest are required")
|
|
|
|
result = dict(failed=True, msg="src and dest are required")
|
|
|
|
return ReturnData(host=conn.host, comm_ok=False, result=result)
|
|
|
|
return ReturnData(host=conn.host, comm_ok=False, result=result)
|
|
|
@ -459,17 +460,19 @@ class Runner(object):
|
|
|
|
result = dict(failed=True, msg="could not find src in first_available_file list")
|
|
|
|
result = dict(failed=True, msg="could not find src in first_available_file list")
|
|
|
|
return ReturnData(host=conn.host, comm_ok=False, result=result)
|
|
|
|
return ReturnData(host=conn.host, comm_ok=False, result=result)
|
|
|
|
|
|
|
|
|
|
|
|
if self.module_vars is not None:
|
|
|
|
if self.module_vars is None:
|
|
|
|
inject.update(self.module_vars)
|
|
|
|
self.module_vars = {}
|
|
|
|
|
|
|
|
lookup_table = self.module_vars.copy()
|
|
|
|
|
|
|
|
lookup_table.update(inject)
|
|
|
|
|
|
|
|
|
|
|
|
source = utils.template(source, inject)
|
|
|
|
source = utils.template(source, lookup_table)
|
|
|
|
|
|
|
|
|
|
|
|
# install the template module
|
|
|
|
# install the template module
|
|
|
|
copy_module = self._transfer_module(conn, tmp, 'copy')
|
|
|
|
copy_module = self._transfer_module(conn, tmp, 'copy')
|
|
|
|
|
|
|
|
|
|
|
|
# template the source data locally
|
|
|
|
# template the source data locally
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
resultant = utils.template_from_file(self.basedir, source, inject)
|
|
|
|
resultant = utils.template_from_file(self.basedir, source, lookup_table)
|
|
|
|
except Exception, e:
|
|
|
|
except Exception, e:
|
|
|
|
result = dict(failed=True, msg=str(e))
|
|
|
|
result = dict(failed=True, msg=str(e))
|
|
|
|
return ReturnData(host=conn.host, comm_ok=False, result=result)
|
|
|
|
return ReturnData(host=conn.host, comm_ok=False, result=result)
|
|
|
@ -478,7 +481,7 @@ class Runner(object):
|
|
|
|
|
|
|
|
|
|
|
|
# run the COPY module
|
|
|
|
# run the COPY module
|
|
|
|
args = "src=%s dest=%s" % (xfered, dest)
|
|
|
|
args = "src=%s dest=%s" % (xfered, dest)
|
|
|
|
exec_rc = self._execute_module(conn, tmp, copy_module, args, inject=inject)
|
|
|
|
exec_rc = self._execute_module(conn, tmp, copy_module, args, inject=lookup_table)
|
|
|
|
|
|
|
|
|
|
|
|
# modify file attribs if needed
|
|
|
|
# modify file attribs if needed
|
|
|
|
if exec_rc.is_successful():
|
|
|
|
if exec_rc.is_successful():
|
|
|
|