| 1 |
- name: create our unarchive destination |
| 2 |
file: |
| 3 |
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz' |
| 4 |
state: directory |
| 5 |
|
| 6 |
- name: test invalid modes |
| 7 |
unarchive: |
| 8 |
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz" |
| 9 |
dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 10 |
remote_src: yes |
| 11 |
mode: "{{ item }}" |
| 12 |
list_files: True |
| 13 |
register: unarchive_mode_errors |
| 14 |
ignore_errors: yes |
| 15 |
loop: |
| 16 |
- u=foo |
| 17 |
- foo=r |
| 18 |
- ufoo=r |
| 19 |
- abc=r |
| 20 |
- ao=r |
| 21 |
- oa=r |
| 22 |
|
| 23 |
- assert: |
| 24 |
that: |
| 25 |
- item.failed |
| 26 |
- "'bad symbolic permission for mode: ' + item.item == item.details" |
| 27 |
loop: "{{ unarchive_mode_errors.results }}" |
| 28 |
|
| 29 |
- name: unarchive and set mode to 0600, directories 0700 |
| 30 |
unarchive: |
| 31 |
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz" |
| 32 |
dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 33 |
remote_src: yes |
| 34 |
mode: "u+rwX,g-rwx,o-rwx" |
| 35 |
list_files: True |
| 36 |
register: unarchive06 |
| 37 |
|
| 38 |
- name: Test that the file modes were changed |
| 39 |
stat: |
| 40 |
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt" |
| 41 |
register: unarchive06_stat |
| 42 |
|
| 43 |
- name: Test that the file modes were changed |
| 44 |
assert: |
| 45 |
that: |
| 46 |
- "unarchive06.changed == true" |
| 47 |
- "unarchive06_stat.stat.mode == '0600'" |
| 48 |
# Verify that file list is generated |
| 49 |
- "'files' in unarchive06" |
| 50 |
- unarchive06['files']| length == 1 |
| 51 |
- "'foo-unarchive.txt' in unarchive06['files']" |
| 52 |
|
| 53 |
- name: remove our tar.gz unarchive destination |
| 54 |
file: |
| 55 |
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz' |
| 56 |
state: absent |
| 57 |
|
| 58 |
- name: create our unarchive destination |
| 59 |
file: |
| 60 |
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz' |
| 61 |
state: directory |
| 62 |
|
| 63 |
- name: unarchive over existing extraction and set mode to 0644 |
| 64 |
unarchive: |
| 65 |
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz" |
| 66 |
dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 67 |
remote_src: yes |
| 68 |
mode: "u+rwX,g-wx,o-wx,g+r,o+r" |
| 69 |
register: unarchive06_2 |
| 70 |
|
| 71 |
- name: Test that the file modes were changed |
| 72 |
stat: |
| 73 |
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt" |
| 74 |
register: unarchive06_2_stat |
| 75 |
|
| 76 |
- debug: |
| 77 |
var: unarchive06_2_stat.stat.mode |
| 78 |
|
| 79 |
- name: Test that the files were changed |
| 80 |
assert: |
| 81 |
that: |
| 82 |
- "unarchive06_2.changed == true" |
| 83 |
- "unarchive06_2_stat.stat.mode == '0644'" |
| 84 |
|
| 85 |
- name: Repeat the last request to verify no changes |
| 86 |
unarchive: |
| 87 |
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz" |
| 88 |
dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 89 |
remote_src: yes |
| 90 |
mode: "u+rwX-x,g-wx,o-wx,g+r,o+r" |
| 91 |
list_files: True |
| 92 |
register: unarchive07 |
| 93 |
|
| 94 |
- name: Test that the files were not changed |
| 95 |
assert: |
| 96 |
that: |
| 97 |
- "unarchive07.changed == false" |
| 98 |
# Verify that file list is generated |
| 99 |
- "'files' in unarchive07" |
| 100 |
- unarchive07['files']| length == 1 |
| 101 |
- "'foo-unarchive.txt' in unarchive07['files']" |
| 102 |
|
| 103 |
- name: remove our tar.gz unarchive destination |
| 104 |
file: |
| 105 |
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz' |
| 106 |
state: absent |
| 107 |
|
| 108 |
- name: create our unarchive destination |
| 109 |
file: |
| 110 |
path: '{{remote_tmp_dir}}/test-unarchive-zip' |
| 111 |
state: directory |
| 112 |
|
| 113 |
- name: unarchive and set mode to 0601, directories 0700 |
| 114 |
unarchive: |
| 115 |
src: "{{ remote_tmp_dir }}/test-unarchive.zip" |
| 116 |
dest: "{{ remote_tmp_dir }}/test-unarchive-zip" |
| 117 |
remote_src: yes |
| 118 |
mode: "u+rwX-x,g-rwx,o=x" |
| 119 |
list_files: True |
| 120 |
register: unarchive08 |
| 121 |
|
| 122 |
- name: Test that the file modes were changed |
| 123 |
stat: |
| 124 |
path: "{{ remote_tmp_dir }}/test-unarchive-zip/foo-unarchive.txt" |
| 125 |
register: unarchive08_stat |
| 126 |
|
| 127 |
- name: Test that the file modes were changed |
| 128 |
assert: |
| 129 |
that: |
| 130 |
- "unarchive08.changed == true" |
| 131 |
- "unarchive08_stat.stat.mode == '0601'" |
| 132 |
# Verify that file list is generated |
| 133 |
- "'files' in unarchive08" |
| 134 |
- unarchive08['files']| length == 3 |
| 135 |
- "'foo-unarchive.txt' in unarchive08['files']" |
| 136 |
- "'foo-unarchive-777.txt' in unarchive08['files']" |
| 137 |
- "'FOO-UNAR.TXT' in unarchive08['files']" |
| 138 |
|
| 139 |
- name: unarchive zipfile a second time and set mode to 0601, directories 0700 |
| 140 |
unarchive: |
| 141 |
src: "{{ remote_tmp_dir }}/test-unarchive.zip" |
| 142 |
dest: "{{ remote_tmp_dir }}/test-unarchive-zip" |
| 143 |
remote_src: yes |
| 144 |
mode: "u+rwX-x,g-rwx,o=x" |
| 145 |
list_files: True |
| 146 |
register: unarchive08 |
| 147 |
|
| 148 |
- name: Test that the file modes were not changed |
| 149 |
stat: |
| 150 |
path: "{{ remote_tmp_dir }}/test-unarchive-zip/foo-unarchive.txt" |
| 151 |
register: unarchive08_stat |
| 152 |
|
| 153 |
- debug: |
| 154 |
var: unarchive08 |
| 155 |
|
| 156 |
- debug: |
| 157 |
var: unarchive08_stat |
| 158 |
|
| 159 |
- name: Test that the files did not change |
| 160 |
assert: |
| 161 |
that: |
| 162 |
- "unarchive08.changed == false" |
| 163 |
- "unarchive08_stat.stat.mode == '0601'" |
| 164 |
# Verify that file list is generated |
| 165 |
- "'files' in unarchive08" |
| 166 |
- unarchive08['files']| length == 3 |
| 167 |
- "'foo-unarchive.txt' in unarchive08['files']" |
| 168 |
- "'foo-unarchive-777.txt' in unarchive08['files']" |
| 169 |
- "'FOO-UNAR.TXT' in unarchive08['files']" |
| 170 |
|
| 171 |
- name: remove our zip unarchive destination |
| 172 |
file: |
| 173 |
path: '{{ remote_tmp_dir }}/test-unarchive-zip' |
| 174 |
state: absent |