iso_extract: strip leading path separator from file entries (#11825)

* iso_extract: strip leading path separator from file entries

Fixes #5283

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* iso_extract: add changelog fragment for issue 5283

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky
2026-04-16 05:54:46 +12:00
committed by GitHub
parent 7172326868
commit d1448b76c1
3 changed files with 21 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
bugfixes:
- iso_extract - strip leading path separator from file entries so files with a leading ``/`` are extracted correctly (https://github.com/ansible-collections/community.general/issues/5283, https://github.com/ansible-collections/community.general/pull/11825).

View File

@@ -48,6 +48,7 @@ options:
description:
- A list of files to extract from the image.
- Extracting directories does not work.
- File paths should not include a leading V(/); any leading path separator is automatically stripped.
type: list
elements: str
required: true
@@ -138,11 +139,11 @@ def main():
module.fail_json(msg=f"ISO image '{image}' does not exist")
result["files"] = []
extract_files = list(files)
extract_files = [f.lstrip(os.sep) for f in files]
if not force:
# Check if we have to process any files based on existence
for f in files:
for f in extract_files[:]:
dest_file = os.path.join(dest, os.path.basename(f))
if os.path.exists(dest_file):
result["files"].append(

View File

@@ -38,3 +38,19 @@
that:
- iso_extract_test0_again is changed
when: in_check_mode
- name: Extract the iso using files with leading slash
iso_extract:
image: '{{ output_test_dir }}/test.iso'
dest: '{{ output_test_dir }}'
files:
- /1.txt
- /2.txt
force: true
register: iso_extract_leading_slash
- name: Test iso_extract with leading slash succeeds (normal mode)
assert:
that:
- iso_extract_leading_slash is not failed
when: not in_check_mode