|
|
@ -51,42 +51,38 @@ class ActionModule(ActionBase):
|
|
|
|
|
|
|
|
|
|
|
|
source = self._task.args.get('src', None)
|
|
|
|
source = self._task.args.get('src', None)
|
|
|
|
dest = self._task.args.get('dest', None)
|
|
|
|
dest = self._task.args.get('dest', None)
|
|
|
|
|
|
|
|
faf = task_vars.get('first_available_file', None)
|
|
|
|
|
|
|
|
|
|
|
|
if (source is None and 'first_available_file' not in task_vars) or dest is None:
|
|
|
|
if (source is None and faf is not None) or dest is None:
|
|
|
|
return dict(failed=True, msg="src and dest are required")
|
|
|
|
return dict(failed=True, msg="src and dest are required")
|
|
|
|
|
|
|
|
|
|
|
|
if tmp is None:
|
|
|
|
if tmp is None:
|
|
|
|
tmp = self._make_tmp_path()
|
|
|
|
tmp = self._make_tmp_path()
|
|
|
|
|
|
|
|
|
|
|
|
##################################################################################################
|
|
|
|
if faf:
|
|
|
|
# FIXME: this all needs to be sorted out
|
|
|
|
#FIXME: issue deprecation warning for first_available_file, use with_first_found or lookup('first_found',...) instead
|
|
|
|
##################################################################################################
|
|
|
|
found = False
|
|
|
|
# if we have first_available_file in our vars
|
|
|
|
for fn in faf:
|
|
|
|
# look up the files and use the first one we find as src
|
|
|
|
fn_orig = fn
|
|
|
|
#if 'first_available_file' in task_vars:
|
|
|
|
fnt = self._templar.template(fn)
|
|
|
|
# found = False
|
|
|
|
fnd = self._loader.path_dwim(self._task._role_._role_path, 'templates', fnt)
|
|
|
|
# for fn in task_vars.get('first_available_file'):
|
|
|
|
|
|
|
|
# fn_orig = fn
|
|
|
|
if not os.path.exists(fnd):
|
|
|
|
# fnt = template.template(self.runner.basedir, fn, task_vars)
|
|
|
|
of = task_vars.get('_original_file', None)
|
|
|
|
# fnd = utils.path_dwim(self.runner.basedir, fnt)
|
|
|
|
if of is not None:
|
|
|
|
# if not os.path.exists(fnd) and '_original_file' in task_vars:
|
|
|
|
fnd = self._loader.path_dwim(self._task._role_._role_path, 'templates', of)
|
|
|
|
# fnd = utils.path_dwim_relative(task_vars['_original_file'], 'templates', fnt, self.runner.basedir, check=False)
|
|
|
|
|
|
|
|
# if os.path.exists(fnd):
|
|
|
|
if os.path.exists(fnd):
|
|
|
|
# source = fnd
|
|
|
|
source = fnd
|
|
|
|
# found = True
|
|
|
|
found = True
|
|
|
|
# break
|
|
|
|
break
|
|
|
|
# if not found:
|
|
|
|
if not found:
|
|
|
|
# result = dict(failed=True, msg="could not find src in first_available_file list")
|
|
|
|
return dict(failed=True, msg="could not find src in first_available_file list")
|
|
|
|
# return ReturnData(conn=conn, comm_ok=False, result=result)
|
|
|
|
else:
|
|
|
|
#else:
|
|
|
|
|
|
|
|
if 1:
|
|
|
|
|
|
|
|
if self._task._role is not None:
|
|
|
|
if self._task._role is not None:
|
|
|
|
source = self._loader.path_dwim_relative(self._task._role._role_path, 'templates', source)
|
|
|
|
source = self._loader.path_dwim_relative(self._task._role._role_path, 'templates', source)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
source = self._loader.path_dwim(source)
|
|
|
|
source = self._loader.path_dwim(source)
|
|
|
|
##################################################################################################
|
|
|
|
|
|
|
|
# END FIXME
|
|
|
|
|
|
|
|
##################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Expand any user home dir specification
|
|
|
|
# Expand any user home dir specification
|
|
|
|
dest = self._remote_expand_user(dest, tmp)
|
|
|
|
dest = self._remote_expand_user(dest, tmp)
|
|
|
|