mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix template not showing a diff with a directory
Template can take a directory as the destination. When that's the case, we need to diff between the source and the file inside of the directory. That happened when the directory was specified with a trailing slash but not when it was specified on its own. This change fixes that. Fixes #24413
This commit is contained in:
parent
16325f6f15
commit
548cacdf6a
1 changed files with 7 additions and 2 deletions
|
@ -97,9 +97,14 @@ class ActionModule(ActionBase):
|
|||
|
||||
directory_prepended = False
|
||||
if dest.endswith(os.sep):
|
||||
# Optimization. trailing slash means we know it's a directory
|
||||
directory_prepended = True
|
||||
base = os.path.basename(source)
|
||||
dest = os.path.join(dest, base)
|
||||
dest = self._connection._shell.join_path(dest, os.path.basename(source))
|
||||
else:
|
||||
# Find out if it's a directory
|
||||
dest_stat = self._execute_remote_stat(dest, task_vars, True, tmp=tmp)
|
||||
if dest_stat['exists'] and dest_stat['isdir']:
|
||||
dest = self._connection._shell.join_path(dest, os.path.basename(source))
|
||||
|
||||
# template the source data locally & get ready to transfer
|
||||
b_source = to_bytes(source)
|
||||
|
|
Loading…
Reference in a new issue