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:
Toshio Kuratomi
2018-04-26 07:14:37 -07:00
committed by GitHub
parent 33f358383a
commit 83c1cba511
9 changed files with 104 additions and 11 deletions

View File

@@ -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