mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Fixes for mode=preserve (#39343)
* Fixes for mode=preserve * Document mode=preserve for template and copy * Make mode=preserve work with remote_src for copy * Make mode=preserve work for template * Integration tests for copy & template mode=preserve Fixes #39279 * Changed mode option in win_copy to hidden option as it doesn't reflect copy mode
This commit is contained in:
@@ -574,5 +574,32 @@
|
||||
- 'diff_result.stdout == ""'
|
||||
- "diff_result.rc == 0"
|
||||
|
||||
# Check that mode=preserve works with template
|
||||
- name: Create a template which has strange permissions
|
||||
copy:
|
||||
content: !unsafe '{{ ansible_managed }}\n'
|
||||
dest: '{{ output_dir }}/foo-template.j2'
|
||||
mode: 0547
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Use template with mode=preserve
|
||||
template:
|
||||
src: '{{ output_dir }}/foo-template.j2'
|
||||
dest: '{{ output_dir }}/foo-templated.txt'
|
||||
mode: 'preserve'
|
||||
register: template_results
|
||||
|
||||
- name: Get permissions from the templated file
|
||||
stat:
|
||||
path: '{{ output_dir }}/foo-templated.txt'
|
||||
register: stat_results
|
||||
|
||||
- name: Check that the resulting file has the correct permissions
|
||||
assert:
|
||||
that:
|
||||
- 'template_results is changed'
|
||||
- 'template_results.mode == "0547"'
|
||||
- 'stat_results.stat["mode"] == "0547"'
|
||||
|
||||
# aliases file requires root for template tests so this should be safe
|
||||
- include: backup_test.yml
|
||||
|
||||
Reference in New Issue
Block a user