| 1 |
- name: Create a destination dir |
| 2 |
file: |
| 3 |
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 4 |
state: directory |
| 5 |
|
| 6 |
- name: Create a symlink to the destination dir |
| 7 |
file: |
| 8 |
path: "{{ remote_tmp_dir }}/link-to-unarchive-dir" |
| 9 |
src: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 10 |
state: "link" |
| 11 |
|
| 12 |
- name: test that unarchive works when dest is a symlink to a dir |
| 13 |
unarchive: |
| 14 |
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz" |
| 15 |
dest: "{{ remote_tmp_dir }}/link-to-unarchive-dir" |
| 16 |
mode: "u+rwX,go+rX" |
| 17 |
remote_src: yes |
| 18 |
register: unarchive_11 |
| 19 |
|
| 20 |
- name: Check that file is really there |
| 21 |
stat: |
| 22 |
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt" |
| 23 |
register: unarchive11_stat0 |
| 24 |
|
| 25 |
- name: Assert that unarchive when dest is a symlink to a dir worked |
| 26 |
assert: |
| 27 |
that: |
| 28 |
- "unarchive_11.changed == true" |
| 29 |
- "unarchive11_stat0.stat.exists == true" |
| 30 |
|
| 31 |
- name: remove our tar.gz unarchive destination |
| 32 |
file: |
| 33 |
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz' |
| 34 |
state: absent |
| 35 |
|
| 36 |
- name: Create a file |
| 37 |
file: |
| 38 |
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 39 |
state: touch |
| 40 |
|
| 41 |
- name: Create a symlink to the file |
| 42 |
file: |
| 43 |
src: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" |
| 44 |
path: "{{ remote_tmp_dir }}/link-to-unarchive-file" |
| 45 |
state: "link" |
| 46 |
|
| 47 |
- name: test that unarchive fails when dest is a link to a file |
| 48 |
unarchive: |
| 49 |
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz" |
| 50 |
dest: "{{ remote_tmp_dir }}/link-to-unarchive-file" |
| 51 |
mode: "u+rwX,go+rX" |
| 52 |
remote_src: yes |
| 53 |
ignore_errors: True |
| 54 |
register: unarchive_12 |
| 55 |
|
| 56 |
- name: Assert that unarchive when dest is a file failed |
| 57 |
assert: |
| 58 |
that: |
| 59 |
- "unarchive_12.failed == true" |
| 60 |
|
| 61 |
- name: remove our tar.gz unarchive destination |
| 62 |
file: |
| 63 |
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz' |
| 64 |
state: absent |
| 65 |
|
| 66 |
- name: Create a destination dir |
| 67 |
file: |
| 68 |
path: "{{ remote_tmp_dir }}/test-symlink" |
| 69 |
state: directory |
| 70 |
|
| 71 |
- name: Create files |
| 72 |
file: |
| 73 |
path: "{{ remote_tmp_dir }}/test-symlink/{{ item }}" |
| 74 |
state: touch |
| 75 |
loop: |
| 76 |
- file1 |
| 77 |
- file2 |
| 78 |
|
| 79 |
- name: Create a symlink to the file |
| 80 |
file: |
| 81 |
path: "{{ remote_tmp_dir }}/test-symlink/link1" |
| 82 |
src: "{{ remote_tmp_dir }}/test-symlink/file1" |
| 83 |
state: link |
| 84 |
|
| 85 |
- name: Create archive of symlink |
| 86 |
shell: tar czvf {{ remote_tmp_dir }}/link1.tar.gz link1 chdir={{ remote_tmp_dir }}/test-symlink |
| 87 |
|
| 88 |
- name: Change target of symlink |
| 89 |
file: |
| 90 |
path: "{{ remote_tmp_dir }}/test-symlink/link1" |
| 91 |
src: "{{ remote_tmp_dir }}/test-symlink/file2" |
| 92 |
state: link |
| 93 |
|
| 94 |
- name: Unarchive when symlink differs |
| 95 |
unarchive: |
| 96 |
src: "{{ remote_tmp_dir }}/link1.tar.gz" |
| 97 |
dest: "{{ remote_tmp_dir }}/test-symlink" |
| 98 |
remote_src: yes |
| 99 |
register: unarchive_13 |
| 100 |
|
| 101 |
- name: Assert that unarchive was performed |
| 102 |
assert: |
| 103 |
that: |
| 104 |
- unarchive_13.changed == true |
| 105 |
|
| 106 |
- name: Unarchive when symlink is the same |
| 107 |
unarchive: |
| 108 |
src: "{{ remote_tmp_dir }}/link1.tar.gz" |
| 109 |
dest: "{{ remote_tmp_dir }}/test-symlink" |
| 110 |
remote_src: yes |
| 111 |
register: unarchive_13 |
| 112 |
|
| 113 |
- name: Assert that unarchive was not performed |
| 114 |
assert: |
| 115 |
that: |
| 116 |
- "unarchive_13.changed == false" |
| 117 |
|
| 118 |
- name: Remove files |
| 119 |
file: |
| 120 |
path: "{{ remote_tmp_dir }}/test-symlink/{{ item }}" |
| 121 |
state: absent |
| 122 |
with_items: |
| 123 |
- file1 |
| 124 |
- file2 |
| 125 |
- link1 |
| 126 |
- link1.tar.gz |