55 lines
1.9 KiB
YAML
55 lines
1.9 KiB
YAML
---
|
|
- name: Bootstrap RHEL System
|
|
block:
|
|
- name: Install base packages in chroot environment
|
|
ansible.builtin.command: >-
|
|
dnf --releasever={{ os_version_major }} --repo=rhel{{ os_version_major }}-baseos
|
|
--installroot=/mnt
|
|
--setopt=install_weak_deps=False --setopt=optional_metadata_types=filelists
|
|
groupinstall -y core base standard
|
|
register: bootstrap_result
|
|
changed_when: bootstrap_result.rc == 0
|
|
failed_when:
|
|
- bootstrap_result.rc != 0
|
|
- "'grub2-common' not in (bootstrap_result.stderr | default(''))"
|
|
|
|
- name: Ensure chroot RHEL DVD directory exists
|
|
ansible.builtin.file:
|
|
path: /mnt/usr/local/install/redhat/dvd
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Bind mount RHEL DVD into chroot
|
|
ansible.posix.mount:
|
|
src: /usr/local/install/redhat/dvd
|
|
path: /mnt/usr/local/install/redhat/dvd
|
|
fstype: none
|
|
opts: bind
|
|
state: ephemeral
|
|
|
|
- name: Rebuild RPM database inside chroot
|
|
ansible.builtin.command: "{{ chroot_command }} rpm --rebuilddb"
|
|
register: bootstrap_rpm_rebuild_result
|
|
changed_when: bootstrap_rpm_rebuild_result.rc == 0
|
|
|
|
- name: Copy RHEL repo file into chroot environment
|
|
ansible.builtin.copy:
|
|
src: /etc/yum.repos.d/rhel.repo
|
|
dest: /mnt/etc/yum.repos.d/redhat.repo
|
|
mode: "0644"
|
|
remote_src: true
|
|
|
|
- name: Install additional packages in chroot
|
|
vars:
|
|
bootstrap_rhel_extra: >-
|
|
{{
|
|
lookup('vars', bootstrap_var_key)
|
|
| reject('equalto', '')
|
|
| join(' ')
|
|
}}
|
|
ansible.builtin.command: >-
|
|
{{ chroot_command }} dnf --releasever={{ os_version_major }}
|
|
--setopt=install_weak_deps=False install -y {{ bootstrap_rhel_extra }}
|
|
register: bootstrap_result
|
|
changed_when: bootstrap_result.rc == 0
|