community.general/tests/integration/targets/decompress/tasks/dest.yml

52 lines
1.3 KiB
YAML
Raw Normal View History

Add decompress module (#9175) * adds simple implementation of `decompress` module * adds simple test, fixes src and dest arg types * minor refactoring * adds support for common file operations adds integration test for gz decompressing * makes tests parametrized to test all supported compression formats * checks that target file exists * writes to decompressed file now uses atomic_move * adds idempotency for decompression * refactoring, removed classes * adds support for check mode * adds check for destination file. If it exists and it is a directory, the module returns error * refactoring, moves code to a class. Also, simplifies tests (now only tests related to the module core functionality run as parametrized, tests for idempotency and check mode run only for one format) * adds 'remove' parameter that deletes original compressed file after decompression * adds documentation * fixes bug with 'remove' parameter in check mode * makes dest argument not required. Dest filename now can be produced from the src filename * adds dest to output * updates the documentation, adds "RETURN" block * fixes test * adds support for python2 * removes some of the test files that can be generated during testing. Adds copyright header to test files * adds maintainer * apply minor suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * fixes code review comments (idempotency issue with non existing src, existing dest and remove=true; fixes the issue and adds test) * refactors the module to use ModuleHelper * refactors lzma dependency manual check to use 'deps.validate' * minor fix * removes registered handlers check * minor refactoring * adds aliases * changes setup for tests * tests: ignores macos and fixes tests for FreeBSD * tests: reverts ignore for macos and fixes issue with centos7 * tests: adds liblzma dependency for python2 * tests: adds backports.lzma * fixes bz2 decompression for python2 * tests: install xz for osx * tests: install xz for osx (2) * fixes code review comments --------- Co-authored-by: Felix Fontein <felix@fontein.de>
2024-12-02 19:16:00 +00:00
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Copy a compressed file
copy:
src: "{{ item.orig }}"
dest: "{{ item.new }}"
remote_src: true
loop:
- { orig: "{{ remote_tmp_dir }}/file.txt.gz", new: "{{ remote_tmp_dir }}/dest.txt.gz" }
- { orig: "{{ remote_tmp_dir }}/file.txt.gz", new: "{{ remote_tmp_dir }}/dest" }
- name: Decompress a file without specifying destination
decompress:
src: "{{ remote_tmp_dir }}/dest.txt.gz"
remove: true
- name: Decompress a file which lacks extension without specifying destination
decompress:
src: "{{ remote_tmp_dir }}/dest"
remove: true
- name: Stat result files
stat:
path: "{{ remote_tmp_dir }}/{{ filename }}"
loop:
- dest.txt
- dest_decompressed
loop_control:
loop_var: filename
register: result_files_stat
- name: Test that file exists
assert:
that: "{{ item.stat.exists }}"
quiet: true
loop: "{{ result_files_stat.results }}"
loop_control:
label: "{{ item.stat.path }}"
- name: Delete test files
file:
path: "{{ filename }}"
state: absent
loop:
- "dest.txt"
- "dest_decompressed"
loop_control:
loop_var: filename