| 1 |
- block: |
| 2 |
- name: Create a group to chown to |
| 3 |
group: |
| 4 |
name: testgroup |
| 5 |
register: testgroup |
| 6 |
|
| 7 |
- name: Create a user to chown to |
| 8 |
user: |
| 9 |
name: testuser |
| 10 |
groups: |
| 11 |
- testgroup |
| 12 |
register: testuser |
| 13 |
|
| 14 |
- set_fact: |
| 15 |
outdir: '{{remote_tmp_dir}}/test-unarchive-{{ ext | replace(".", "_") }}' |
| 16 |
|
| 17 |
- debug: |
| 18 |
msg: Username test |
| 19 |
|
| 20 |
# username |
| 21 |
- name: create our unarchive destinations |
| 22 |
file: |
| 23 |
path: '{{outdir}}' |
| 24 |
state: directory |
| 25 |
|
| 26 |
- name: unarchive a file |
| 27 |
unarchive: |
| 28 |
src: '{{remote_tmp_dir}}/{{archive}}' |
| 29 |
dest: '{{outdir}}' |
| 30 |
list_files: True |
| 31 |
remote_src: yes |
| 32 |
owner: testuser |
| 33 |
|
| 34 |
- name: stat an output file |
| 35 |
stat: |
| 36 |
path: '{{outdir}}/{{testfile}}' |
| 37 |
register: stat |
| 38 |
|
| 39 |
- name: verify that the file has the right owner |
| 40 |
assert: |
| 41 |
that: |
| 42 |
- stat.stat.exists |
| 43 |
- stat.stat.pw_name == testuser.name |
| 44 |
- stat.stat.uid == testuser.uid |
| 45 |
|
| 46 |
- name: nuke destination |
| 47 |
file: |
| 48 |
path: '{{outdir}}' |
| 49 |
state: absent |
| 50 |
|
| 51 |
- debug: |
| 52 |
msg: uid test |
| 53 |
|
| 54 |
# uid |
| 55 |
- name: create our unarchive destinations |
| 56 |
file: |
| 57 |
path: '{{outdir}}' |
| 58 |
state: directory |
| 59 |
|
| 60 |
- name: unarchive a file |
| 61 |
unarchive: |
| 62 |
src: '{{remote_tmp_dir}}/{{archive}}' |
| 63 |
dest: '{{outdir}}' |
| 64 |
list_files: True |
| 65 |
remote_src: yes |
| 66 |
owner: '{{ testuser.uid }}' |
| 67 |
|
| 68 |
- name: stat an output file |
| 69 |
stat: |
| 70 |
path: '{{outdir}}/{{testfile}}' |
| 71 |
register: stat |
| 72 |
|
| 73 |
- name: verify that the file has the right owner |
| 74 |
assert: |
| 75 |
that: |
| 76 |
- stat.stat.exists |
| 77 |
- stat.stat.pw_name == testuser.name |
| 78 |
- stat.stat.uid == testuser.uid |
| 79 |
|
| 80 |
- name: nuke destination |
| 81 |
file: |
| 82 |
path: '{{outdir}}' |
| 83 |
state: absent |
| 84 |
|
| 85 |
- debug: |
| 86 |
msg: groupname test |
| 87 |
|
| 88 |
# groupname |
| 89 |
- name: create our unarchive destinations |
| 90 |
file: |
| 91 |
path: '{{outdir}}' |
| 92 |
state: directory |
| 93 |
|
| 94 |
- name: unarchive a file |
| 95 |
unarchive: |
| 96 |
src: '{{remote_tmp_dir}}/{{archive}}' |
| 97 |
dest: '{{outdir}}' |
| 98 |
list_files: True |
| 99 |
remote_src: yes |
| 100 |
group: testgroup |
| 101 |
|
| 102 |
- name: stat an output file |
| 103 |
stat: |
| 104 |
path: '{{outdir}}/{{testfile}}' |
| 105 |
register: stat |
| 106 |
|
| 107 |
- name: verify that the file has the right owner |
| 108 |
assert: |
| 109 |
that: |
| 110 |
- stat.stat.exists |
| 111 |
- stat.stat.gr_name == testgroup.name |
| 112 |
- stat.stat.gid == testgroup.gid |
| 113 |
|
| 114 |
- name: nuke destination |
| 115 |
file: |
| 116 |
path: '{{outdir}}' |
| 117 |
state: absent |
| 118 |
|
| 119 |
- debug: |
| 120 |
msg: gid test |
| 121 |
|
| 122 |
# gid |
| 123 |
- name: create our unarchive destinations |
| 124 |
file: |
| 125 |
path: '{{outdir}}' |
| 126 |
state: directory |
| 127 |
|
| 128 |
- name: unarchive a file |
| 129 |
unarchive: |
| 130 |
src: '{{remote_tmp_dir}}/{{archive}}' |
| 131 |
dest: '{{outdir}}' |
| 132 |
list_files: True |
| 133 |
remote_src: yes |
| 134 |
group: '{{ testgroup.gid }}' |
| 135 |
|
| 136 |
- name: stat an output file |
| 137 |
stat: |
| 138 |
path: '{{outdir}}/{{testfile}}' |
| 139 |
register: stat |
| 140 |
|
| 141 |
- name: verify that the file has the right owner |
| 142 |
assert: |
| 143 |
that: |
| 144 |
- stat.stat.exists |
| 145 |
- stat.stat.gr_name == testgroup.name |
| 146 |
- stat.stat.gid == testgroup.gid |
| 147 |
|
| 148 |
- name: nuke destination |
| 149 |
file: |
| 150 |
path: '{{outdir}}' |
| 151 |
state: absent |
| 152 |
|
| 153 |
always: |
| 154 |
- name: Remove testuser |
| 155 |
user: |
| 156 |
name: testuser |
| 157 |
state: absent |
| 158 |
remove: yes |
| 159 |
force: yes |
| 160 |
|
| 161 |
- name: Remove testgroup |
| 162 |
group: |
| 163 |
name: testgroup |
| 164 |
state: absent |