--- - name: Include Packages ansible.builtin.include_vars: file: packages.yml name: role_packages - name: Run OS-specific bootstrap process block: - name: Bootstrap RHEL System block: - name: Install base packages in chroot environment ansible.builtin.command: >- dnf --releasever={{ '8' if os == 'rhel8' else '9' }} --repo={{ os | lower }}-baseos --installroot=/mnt --setopt=install_weak_deps=False --setopt=optional_metadata_types=filelists groupinstall -y base core changed_when: result.rc == 0 register: result - name: Prepare chroot environment ansible.builtin.shell: | ln -sf /run/systemd/resolve/resolv.conf /mnt/etc/resolv.conf mkdir -p /mnt/usr/local/install/redhat/dvd mount --bind /usr/local/install/redhat/dvd /mnt/usr/local/install/redhat/dvd arch-chroot /mnt rpm --rebuilddb changed_when: result.rc == 0 register: result - name: Copy RHEL repo file into chroot environment ansible.builtin.copy: src: /etc/yum.repos.d/{{ os | lower }}.repo dest: /mnt/etc/yum.repos.d/{{ os | lower }}.repo mode: '0644' remote_src: true - name: Install additional packages in chroot ansible.builtin.command: >- arch-chroot /mnt dnf --releasever={{ '8' if os == 'rhel8' else '9' }} --setopt=install_weak_deps=False install -y {{ role_packages[os] | join(' ') }} changed_when: result.rc == 0 register: result