ansible/test/integration/targets/unarchive/tasks/test_missing_binaries.yml
Sam Doran 004c33d9c5
unarchive - do not fail in init when trying to find required binary (#74892)
Test for the required binaries in the can_handle_archive() method and fail there. This
prevents failures for missing binaries unrelated to the archive type.

* Update missing zip binary message to match tar message
* Update unit tests
* Add integration tests
* Define packages based on the system rather than ignoring failures
2021-06-07 12:59:06 -04:00

56 lines
1.4 KiB
YAML

- name: Test missing binaries
when: ansible_pkg_mgr in ('yum', 'dnf', 'apt', 'pkgng')
block:
- name: Remove zip binaries
package:
state: absent
name:
- zip
- unzip
notify: restore packages
- name: create unarchive destinations
file:
path: '{{ remote_tmp_dir }}/test-unarchive-{{ item }}'
state: directory
loop:
- zip
- tar
# With the zip binaries absent and tar still present, this task should work
- name: unarchive a tar file
unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.tar'
dest: '{{remote_tmp_dir}}/test-unarchive-tar'
remote_src: yes
register: tar
- name: unarchive a zip file
unarchive:
src: '{{remote_tmp_dir}}/test-unarchive.zip'
dest: '{{remote_tmp_dir}}/test-unarchive-zip'
list_files: True
remote_src: yes
register: zip_fail
ignore_errors: yes
- name: Ensure tasks worked as expected
assert:
that:
- tar is success
- zip_fail is failed
- zip_fail.msg is search('Unable to find required')
- name: Remove unarchive destinations
file:
path: '{{ remote_tmp_dir }}/test-unarchive-{{ item }}'
state: absent
loop:
- zip
- tar
- name: Reinsntall zip binaries
package:
name:
- zip
- unzip