Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible: avoid roundtrip in copy action due to fixup_perms2().
On top of existing temporary files work, this reduces the number of roundtrips required for "copy" and "template" actions from 6 to 3.
- Loading branch information
Showing
3 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
- import_playbook: remote_file_exists.yml | ||
- import_playbook: remote_expand_user.yml | ||
- import_playbook: fixup_perms2__copy.yml | ||
- import_playbook: low_level_execute_command.yml | ||
- import_playbook: make_tmp_path.yml | ||
- import_playbook: remote_expand_user.yml | ||
- import_playbook: remote_file_exists.yml | ||
- import_playbook: transfer_data.yml |
104 changes: 104 additions & 0 deletions
104
tests/ansible/integration/action/fixup_perms2__copy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Verify action plugins still set file modes correctly even though | ||
# fixup_perms2() avoids setting execute bit despite being asked to. | ||
|
||
- name: integration/action/fixup_perms2__copy.yml | ||
hosts: test-targets | ||
any_errors_fatal: true | ||
tasks: | ||
- name: Get default remote file mode | ||
shell: python -c 'import os; print("%04o" % (int("0666", 8) & ~os.umask(0)))' | ||
register: py_umask | ||
|
||
- name: Set default file mode | ||
set_fact: | ||
mode: "{{py_umask.stdout}}" | ||
|
||
# | ||
# copy module (no mode). | ||
# | ||
|
||
- name: "Copy files (no mode)" | ||
copy: | ||
content: "" | ||
dest: /tmp/copy-no-mode | ||
|
||
- stat: path=/tmp/copy-no-mode | ||
register: out | ||
- assert: | ||
that: | ||
- out.stat.mode == mode | ||
|
||
# | ||
# copy module (explicit mode). | ||
# | ||
|
||
- name: "Copy files from content: arg" | ||
copy: | ||
content: "" | ||
mode: 0400 | ||
dest: /tmp/copy-with-mode | ||
|
||
- stat: path=/tmp/copy-with-mode | ||
register: out | ||
- assert: | ||
that: | ||
- out.stat.mode == "0400" | ||
|
||
# | ||
# copy module (existing disk files, no mode). | ||
# | ||
|
||
- file: | ||
path: /tmp/weird-mode | ||
state: absent | ||
|
||
- name: Create local test file. | ||
connection: local | ||
copy: | ||
content: "weird mode" | ||
dest: "/tmp/weird-mode" | ||
mode: "1462" | ||
|
||
- copy: | ||
src: "/tmp/weird-mode" | ||
dest: "/tmp/weird-mode" | ||
|
||
- stat: | ||
path: "/tmp/weird-mode" | ||
register: out | ||
- assert: | ||
that: | ||
- out.stat.mode == mode | ||
|
||
# | ||
# copy module (existing disk files, preserve mode). | ||
# | ||
|
||
- copy: | ||
src: "/tmp/weird-mode" | ||
dest: "/tmp/weird-mode" | ||
mode: preserve | ||
|
||
- stat: | ||
path: "/tmp/weird-mode" | ||
register: out | ||
- assert: | ||
that: | ||
- out.stat.mode == "1462" | ||
|
||
# | ||
# copy module (existing disk files, explicit mode). | ||
# | ||
|
||
- copy: | ||
src: "/tmp/weird-mode" | ||
dest: "/tmp/weird-mode" | ||
mode: "1461" | ||
|
||
- stat: | ||
path: "/tmp/weird-mode" | ||
register: out | ||
|
||
- assert: | ||
that: | ||
- out.stat.mode == "1461" |