template: change to pass along the correct template path (#35027)
* template: change to pass along the correct template path * standardise tmp path behaviour * removed if condition as it should not be needed
This commit is contained in:
parent
676ce74cbf
commit
389f4ef1fb
12 changed files with 41 additions and 25 deletions
|
@ -85,6 +85,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
if task_vars is None:
|
||||
task_vars = dict()
|
||||
|
||||
|
@ -146,11 +148,11 @@ class ActionModule(ActionBase):
|
|||
if self._play_context.diff:
|
||||
diff = self._get_diff_data(dest, path, task_vars)
|
||||
|
||||
remote_path = self._connection._shell.join_path(self._connection._shell.tempdir, 'src')
|
||||
remote_path = self._connection._shell.join_path(tmp, 'src')
|
||||
xfered = self._transfer_file(path, remote_path)
|
||||
|
||||
# fix file permissions when the copy is done as a different user
|
||||
self._fixup_perms2((self._connection._shell.tempdir, remote_path))
|
||||
self._fixup_perms2((tmp, remote_path))
|
||||
|
||||
new_module_args.update(dict(src=xfered,))
|
||||
|
||||
|
@ -164,6 +166,6 @@ class ActionModule(ActionBase):
|
|||
except AnsibleAction as e:
|
||||
result.update(e.result)
|
||||
finally:
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -15,6 +15,8 @@ class ActionModule(ActionBase):
|
|||
self._supports_async = True
|
||||
results = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
# Command module has a special config option to turn off the command nanny warnings
|
||||
if 'warn' not in self._task.args:
|
||||
self._task.args['warn'] = C.COMMAND_WARNINGS
|
||||
|
@ -24,6 +26,6 @@ class ActionModule(ActionBase):
|
|||
|
||||
if not wrap_async:
|
||||
# remove a temporary path we created
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return results
|
||||
|
|
|
@ -258,7 +258,7 @@ class ActionModule(ActionBase):
|
|||
return result
|
||||
|
||||
# Define a remote directory that we will copy the file to.
|
||||
tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, 'source')
|
||||
tmp_src = self._connection._shell.join_path(tmp, 'source')
|
||||
|
||||
remote_path = None
|
||||
|
||||
|
@ -273,7 +273,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
# fix file permissions when the copy is done as a different user
|
||||
if remote_path:
|
||||
self._fixup_perms2((self._connection._shell.tempdir, remote_path))
|
||||
self._fixup_perms2((tmp, remote_path))
|
||||
|
||||
if raw:
|
||||
# Continue to next iteration if raw is defined.
|
||||
|
@ -389,8 +389,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if tmp is None:
|
||||
tmp = self._connection._shell.tempdir
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
source = self._task.args.get('src', None)
|
||||
content = self._task.args.get('content', None)
|
||||
|
@ -548,6 +547,6 @@ class ActionModule(ActionBase):
|
|||
result.update(dict(dest=dest, src=source, changed=changed))
|
||||
|
||||
# Delete tmp path
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -44,6 +44,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
try:
|
||||
if self._play_context.check_mode:
|
||||
result['skipped'] = True
|
||||
|
@ -212,6 +214,6 @@ class ActionModule(ActionBase):
|
|||
result.update(dict(changed=False, md5sum=local_md5, file=source, dest=dest, checksum=local_checksum))
|
||||
|
||||
finally:
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -31,6 +31,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
if not result.get('skipped'):
|
||||
|
||||
if result.get('invocation', {}).get('module_args'):
|
||||
|
@ -51,6 +53,6 @@ class ActionModule(ActionBase):
|
|||
|
||||
if not wrap_async:
|
||||
# remove a temporary path we created
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -39,6 +39,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
module = self._task.args.get('use', 'auto')
|
||||
|
||||
if module == 'auto':
|
||||
|
@ -76,6 +78,6 @@ class ActionModule(ActionBase):
|
|||
finally:
|
||||
if not self._task.async_val:
|
||||
# remove a temporary path we created
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -36,6 +36,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
src = self._task.args.get('src', None)
|
||||
remote_src = boolean(self._task.args.get('remote_src', 'no'), strict=False)
|
||||
|
||||
|
@ -52,7 +54,7 @@ class ActionModule(ActionBase):
|
|||
except AnsibleError as e:
|
||||
raise AnsibleActionFail(to_native(e))
|
||||
|
||||
tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, os.path.basename(src))
|
||||
tmp_src = self._connection._shell.join_path(tmp, os.path.basename(src))
|
||||
self._transfer_file(src, tmp_src)
|
||||
self._fixup_perms2((tmp_src,))
|
||||
|
||||
|
@ -67,5 +69,5 @@ class ActionModule(ActionBase):
|
|||
except AnsibleAction as e:
|
||||
result.update(e.result)
|
||||
finally:
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
return result
|
||||
|
|
|
@ -42,6 +42,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
try:
|
||||
creates = self._task.args.get('creates')
|
||||
if creates:
|
||||
|
@ -88,7 +90,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
if not self._play_context.check_mode:
|
||||
# transfer the file to a remote tmp location
|
||||
tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, os.path.basename(source))
|
||||
tmp_src = self._connection._shell.join_path(tmp, os.path.basename(source))
|
||||
|
||||
# Convert raw_params to text for the purpose of replacing the script since
|
||||
# parts and tmp_src are both unicode strings and raw_params will be different
|
||||
|
@ -132,6 +134,6 @@ class ActionModule(ActionBase):
|
|||
except AnsibleAction as e:
|
||||
result.update(e.result)
|
||||
finally:
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -38,6 +38,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
module = self._task.args.get('use', 'auto').lower()
|
||||
|
||||
if module == 'auto':
|
||||
|
@ -84,6 +86,6 @@ class ActionModule(ActionBase):
|
|||
result.update(e.result)
|
||||
finally:
|
||||
if not self._task.async_val:
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -24,7 +24,4 @@ class ActionModule(ActionBase):
|
|||
shared_loader_obj=self._shared_loader_obj)
|
||||
result = command_action.run(task_vars=task_vars)
|
||||
|
||||
# remove a temporary path we created
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
|
||||
return result
|
||||
|
|
|
@ -42,6 +42,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
source = self._task.args.get('src', None)
|
||||
dest = self._task.args.get('dest', None)
|
||||
force = boolean(self._task.args.get('force', True), strict=False)
|
||||
|
@ -152,12 +154,12 @@ class ActionModule(ActionBase):
|
|||
loader=self._loader,
|
||||
templar=self._templar,
|
||||
shared_loader_obj=self._shared_loader_obj)
|
||||
result.update(copy_action.run(task_vars=task_vars))
|
||||
result.update(copy_action.run(task_vars=task_vars, tmp=tmp))
|
||||
finally:
|
||||
shutil.rmtree(tempdir)
|
||||
except AnsibleAction as e:
|
||||
result.update(e.result)
|
||||
finally:
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
|
||||
return result
|
||||
|
|
|
@ -37,6 +37,8 @@ class ActionModule(ActionBase):
|
|||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
tmp = self._connection._shell.tempdir
|
||||
|
||||
source = self._task.args.get('src', None)
|
||||
dest = self._task.args.get('dest', None)
|
||||
remote_src = boolean(self._task.args.get('remote_src', False), strict=False)
|
||||
|
@ -83,7 +85,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
if not remote_src:
|
||||
# transfer the file to a remote tmp location
|
||||
tmp_src = self._connection._shell.join_path(self._connection._shell.tempdir, 'source')
|
||||
tmp_src = self._connection._shell.join_path(tmp, 'source')
|
||||
self._transfer_file(source, tmp_src)
|
||||
|
||||
# handle diff mode client side
|
||||
|
@ -91,7 +93,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
if not remote_src:
|
||||
# fix file permissions when the copy is done as a different user
|
||||
self._fixup_perms2((self._connection._shell.tempdir, tmp_src))
|
||||
self._fixup_perms2((tmp, tmp_src))
|
||||
# Build temporary module_args.
|
||||
new_module_args = self._task.args.copy()
|
||||
new_module_args.update(
|
||||
|
@ -119,5 +121,5 @@ class ActionModule(ActionBase):
|
|||
except AnsibleAction as e:
|
||||
result.update(e.result)
|
||||
finally:
|
||||
self._remove_tmp_path(self._connection._shell.tempdir)
|
||||
self._remove_tmp_path(tmp)
|
||||
return result
|
||||
|
|
Loading…
Reference in a new issue