mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
* Add new parameters related to mtime and atime for file module, fixes #30226
This commit is contained in:
parent
1b3f074ec6
commit
a78cc15099
3 changed files with 203 additions and 42 deletions
|
@ -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
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue