Unify yaml style in unarchive tests to be dict-style (refs #68272) (#68477)

Signed-off-by: Rick Elrod <rick@elrod.me>
pull/68504/head
Rick Elrod 6 years ago committed by GitHub
parent cfc9b4a1e2
commit 2af76f16be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,7 +26,9 @@
when: ansible_pkg_mgr in ('yum', 'dnf', 'apt', 'pkgng') when: ansible_pkg_mgr in ('yum', 'dnf', 'apt', 'pkgng')
- name: prep our file - name: prep our file
copy: src=foo.txt dest={{remote_tmp_dir}}/foo-unarchive.txt copy:
src: foo.txt
dest: "{{remote_tmp_dir}}/foo-unarchive.txt"
- name: prep a tar file - name: prep a tar file
shell: tar cvf test-unarchive.tar foo-unarchive.txt chdir={{remote_tmp_dir}} shell: tar cvf test-unarchive.tar foo-unarchive.txt chdir={{remote_tmp_dir}}
@ -35,10 +37,15 @@
shell: tar czvf test-unarchive.tar.gz foo-unarchive.txt chdir={{remote_tmp_dir}} shell: tar czvf test-unarchive.tar.gz foo-unarchive.txt chdir={{remote_tmp_dir}}
- name: prep a chmodded file for zip - name: prep a chmodded file for zip
copy: src=foo.txt dest={{remote_tmp_dir}}/foo-unarchive-777.txt mode=0777 copy:
src: foo.txt
dest: '{{remote_tmp_dir}}/foo-unarchive-777.txt'
mode: '0777'
- name: prep a windows permission file for our zip - name: prep a windows permission file for our zip
copy: src=foo.txt dest={{remote_tmp_dir}}/FOO-UNAR.TXT copy:
src: foo.txt
dest: '{{remote_tmp_dir}}/FOO-UNAR.TXT'
# This gets around an unzip timestamp bug in some distributions # This gets around an unzip timestamp bug in some distributions
# Recent unzip on Ubuntu and BSD will randomly round some timestamps up. # Recent unzip on Ubuntu and BSD will randomly round some timestamps up.
@ -88,19 +95,28 @@
shell: zip -k test-unarchive.zip FOO-UNAR.TXT chdir={{remote_tmp_dir}} shell: zip -k test-unarchive.zip FOO-UNAR.TXT chdir={{remote_tmp_dir}}
- name: prep a subdirectory - name: prep a subdirectory
file: path={{remote_tmp_dir}}/unarchive-dir state=directory file:
path: '{{remote_tmp_dir}}/unarchive-dir'
state: directory
- name: prep our file - name: prep our file
copy: src=foo.txt dest={{remote_tmp_dir}}/unarchive-dir/foo-unarchive.txt copy:
src: foo.txt
dest: '{{remote_tmp_dir}}/unarchive-dir/foo-unarchive.txt'
- name: prep a tar.gz file with directory - name: prep a tar.gz file with directory
shell: tar czvf test-unarchive-dir.tar.gz unarchive-dir chdir={{remote_tmp_dir}} shell: tar czvf test-unarchive-dir.tar.gz unarchive-dir chdir={{remote_tmp_dir}}
- name: create our tar unarchive destination - name: create our tar unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar'
state: directory
- name: unarchive a tar file - name: unarchive a tar file
unarchive: src={{remote_tmp_dir}}/test-unarchive.tar dest="{{remote_tmp_dir}}/test-unarchive-tar" remote_src=yes unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.tar'
dest: '{{remote_tmp_dir}}/test-unarchive-tar'
remote_src: yes
register: unarchive01 register: unarchive01
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
@ -109,16 +125,25 @@
- "unarchive01.changed == true" - "unarchive01.changed == true"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path={{remote_tmp_dir}}/test-unarchive-tar/foo-unarchive.txt state=file file:
path: '{{remote_tmp_dir}}/test-unarchive-tar/foo-unarchive.txt'
state: file
- name: remove our tar unarchive destination - name: remove our tar unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar state=absent file:
path: '{{remote_tmp_dir}}/test-unarchive-tar'
state: absent
- name: create our tar.gz unarchive destination - name: create our tar.gz unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: directory
- name: unarchive a tar.gz file - name: unarchive a tar.gz file
unarchive: src={{remote_tmp_dir}}/test-unarchive.tar.gz dest={{remote_tmp_dir}}/test-unarchive-tar-gz remote_src=yes unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.tar.gz'
dest: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
remote_src: yes
register: unarchive02 register: unarchive02
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
@ -129,16 +154,26 @@
- "'files' not in unarchive02" - "'files' not in unarchive02"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt state=file file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt'
state: file
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=absent file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: absent
- name: create our tar.gz unarchive destination for creates - name: create our tar.gz unarchive destination for creates
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: directory
- name: unarchive a tar.gz file with creates set - name: unarchive a tar.gz file with creates set
unarchive: src={{remote_tmp_dir}}/test-unarchive.tar.gz dest={{remote_tmp_dir}}/test-unarchive-tar-gz remote_src=yes creates={{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.tar.gz'
dest: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
creates: '{{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt'
remote_src: yes
register: unarchive02b register: unarchive02b
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
@ -147,10 +182,16 @@
- "unarchive02b.changed == true" - "unarchive02b.changed == true"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt state=file file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt'
state: file
- name: unarchive a tar.gz file with creates over an existing file - name: unarchive a tar.gz file with creates over an existing file
unarchive: src={{remote_tmp_dir}}/test-unarchive.tar.gz dest={{remote_tmp_dir}}/test-unarchive-tar-gz remote_src=yes creates={{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.tar.gz'
dest: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
creates: '{{remote_tmp_dir}}/test-unarchive-tar-gz/foo-unarchive.txt'
remote_src: yes
register: unarchive02c register: unarchive02c
- name: verify that the file was not marked as changed - name: verify that the file was not marked as changed
@ -172,7 +213,9 @@
- "unarchive02d.changed == false" - "unarchive02d.changed == false"
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=absent file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: absent
- block: - block:
- name: Create a group to chown to - name: Create a group to chown to
@ -283,10 +326,16 @@
# Zip # Zip
- name: create our zip unarchive destination - name: create our zip unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-zip state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-zip'
state: directory
- name: unarchive a zip file - name: unarchive a zip file
unarchive: src={{remote_tmp_dir}}/test-unarchive.zip dest={{remote_tmp_dir}}/test-unarchive-zip remote_src=yes list_files=True unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.zip'
dest: '{{remote_tmp_dir}}/test-unarchive-zip'
list_files: True
remote_src: yes
register: unarchive03 register: unarchive03
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
@ -301,14 +350,20 @@
- "'FOO-UNAR.TXT' in unarchive03['files']" - "'FOO-UNAR.TXT' in unarchive03['files']"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path={{remote_tmp_dir}}/test-unarchive-zip/{{item}} state=file file:
path: '{{remote_tmp_dir}}/test-unarchive-zip/{{item}}'
state: file
with_items: with_items:
- foo-unarchive.txt - foo-unarchive.txt
- foo-unarchive-777.txt - foo-unarchive-777.txt
- FOO-UNAR.TXT - FOO-UNAR.TXT
- name: repeat the last request to verify no changes - name: repeat the last request to verify no changes
unarchive: src={{remote_tmp_dir}}/test-unarchive.zip dest={{remote_tmp_dir}}/test-unarchive-zip remote_src=yes list_files=True unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.zip'
dest: '{{remote_tmp_dir}}/test-unarchive-zip'
list_files: true
remote_src: true
register: unarchive03b register: unarchive03b
- name: verify that the task was not marked as changed - name: verify that the task was not marked as changed
@ -352,26 +407,35 @@
- "{{ unarchive00.results }}" - "{{ unarchive00.results }}"
- name: remove our zip unarchive destination - name: remove our zip unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-zip state=absent file:
path: '{{remote_tmp_dir}}/test-unarchive-zip'
state: absent
- name: remove our test files for the archive - name: remove our test files for the archive
file: path={{remote_tmp_dir}}/{{item}} state=absent file:
path: '{{remote_tmp_dir}}/{{item}}'
state: absent
with_items: with_items:
- foo-unarchive.txt - foo-unarchive.txt
- foo-unarchive-777.txt - foo-unarchive-777.txt
- FOO-UNAR.TXT - FOO-UNAR.TXT
- name: check if /tmp/foo-unarchive.text exists - name: check if /tmp/foo-unarchive.text exists
stat: path=/tmp/foo-unarchive.txt stat:
path: /tmp/foo-unarchive.txt
ignore_errors: True ignore_errors: True
register: unarchive04 register: unarchive04
- name: fail if the proposed destination file exists for safey - name: fail if the proposed destination file exists for safey
fail: msg="/tmp/foo-unarchive.txt already exists, aborting" fail:
msg: /tmp/foo-unarchive.txt already exists, aborting
when: unarchive04.stat.exists when: unarchive04.stat.exists
- name: try unarchiving to /tmp - name: try unarchiving to /tmp
unarchive: src={{remote_tmp_dir}}/test-unarchive.tar.gz dest=/tmp remote_src=yes unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.tar.gz'
dest: /tmp
remote_src: true
register: unarchive05 register: unarchive05
- name: verify that the file was marked as changed - name: verify that the file was marked as changed
@ -380,13 +444,19 @@
- "unarchive05.changed == true" - "unarchive05.changed == true"
- name: verify that the file was unarchived - name: verify that the file was unarchived
file: path=/tmp/foo-unarchive.txt state=file file:
path: /tmp/foo-unarchive.txt
state: file
- name: remove our unarchive destination - name: remove our unarchive destination
file: path=/tmp/foo-unarchive.txt state=absent file:
path: /tmp/foo-unarchive.txt
state: absent
- name: create our unarchive destination - name: create our unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: directory
- name: unarchive and set mode to 0600, directories 0700 - name: unarchive and set mode to 0600, directories 0700
unarchive: unarchive:
@ -413,10 +483,14 @@
- "'foo-unarchive.txt' in unarchive06['files']" - "'foo-unarchive.txt' in unarchive06['files']"
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{ remote_tmp_dir }}/test-unarchive-tar-gz state=absent file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent
- name: create our unarchive destination - name: create our unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: directory
- name: unarchive over existing extraction and set mode to 0644 - name: unarchive over existing extraction and set mode to 0644
unarchive: unarchive:
@ -431,7 +505,9 @@
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt" path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt"
register: unarchive06_2_stat register: unarchive06_2_stat
- debug: var=unarchive06_2_stat.stat.mode - debug:
var: unarchive06_2_stat.stat.mode
- name: Test that the files were changed - name: Test that the files were changed
assert: assert:
that: that:
@ -457,10 +533,14 @@
- "'foo-unarchive.txt' in unarchive07['files']" - "'foo-unarchive.txt' in unarchive07['files']"
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{ remote_tmp_dir }}/test-unarchive-tar-gz state=absent file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent
- name: create our unarchive destination - name: create our unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-zip state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-zip'
state: directory
- name: unarchive and set mode to 0601, directories 0700 - name: unarchive and set mode to 0601, directories 0700
unarchive: unarchive:
@ -521,13 +601,19 @@
- "'FOO-UNAR.TXT' in unarchive08['files']" - "'FOO-UNAR.TXT' in unarchive08['files']"
- name: remove our zip unarchive destination - name: remove our zip unarchive destination
file: path={{ remote_tmp_dir }}/test-unarchive-zip state=absent file:
path: '{{ remote_tmp_dir }}/test-unarchive-zip'
state: absent
- name: create our unarchive destination - name: create our unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: directory
- name: create a directory with quotable chars - name: create a directory with quotable chars
file: path="{{ remote_tmp_dir }}/test-quotes~root" state=directory file:
path: '{{ remote_tmp_dir }}/test-quotes~root'
state: directory
- name: unarchive into directory with quotable chars - name: unarchive into directory with quotable chars
unarchive: unarchive:
@ -554,7 +640,9 @@
- "unarchive09.changed == false" - "unarchive09.changed == false"
- name: remove quotable chars test - name: remove quotable chars test
file: path="{{ remote_tmp_dir }}/test-quotes~root" state=absent file:
path: '{{ remote_tmp_dir }}/test-quotes~root'
state: absent
- name: create our unarchive destination - name: create our unarchive destination
file: file:
@ -583,7 +671,9 @@
- "nonascii_stat0.stat.exists == true" - "nonascii_stat0.stat.exists == true"
- name: remove nonascii test - name: remove nonascii test
file: path="{{ remote_tmp_dir }}/test-unarchive-nonascii-くらとみ-tar-gz" state=absent file:
path: "{{ remote_tmp_dir }}/test-unarchive-nonascii-くらとみ-tar-gz"
state: absent
- name: test non-ascii with different LC_ALL - name: test non-ascii with different LC_ALL
block: block:
@ -614,7 +704,9 @@
- "nonascii_stat0.stat.exists == true" - "nonascii_stat0.stat.exists == true"
- name: remove nonascii test - name: remove nonascii test
file: path="{{ remote_tmp_dir }}/test-unarchive-nonascii-くらとみ-tar-gz" state=absent file:
path: "{{ remote_tmp_dir }}/test-unarchive-nonascii-くらとみ-tar-gz"
state: absent
environment: environment:
LC_ALL: C LC_ALL: C
@ -622,7 +714,9 @@
# Test that unarchiving is performed if files are missing # Test that unarchiving is performed if files are missing
# https://github.com/ansible/ansible-modules-core/issues/1064 # https://github.com/ansible/ansible-modules-core/issues/1064
- name: create our unarchive destination - name: create our unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: directory
- name: unarchive a tar that has directories - name: unarchive a tar that has directories
unarchive: unarchive:
@ -640,7 +734,7 @@
- name: Change the mode of the toplevel dir - name: Change the mode of the toplevel dir
file: file:
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/unarchive-dir" path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/unarchive-dir"
mode: 0701 mode: "0701"
- name: Remove a file from the extraction point - name: Remove a file from the extraction point
file: file:
@ -661,7 +755,9 @@
- "unarchive10_1.changed == true" - "unarchive10_1.changed == true"
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{ remote_tmp_dir }}/test-unarchive-tar-gz state=absent file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent
# #
# Symlink tests # Symlink tests
@ -698,7 +794,9 @@
- "unarchive11_stat0.stat.exists == true" - "unarchive11_stat0.stat.exists == true"
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{ remote_tmp_dir }}/test-unarchive-tar-gz state=absent file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent
- name: Create a file - name: Create a file
file: file:
@ -707,8 +805,8 @@
- name: Create a symlink to the file - name: Create a symlink to the file
file: file:
path: "{{ remote_tmp_dir }}/link-to-unarchive-file"
src: "{{ remote_tmp_dir }}/test-unarchive-tar-gz" src: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
path: "{{ remote_tmp_dir }}/link-to-unarchive-file"
state: "link" state: "link"
- name: test that unarchive fails when dest is a link to a file - name: test that unarchive fails when dest is a link to a file
@ -726,11 +824,15 @@
- "unarchive_12.failed == true" - "unarchive_12.failed == true"
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{ remote_tmp_dir }}/test-unarchive-tar-gz state=absent file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent
# Test downloading a file before unarchiving it # Test downloading a file before unarchiving it
- name: create our unarchive destination - name: create our unarchive destination
file: path={{remote_tmp_dir}}/test-unarchive-tar-gz state=directory file:
path: '{{remote_tmp_dir}}/test-unarchive-tar-gz'
state: directory
- name: Install packages to make TLS connections work on CentOS 6 - name: Install packages to make TLS connections work on CentOS 6
pip: pip:
@ -757,4 +859,6 @@
- "unarchive13.changed == true" - "unarchive13.changed == true"
- name: remove our tar.gz unarchive destination - name: remove our tar.gz unarchive destination
file: path={{ remote_tmp_dir }}/test-unarchive-tar-gz state=absent file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent

Loading…
Cancel
Save