mirror of https://github.com/ansible/ansible.git
atomic_move - fix preserving extended acls (#82818)
* use copystat to copy as many attributes as possible before os.rename update unit test mocks for updated method of attribute preservation add integration test for lineinfile case remove erroneous `- meta: end_play` from lineinfile test suite * add keep_dest_attrs parameter to control whether src attributes are copied initially, and for existing destinations, whether the src is updated using the dest before being renamed consolidate with copy unsetting extended attrs ci_completepull/82840/head
parent
7adc146e2f
commit
2bb09bfd12
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- AnsibleModule.atomic_move - fix preserving extended ACLs of the destination when it exists (https://github.com/ansible/ansible/issues/72929).
|
@ -1 +1,2 @@
|
||||
shippable/posix/group2
|
||||
destructive
|
||||
|
@ -0,0 +1,54 @@
|
||||
- block:
|
||||
- name: Install the acl package on Ubuntu
|
||||
apt:
|
||||
name: acl
|
||||
when: ansible_distribution in ('Ubuntu')
|
||||
register: setup_acl
|
||||
|
||||
- name: Create file
|
||||
copy:
|
||||
content: "TEST"
|
||||
mode: 0644
|
||||
dest: "~/test.txt"
|
||||
|
||||
- shell: setfacl -m nobody:rwx ~/test.txt
|
||||
|
||||
- shell: getfacl ~/test.txt
|
||||
register: acls
|
||||
|
||||
- name: Check that permissions match with the copy mode and setfacl command
|
||||
assert:
|
||||
that:
|
||||
- "'user::rw-' in acls.stdout_lines"
|
||||
- "'user:nobody:rwx' in acls.stdout_lines"
|
||||
- "'group::r--' in acls.stdout_lines"
|
||||
- "'other::r--' in acls.stdout_lines"
|
||||
|
||||
- name: test atomic_move via lineinfile doesn't delete extended acls
|
||||
lineinfile:
|
||||
path: "~/test.txt"
|
||||
regexp: "TEST"
|
||||
line: "UPDATE"
|
||||
|
||||
- shell: getfacl ~/test.txt
|
||||
register: acls
|
||||
|
||||
- name: Validate the acls are unmodified
|
||||
assert:
|
||||
that:
|
||||
- "'user::rw-' in acls.stdout_lines"
|
||||
- "'user:nobody:rwx' in acls.stdout_lines"
|
||||
- "'group::r--' in acls.stdout_lines"
|
||||
- "'other::r--' in acls.stdout_lines"
|
||||
|
||||
always:
|
||||
- name: Remove the acl package on Ubuntu
|
||||
apt:
|
||||
name: acl
|
||||
state: absent
|
||||
when: setup_acl is changed
|
||||
|
||||
- name: Clean up
|
||||
file:
|
||||
path: "~/test.txt"
|
||||
state: absent
|
Loading…
Reference in New Issue