community.general.iso_extract module – Extract files from an ISO image

Note

This module is part of the community.general collection (version 9.5.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.iso_extract.

Synopsis

  • This module has two possible ways of operation.

  • If 7zip is installed on the system, this module extracts files from an ISO into a temporary directory and copies files to a given destination, if needed.

  • If the user has mount-capabilities (CAP_SYS_ADMIN on Linux) this module mounts the ISO image to a temporary location, and copies files to a given destination, if needed.

Requirements

The below requirements are needed on the host that executes this module.

  • Either 7z (from 7zip or p7zip package)

  • Or mount capabilities (root-access, or CAP_SYS_ADMIN capability on Linux)

Parameters

Parameter

Comments

dest

path / required

The destination directory to extract files to.

executable

path

The path to the 7z executable to use for extracting files from the ISO.

If not provided, it will assume the value 7z.

files

list / elements=string / required

A list of files to extract from the image.

Extracting directories does not work.

force

boolean

If true, which will replace the remote file when contents are different than the source.

If false, the file will only be extracted and copied if the destination does not already exist.

Choices:

  • false

  • true ← (default)

image

aliases: path, src

path / required

The ISO image to extract files from.

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Notes

Note

  • Only the file checksum (content) is taken into account when extracting files from the ISO image. If force=false, only checks the presence of the file.

Examples

- name: Extract kernel and ramdisk from a LiveCD
  community.general.iso_extract:
    image: /tmp/rear-test.iso
    dest: /tmp/virt-rear/
    files:
    - isolinux/kernel
    - isolinux/initrd.cgz

Authors

  • Jeroen Hoekx (@jhoekx)

  • Matt Robinson (@ribbons)

  • Dag Wieers (@dagwieers)