diff options
author | Stephen SORRIAUX <stephen.sorriaux@gmail.com> | 2018-08-24 02:20:54 +0200 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-08-23 17:20:54 -0700 |
commit | a78cc15099d6a31e948eb5aa6f9f3cc82337f5bc (patch) | |
tree | c4ba894253de086e36ead442b3681a07d030c86b /test/integration/targets/file | |
parent | 1b3f074ec6bdb64e26ad47ce32feef5afa637026 (diff) | |
download | ansible-a78cc15099d6a31e948eb5aa6f9f3cc82337f5bc.tar.gz |
Add new parameters to manage mtime and atime for file module, fixes #30226 (#43230)
* Add new parameters related to mtime and atime for file module, fixes #30226
Diffstat (limited to 'test/integration/targets/file')
-rw-r--r-- | test/integration/targets/file/tasks/directory_as_dest.yml | 29 | ||||
-rw-r--r-- | test/integration/targets/file/tasks/main.yml | 18 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/integration/targets/file/tasks/directory_as_dest.yml b/test/integration/targets/file/tasks/directory_as_dest.yml index decc3835fb..b51fa72a7f 100644 --- a/test/integration/targets/file/tasks/directory_as_dest.yml +++ b/test/integration/targets/file/tasks/directory_as_dest.yml @@ -262,6 +262,35 @@ - 'file8_dir_stat["stat"].isdir' - 'file8_dir_stat["stat"]["mtime"] != file8_initial_dir_stat["stat"]["mtime"]' +- name: Get initial stat info to compare with later + stat: + path: '{{ output_dir }}/sub1' + follow: False + register: file11_initial_dir_stat + +- name: Use touch with directory as dest and keep mtime and atime + file: + dest: '{{output_dir}}/sub1' + state: touch + force: False + modification_time: preserve + access_time: preserve + register: file11_result + +- name: Get stat info to show the directory has not been changed + stat: + path: '{{ output_dir }}/sub1' + follow: False + register: file11_dir_stat + +- name: verify that the directory has not been updated + assert: + that: + - 'file11_result is not changed' + - 'file11_dir_stat["stat"].isdir' + - 'file11_dir_stat["stat"]["mtime"] == file11_initial_dir_stat["stat"]["mtime"]' + - 'file11_dir_stat["stat"]["atime"] == file11_initial_dir_stat["stat"]["atime"]' + # # State=directory realizes that the directory already exists and does nothing # diff --git a/test/integration/targets/file/tasks/main.yml b/test/integration/targets/file/tasks/main.yml index c27a90b512..a8e903f4be 100644 --- a/test/integration/targets/file/tasks/main.yml +++ b/test/integration/targets/file/tasks/main.yml @@ -117,6 +117,24 @@ - name: change ownership and group file: path={{output_dir}}/baz.txt owner=1234 group=1234 +- name: Get stat info to check atime later + stat: path={{output_dir}}/baz.txt + register: file_attributes_result_5_before + +- name: updates access time + file: path={{output_dir}}/baz.txt access_time=now + register: file_attributes_result_5 + +- name: Get stat info to check atime later + stat: path={{output_dir}}/baz.txt + register: file_attributes_result_5_after + +- name: verify that the file was marked as changed and atime changed + assert: + that: + - "file_attributes_result_5 is changed" + - "file_attributes_result_5_after['stat']['atime'] != file_attributes_result_5_before['stat']['atime']" + - name: setup a tmp-like directory for ownership test file: path=/tmp/worldwritable mode=1777 state=directory |