58 lines
2.0 KiB
YAML
58 lines
2.0 KiB
YAML
---
|
|
- name: Bootstrap RHEL System
|
|
vars:
|
|
_rhel_config: "{{ lookup('vars', bootstrap_var_key) }}"
|
|
_rhel_repos: "{{ _rhel_config.repos | map('regex_replace', '^', '--repo=') | join(' ') }}"
|
|
_rhel_groups: "{{ _rhel_config.base | join(' ') }}"
|
|
_rhel_extra: >-
|
|
{{
|
|
((_rhel_config.extra | default([])) + (_rhel_config.conditional | default([])))
|
|
| reject('equalto', '')
|
|
| join(' ')
|
|
}}
|
|
block:
|
|
- name: Install base packages in chroot environment
|
|
ansible.builtin.command: >-
|
|
dnf --releasever={{ os_version_major }} {{ _rhel_repos }}
|
|
--installroot=/mnt
|
|
--setopt=install_weak_deps=False --setopt=optional_metadata_types=filelists
|
|
groupinstall -y {{ _rhel_groups }}
|
|
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
|
|
ansible.builtin.command: >-
|
|
{{ chroot_command }} dnf --releasever={{ os_version_major }}
|
|
--setopt=install_weak_deps=False install -y {{ _rhel_extra }}
|
|
register: bootstrap_result
|
|
changed_when: bootstrap_result.rc == 0
|