fix(environment): pick the largest cdrom as the RHEL install DVD

This commit is contained in:
2026-05-28 17:52:44 +02:00
parent b04aad12fb
commit 6a75237197

View File

@@ -73,28 +73,25 @@
mode: "0755"
- name: Detect RHEL ISO device
ansible.builtin.command: lsblk -rno NAME,TYPE
ansible.builtin.command: lsblk -rbno NAME,TYPE,SIZE
register: environment_lsblk_result
changed_when: false
- name: Select RHEL ISO device
vars:
_rom_devices: >-
{{
environment_lsblk_result.stdout_lines
| map('split', ' ')
| selectattr('1', 'equalto', 'rom')
| map('first')
| map('regex_replace', '^', '/dev/')
| list
}}
_roms: >-
{%- set out = [] -%}
{%- for line in environment_lsblk_result.stdout_lines -%}
{%- set p = line.split() -%}
{%- if (p | length) >= 3 and p[1] == 'rom' -%}
{%- set _ = out.append({'name': p[0], 'size': p[2] | int}) -%}
{%- endif -%}
{%- endfor -%}
{{ out }}
ansible.builtin.set_fact:
environment_rhel_iso_device: >-
{{
_rom_devices[-1]
if _rom_devices | length > 1
else (_rom_devices[0] | default('/dev/sr1'))
}}
{{ ('/dev/' ~ (_roms | sort(attribute='size') | last).name)
if (_roms | length) > 0 else '/dev/sr1' }}
- name: Mount RHEL ISO
ansible.posix.mount: