community.windows.win_disk_image (2.2.0) — module

Manage ISO/VHD/VHDX mounts on Windows hosts

Authors: Matt Davis (@nitzmahone)

Install collection

Install with ansible-galaxy collection install community.windows:==2.2.0


Add to requirements.yml

  collections:
    - name: community.windows
      version: 2.2.0

Description

Manages mount behavior for a specified ISO, VHD, or VHDX image on a Windows host. When C(state) is C(present), the image will be mounted under a system-assigned drive letter, which will be returned in the C(mount_path) value of the module result.

Requires Windows 8+ or Windows Server 2012+.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Run installer from mounted ISO, then unmount
- name: Ensure an ISO is mounted
  community.windows.win_disk_image:
    image_path: C:\install.iso
    state: present
  register: disk_image_out
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run installer from mounted ISO
  ansible.windows.win_package:
    path: '{{ disk_image_out.mount_paths[0] }}setup\setup.exe'
    product_id: 35a4e767-0161-46b0-979f-e61f282fee21
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Unmount ISO
  community.windows.win_disk_image:
    image_path: C:\install.iso
    state: absent

Inputs

    
state:
    choices:
    - absent
    - present
    default: present
    description:
    - Whether the image should be present as a drive-letter mount or not.
    type: str

image_path:
    description:
    - Path to an ISO, VHD, or VHDX image on the target Windows host (the file cannot reside
      on a network share)
    required: true
    type: str

Outputs

mount_paths:
  description: A list of filesystem paths mounted from the target image.
  returned: when C(state) is C(present)
  sample:
  - E:\
  - F:\
  type: list