diff options
author | Sloane Hertel <shertel@redhat.com> | 2018-06-29 14:19:34 -0400 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-06-29 11:19:34 -0700 |
commit | 22a6927dbd51c213cf8b81d8f5852332b54aa1b9 (patch) | |
tree | 29cecba6c55ef95abfe60f0a612b4da01265e8f5 /lib | |
parent | e9dbebfa57187dea49631ea1669ec9c0c244cd3a (diff) | |
download | ansible-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.py | 7 |
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): |