summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSloane Hertel <shertel@redhat.com>2018-06-29 14:19:34 -0400
committerToshio Kuratomi <a.badger@gmail.com>2018-06-29 11:19:34 -0700
commit22a6927dbd51c213cf8b81d8f5852332b54aa1b9 (patch)
tree29cecba6c55ef95abfe60f0a612b4da01265e8f5 /lib
parente9dbebfa57187dea49631ea1669ec9c0c244cd3a (diff)
downloadansible-22a6927dbd51c213cf8b81d8f5852332b54aa1b9.tar.gz
Fix file module with check_mode - Fixes #42111 (#42115)
* Fix file module check_mode
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/modules/files/file.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/ansible/modules/files/file.py b/lib/ansible/modules/files/file.py
index 6fc5622482..bf1ed8a784 100644
--- a/lib/ansible/modules/files/file.py
+++ b/lib/ansible/modules/files/file.py
@@ -322,6 +322,9 @@ def execute_touch(path, follow):
b_path = to_bytes(path, errors='surrogate_or_strict')
prev_state = get_state(b_path)
+ # Unfortunately, touch always changes the file because it updates file's timestamp
+ result = {'dest': path, 'changed': True}
+
if not module.check_mode:
if prev_state == 'absent':
# Create an empty file if the filename did not already exist
@@ -369,8 +372,8 @@ def execute_touch(path, follow):
os.remove(b_path)
raise
- # Unfortunately, touch always changes the file because it updates file's timestamp
- return {'dest': path, 'changed': True, 'diff': diff}
+ result['diff'] = diff
+ return result
def ensure_file_attributes(path, follow):