1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Update core and extras module refs and add tests for an unarchive

problem that the update fixes:

https://github.com/ansible/ansible-modules-core/issues/1064
This commit is contained in:
Toshio Kuratomi 2015-04-15 05:09:09 -07:00
parent 02e7385002
commit aab681bc2b
3 changed files with 91 additions and 6 deletions

@ -1 +1 @@
Subproject commit 74e69d1fd16957ff84408eac0d28a0c8ef78225c Subproject commit 761fc8d277e64e0d63eb2cff8c72c3fa3ec70dd2

@ -1 +1 @@
Subproject commit 4048de9c1e2333aa7880b61f34af8cbdce5cbcec Subproject commit df7fcc90d9a17956ec156066e8fc31e5ed8106e6

View file

@ -32,11 +32,20 @@
shell: tar cvf test-unarchive.tar foo-unarchive.txt chdir={{output_dir}} shell: tar cvf test-unarchive.tar foo-unarchive.txt chdir={{output_dir}}
- name: prep a tar.gz file - name: prep a tar.gz file
shell: tar cvf test-unarchive.tar.gz foo-unarchive.txt chdir={{output_dir}} shell: tar czvf test-unarchive.tar.gz foo-unarchive.txt chdir={{output_dir}}
- name: prep a zip file - name: prep a zip file
shell: zip test-unarchive.zip foo-unarchive.txt chdir={{output_dir}} shell: zip test-unarchive.zip foo-unarchive.txt chdir={{output_dir}}
- name: prep a subdirectory
file: path={{output_dir}}/unarchive-dir state=directory
- name: prep our file
copy: src=foo.txt dest={{output_dir}}/unarchive-dir/foo-unarchive.txt
- name: prep a tar.gz file with directory
shell: tar czvf test-unarchive-dir.tar.gz unarchive-dir chdir={{output_dir}}
- name: create our tar unarchive destination - name: create our tar unarchive destination
file: path={{output_dir}}/test-unarchive-tar state=directory file: path={{output_dir}}/test-unarchive-tar state=directory
@ -161,7 +170,7 @@
- name: create our unarchive destination - name: create our unarchive destination
file: path={{output_dir}}/test-unarchive-tar-gz state=directory file: path={{output_dir}}/test-unarchive-tar-gz state=directory
- name: unarchive and set mode - name: unarchive and set mode to 0600
unarchive: unarchive:
src: "{{ output_dir }}/test-unarchive.tar.gz" src: "{{ output_dir }}/test-unarchive.tar.gz"
dest: "{{ output_dir | expanduser }}/test-unarchive-tar-gz" dest: "{{ output_dir | expanduser }}/test-unarchive-tar-gz"
@ -180,12 +189,39 @@
- "unarchive06.changed == true" - "unarchive06.changed == true"
- "unarchive06_stat.stat.mode == '0600'" - "unarchive06_stat.stat.mode == '0600'"
- name: unarchive and set mode - name: remove our tar.gz unarchive destination
file: path={{ output_dir }}/test-unarchive-tar-gz state=absent
- name: create our unarchive destination
file: path={{output_dir}}/test-unarchive-tar-gz state=directory
- name: unarchive over existing extraction and set mode to 0644
unarchive: unarchive:
src: "{{ output_dir }}/test-unarchive.tar.gz" src: "{{ output_dir }}/test-unarchive.tar.gz"
dest: "{{ output_dir | expanduser }}/test-unarchive-tar-gz" dest: "{{ output_dir | expanduser }}/test-unarchive-tar-gz"
copy: no copy: no
mode: "u+rwX,g-rwx,o-rwx" mode: "u+rwX,g-wx,o-wx,g+r,o+r"
register: unarchive06_2
- name: Test that the file modes were changed
stat:
path: "{{ output_dir | expanduser }}/test-unarchive-tar-gz/foo-unarchive.txt"
register: unarchive06_2_stat
- debug: var=unarchive06_2_stat.stat.mode
- name: Test that the files were changed
assert:
that:
- "unarchive06_2.changed == true"
- "unarchive06_2_stat.stat.mode == '0644'"
- name: Repeat the last request to verify no changes
unarchive:
src: "{{ output_dir }}/test-unarchive.tar.gz"
dest: "{{ output_dir | expanduser }}/test-unarchive-tar-gz"
copy: no
mode: "u+rwX,g-wx,o-wx,g+r,o+r"
register: unarchive07 register: unarchive07
- name: Test that the files were not changed - name: Test that the files were not changed
@ -196,6 +232,11 @@
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{ output_dir }}/test-unarchive-tar-gz state=absent file: path={{ output_dir }}/test-unarchive-tar-gz state=absent
- name: create our unarchive destination
file: path={{output_dir}}/test-unarchive-tar-gz state=directory
- name: create a directory with quotable chars - name: create a directory with quotable chars
file: path="{{ output_dir }}/test-quotes~root" state=directory file: path="{{ output_dir }}/test-quotes~root" state=directory
@ -225,3 +266,47 @@
- name: remove quotable chars test - name: remove quotable chars test
file: path="{{ output_dir }}/test-quotes~root" state=absent file: path="{{ output_dir }}/test-quotes~root" state=absent
# Test that unarchiving is performed if files are missing
# https://github.com/ansible/ansible-modules-core/issues/1064
- name: create our unarchive destination
file: path={{output_dir}}/test-unarchive-tar-gz state=directory
- name: unarchive a tar that has directories
unarchive:
src: "{{ output_dir }}/test-unarchive-dir.tar.gz"
dest: "{{ output_dir }}/test-unarchive-tar-gz"
mode: "0700"
copy: no
register: unarchive10
- name: Test that unarchive succeeded
assert:
that:
- "unarchive10.changed == true"
- name: Change the mode of the toplevel dir
file:
path: "{{ output_dir }}/test-unarchive-tar-gz/unarchive-dir"
mode: 0701
- name: Remove a file from the extraction point
file:
path: "{{ output_dir }}/test-unarchive-tar-gz/unarchive-dir/foo-unarchive.txt"
state: absent
- name: unarchive a tar that has directories
unarchive:
src: "{{ output_dir }}/test-unarchive-dir.tar.gz"
dest: "{{ output_dir }}/test-unarchive-tar-gz"
mode: "0700"
copy: no
register: unarchive10_1
- name: Test that unarchive succeeded
assert:
that:
- "unarchive10_1.changed == true"
- name: remove our tar.gz unarchive destination
file: path={{ output_dir }}/test-unarchive-tar-gz state=absent