community.general.iso_customize module – Add/remove/change files in ISO file

Note

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

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_customize.

New in community.general 5.8.0

Synopsis

  • This module is used to add/remove/change files in ISO file.

  • The file inside ISO will be overwritten if it exists by option add_files.

Requirements

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

  • pycdlib

Parameters

Parameter

Comments

add_files

list / elements=dictionary

Allows to add and replace files in the ISO file.

Will create intermediate folders inside the ISO file when they do not exist.

Default: []

dest_file

string / required

The absolute path of the file inside the ISO file.

src_file

path / required

The path with file name on the machine the module is executed on.

delete_files

list / elements=string

Absolute paths for files inside the ISO file that should be removed.

Default: []

dest_iso

path / required

The path of the customized ISO file.

src_iso

path / required

This is the path of source ISO file.

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

  • The pycdlib library states it supports Python 2.7 and 3.4+.

  • The function add_file in pycdlib will overwrite the existing file in ISO with type ISO9660 / Rock Ridge 1.12 / Joliet / UDF. But it will not overwrite the existing file in ISO with Rock Ridge 1.09 / 1.10. So we take workaround “delete the existing file and then add file for ISO with Rock Ridge”.

Examples

- name: "Customize ISO file"
  community.general.iso_customize:
    src_iso: "/path/to/ubuntu-22.04-desktop-amd64.iso"
    dest_iso: "/path/to/ubuntu-22.04-desktop-amd64-customized.iso"
    delete_files:
      - "/boot.catalog"
    add_files:
      - src_file: "/path/to/grub.cfg"
        dest_file: "/boot/grub/grub.cfg"
      - src_file: "/path/to/ubuntu.seed"
        dest_file: "/preseed/ubuntu.seed"
  register: customize_iso_result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

dest_iso

string

Path of the customized ISO file.

Returned: on success

Sample: "/path/to/customized.iso"

src_iso

string

Path of source ISO file.

Returned: on success

Sample: "/path/to/file.iso"

Authors

  • Yuhua Zou (@ZouYuhua)