From aab681bc2baeae580bacd47edd214830b6b87181 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 15 Apr 2015 05:09:09 -0700 Subject: [PATCH] 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 --- lib/ansible/modules/core | 2 +- lib/ansible/modules/extras | 2 +- .../roles/test_unarchive/tasks/main.yml | 93 ++++++++++++++++++- 3 files changed, 91 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/core b/lib/ansible/modules/core index 74e69d1fd1..761fc8d277 160000 --- a/lib/ansible/modules/core +++ b/lib/ansible/modules/core @@ -1 +1 @@ -Subproject commit 74e69d1fd16957ff84408eac0d28a0c8ef78225c +Subproject commit 761fc8d277e64e0d63eb2cff8c72c3fa3ec70dd2 diff --git a/lib/ansible/modules/extras b/lib/ansible/modules/extras index 4048de9c1e..df7fcc90d9 160000 --- a/lib/ansible/modules/extras +++ b/lib/ansible/modules/extras @@ -1 +1 @@ -Subproject commit 4048de9c1e2333aa7880b61f34af8cbdce5cbcec +Subproject commit df7fcc90d9a17956ec156066e8fc31e5ed8106e6 diff --git a/test/integration/roles/test_unarchive/tasks/main.yml b/test/integration/roles/test_unarchive/tasks/main.yml index fa5891396c..edcee064a9 100644 --- a/test/integration/roles/test_unarchive/tasks/main.yml +++ b/test/integration/roles/test_unarchive/tasks/main.yml @@ -32,11 +32,20 @@ shell: tar cvf test-unarchive.tar foo-unarchive.txt chdir={{output_dir}} - 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 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 file: path={{output_dir}}/test-unarchive-tar state=directory @@ -161,7 +170,7 @@ - name: create our unarchive destination file: path={{output_dir}}/test-unarchive-tar-gz state=directory -- name: unarchive and set mode +- name: unarchive and set mode to 0600 unarchive: src: "{{ output_dir }}/test-unarchive.tar.gz" dest: "{{ output_dir | expanduser }}/test-unarchive-tar-gz" @@ -180,12 +189,39 @@ - "unarchive06.changed == true" - "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: src: "{{ output_dir }}/test-unarchive.tar.gz" dest: "{{ output_dir | expanduser }}/test-unarchive-tar-gz" 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 - name: Test that the files were not changed @@ -196,6 +232,11 @@ - 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: create a directory with quotable chars file: path="{{ output_dir }}/test-quotes~root" state=directory @@ -225,3 +266,47 @@ - name: remove quotable chars test 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