mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Initial commit
* Adding changelog fragment
(cherry picked from commit ffe505a798
)
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
This commit is contained in:
parent
6d5dbfd455
commit
58d8469759
3 changed files with 45 additions and 8 deletions
4
changelogs/fragments/2923-archive-remove-bugfix.yml
Normal file
4
changelogs/fragments/2923-archive-remove-bugfix.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- archive - fixed task failure when using the ``remove`` option with a ``path`` containing nested files for
|
||||||
|
``format``s other than ``zip`` (https://github.com/ansible-collections/community.general/issues/2919).
|
|
@ -399,13 +399,14 @@ class Archive(object):
|
||||||
|
|
||||||
def remove_targets(self):
|
def remove_targets(self):
|
||||||
for path in self.successes:
|
for path in self.successes:
|
||||||
try:
|
if os.path.exists(path):
|
||||||
if os.path.isdir(path):
|
try:
|
||||||
shutil.rmtree(path)
|
if os.path.isdir(path):
|
||||||
else:
|
shutil.rmtree(path)
|
||||||
os.remove(path)
|
else:
|
||||||
except OSError:
|
os.remove(path)
|
||||||
self.errors.append(_to_native(path))
|
except OSError:
|
||||||
|
self.errors.append(_to_native(path))
|
||||||
for path in self.paths:
|
for path in self.paths:
|
||||||
try:
|
try:
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
|
|
|
@ -148,7 +148,39 @@
|
||||||
- name: verify that excluded sub file is still present
|
- name: verify that excluded sub file is still present
|
||||||
file: path={{ output_dir }}/tmpdir/sub/subfile.txt state=file
|
file: path={{ output_dir }}/tmpdir/sub/subfile.txt state=file
|
||||||
|
|
||||||
- name: remove temporary directory
|
- name: prep our files in tmpdir again
|
||||||
|
copy: src={{ item }} dest={{ output_dir }}/tmpdir/{{ item }}
|
||||||
|
with_items:
|
||||||
|
- foo.txt
|
||||||
|
- bar.txt
|
||||||
|
- empty.txt
|
||||||
|
- sub
|
||||||
|
- sub/subfile.txt
|
||||||
|
|
||||||
|
- name: archive using gz and remove src directory
|
||||||
|
archive:
|
||||||
|
path:
|
||||||
|
- "{{ output_dir }}/tmpdir/"
|
||||||
|
dest: "{{ output_dir }}/archive_remove_05.gz"
|
||||||
|
format: gz
|
||||||
|
remove: yes
|
||||||
|
exclude_path: "{{ output_dir }}/tmpdir/sub/subfile.txt"
|
||||||
|
register: archive_remove_result_05
|
||||||
|
|
||||||
|
- name: verify that the files archived
|
||||||
|
file: path={{ output_dir }}/archive_remove_05.gz state=file
|
||||||
|
|
||||||
|
- name: Verify source files were removed
|
||||||
file:
|
file:
|
||||||
path: "{{ output_dir }}/tmpdir"
|
path: "{{ output_dir }}/tmpdir"
|
||||||
state: absent
|
state: absent
|
||||||
|
register: archive_source_file_removal_05
|
||||||
|
|
||||||
|
- name: Verify that task status is success
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- archive_remove_result_05 is success
|
||||||
|
- archive_source_file_removal_05 is not changed
|
||||||
|
|
||||||
|
- name: remove our gz
|
||||||
|
file: path="{{ output_dir }}/archive_remove_05.gz" state=absent
|
||||||
|
|
Loading…
Reference in a new issue