mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
file - allow touch on files not owned by user (#50964)
* file - allow touch on files not owned by user * use Sentinal value and preserved existing args * Do no instantiate the Sentinel object
This commit is contained in:
@@ -488,6 +488,37 @@
|
||||
that:
|
||||
- result.mode == '0444'
|
||||
|
||||
# https://github.com/ansible/ansible/issues/50943
|
||||
# Need to use /tmp as nobody can't access output_dir at all
|
||||
- name: create file as root with all write permissions
|
||||
file: dest=/tmp/write_utime state=touch mode=0666 owner={{ansible_user}}
|
||||
|
||||
- block:
|
||||
- name: get previous time
|
||||
stat: path=/tmp/write_utime
|
||||
register: previous_time
|
||||
|
||||
- name: touch file as nobody
|
||||
file: dest=/tmp/write_utime state=touch
|
||||
become: True
|
||||
become_user: nobody
|
||||
register: result
|
||||
|
||||
- name: get new time
|
||||
stat: path=/tmp/write_utime
|
||||
register: current_time
|
||||
|
||||
always:
|
||||
- name: remove test utime file
|
||||
file: path=/tmp/write_utime state=absent
|
||||
|
||||
- name: assert touch file as nobody
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- current_time.stat.atime > previous_time.stat.atime
|
||||
- current_time.stat.mtime > previous_time.stat.mtime
|
||||
|
||||
# Follow + recursive tests
|
||||
- name: create a toplevel directory
|
||||
file: path={{output_dir}}/test_follow_rec state=directory mode=0755
|
||||
|
||||
Reference in New Issue
Block a user