---
# removes the in windows 10 introduced click to start dvd at boot
- name: Customize Windows ISO on Linux
hosts: localhost
become: true
gather_facts: false
vars:
iso_source: "/var/lib/vz/template/iso/Win11_24H2_usaLanguage_x64.iso" # Original Windows ISO path
iso_mount: "/dev/shm/isomount" # Mount point
iso_extracted: "/dev/shm/winiso/extracted" # Directory where files are copied
iso_output: "/var/lib/vz/template/iso/Win11_24H2_usaLanguage_x64_edited.iso" # Output path for the modified ISO
volume_label: "WINSETUP" # Volume label for the new ISO
tasks:
- name: Install required packages
ansible.builtin.package:
name: xorriso
state: present
- name: Create mount and extraction directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: '0755'
loop:
- "{{ iso_mount }}"
- "{{ iso_extracted }}"
- name: Mount the Windows ISO
ansible.builtin.mount:
path: "{{ iso_mount }}"
src: "{{ iso_source }}"
fstype: udf
opts: loop,ro
state: mounted
- name: Copy ISO contents to local directory
ansible.builtin.synchronize:
src: "{{ iso_mount }}/"
dest: "{{ iso_extracted }}/"
archive: true
- name: Unmount the Windows ISO
ansible.builtin.mount:
path: "{{ iso_mount }}"
state: unmounted
- name: Remove old efisys.bin and cdboot.efi
ansible.builtin.file:
path: "{{ iso_extracted }}/efi/microsoft/boot/{{ item }}"
state: absent
loop:
- "efisys.bin"
- "cdboot.efi"
- name: Copy efisys_noprompt.bin to efisys.bin
ansible.builtin.copy:
remote_src: true
src: "{{ iso_extracted }}/efi/microsoft/boot/efisys_noprompt.bin"
dest: "{{ iso_extracted }}/efi/microsoft/boot/efisys.bin"
- name: Remove efisys_noprompt.bin
ansible.builtin.file:
path: "{{ iso_extracted }}/efi/microsoft/boot/efisys_noprompt.bin"
state: absent
- name: Copy cdboot_noprompt.efi to cdboot.efi
ansible.builtin.copy:
remote_src: true
src: "{{ iso_extracted }}/efi/microsoft/boot/cdboot_noprompt.efi"
dest: "{{ iso_extracted }}/efi/microsoft/boot/cdboot.efi"
- name: Remove cdboot_noprompt.efi
ansible.builtin.file:
path: "{{ iso_extracted }}/efi/microsoft/boot/cdboot_noprompt.efi"
state: absent
- name: Build new Windows ISO with xorriso
ansible.builtin.shell: |
xorriso -as mkisofs \
-iso-level 3 \
-volid "{{ volume_label }}" \
-eltorito-boot boot/etfsboot.com \
-eltorito-catalog boot/boot.cat \
-no-emul-boot \
-boot-load-size 8 \
-boot-info-table \
-eltorito-alt-boot \
-e efi/microsoft/boot/efisys.bin \
-no-emul-boot \
-isohybrid-gpt-basdat \
-o "{{ iso_output }}" \
"{{ iso_extracted }}"
args:
creates: "{{ iso_output }}"
register: xorriso_output
- name: Show xorriso output
ansible.builtin.debug:
var: xorriso_output.stdout
- name: remove folders from /dev/shm
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ iso_mount }}"
- "{{ iso_extracted }}"