refactor(bootstrap): unify rocky, almalinux, and fedora into shared _dnf_family.yml
This commit is contained in:
41
roles/bootstrap/tasks/_dnf_family.yml
Normal file
41
roles/bootstrap/tasks/_dnf_family.yml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
- name: "Bootstrap {{ os | capitalize }}"
|
||||||
|
vars:
|
||||||
|
_dnf_os_config:
|
||||||
|
rocky:
|
||||||
|
repos: [baseos, appstream]
|
||||||
|
groups: [core]
|
||||||
|
almalinux:
|
||||||
|
repos: [baseos, appstream]
|
||||||
|
groups: [core]
|
||||||
|
fedora:
|
||||||
|
repos: [fedora, fedora-updates]
|
||||||
|
groups: [critical-path-base, core]
|
||||||
|
_dnf_repos: "{{ _dnf_os_config[os].repos | map('regex_replace', '^', '--repo=') | join(' ') }}"
|
||||||
|
_dnf_groups: "{{ _dnf_os_config[os].groups | join(' ') }}"
|
||||||
|
_dnf_extra: >-
|
||||||
|
{{
|
||||||
|
lookup('vars', bootstrap_var_key)
|
||||||
|
| reject('equalto', '')
|
||||||
|
| join(' ')
|
||||||
|
}}
|
||||||
|
block:
|
||||||
|
- name: "Install {{ os | capitalize }} base system"
|
||||||
|
ansible.builtin.command: >-
|
||||||
|
dnf --releasever={{ os_version }} --best {{ _dnf_repos }}
|
||||||
|
--installroot=/mnt --setopt=install_weak_deps=False
|
||||||
|
groupinstall -y {{ _dnf_groups }}
|
||||||
|
register: _dnf_base_result
|
||||||
|
changed_when: _dnf_base_result.rc == 0
|
||||||
|
|
||||||
|
- name: Install extra packages
|
||||||
|
ansible.builtin.command: >-
|
||||||
|
{{ chroot_command }} dnf --releasever={{ os_version }} --setopt=install_weak_deps=False
|
||||||
|
install -y {{ _dnf_extra }}
|
||||||
|
register: _dnf_extra_result
|
||||||
|
changed_when: _dnf_extra_result.rc == 0
|
||||||
|
|
||||||
|
- name: Reinstall kernel core
|
||||||
|
ansible.builtin.command: "{{ chroot_command }} dnf reinstall -y kernel-core"
|
||||||
|
register: _dnf_kernel_result
|
||||||
|
changed_when: _dnf_kernel_result.rc == 0
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Bootstrap AlmaLinux
|
|
||||||
vars:
|
|
||||||
bootstrap_almalinux_extra: >-
|
|
||||||
{{
|
|
||||||
lookup('vars', bootstrap_var_key)
|
|
||||||
| reject('equalto', '')
|
|
||||||
| join(' ')
|
|
||||||
}}
|
|
||||||
block:
|
|
||||||
- name: Install AlmaLinux base system
|
|
||||||
ansible.builtin.command: >-
|
|
||||||
dnf --releasever={{ os_version }} --best --repo=baseos --repo=appstream
|
|
||||||
--installroot=/mnt --setopt=install_weak_deps=False
|
|
||||||
groupinstall -y core
|
|
||||||
register: bootstrap_almalinux_base_result
|
|
||||||
changed_when: bootstrap_almalinux_base_result.rc == 0
|
|
||||||
|
|
||||||
- name: Install extra packages
|
|
||||||
ansible.builtin.command: >-
|
|
||||||
{{ chroot_command }} dnf --releasever={{ os_version }} --setopt=install_weak_deps=False
|
|
||||||
install -y {{ bootstrap_almalinux_extra }}
|
|
||||||
register: bootstrap_almalinux_extra_result
|
|
||||||
changed_when: bootstrap_almalinux_extra_result.rc == 0
|
|
||||||
|
|
||||||
- name: Reinstall kernel core
|
|
||||||
ansible.builtin.command: "{{ chroot_command }} dnf reinstall -y kernel-core"
|
|
||||||
register: bootstrap_almalinux_kernel_result
|
|
||||||
changed_when: bootstrap_almalinux_kernel_result.rc == 0
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Bootstrap Fedora
|
|
||||||
vars:
|
|
||||||
bootstrap_fedora_extra: >-
|
|
||||||
{{
|
|
||||||
lookup('vars', bootstrap_var_key)
|
|
||||||
| reject('equalto', '')
|
|
||||||
| join(' ')
|
|
||||||
}}
|
|
||||||
block:
|
|
||||||
- name: Install Fedora base system
|
|
||||||
ansible.builtin.command: >-
|
|
||||||
dnf --releasever={{ os_version }} --best --repo=fedora --repo=fedora-updates
|
|
||||||
--installroot=/mnt --setopt=install_weak_deps=False
|
|
||||||
groupinstall -y critical-path-base core
|
|
||||||
register: bootstrap_fedora_base_result
|
|
||||||
changed_when: bootstrap_fedora_base_result.rc == 0
|
|
||||||
|
|
||||||
- name: Install extra packages
|
|
||||||
ansible.builtin.command: >-
|
|
||||||
{{ chroot_command }} dnf --releasever={{ os_version }} --setopt=install_weak_deps=False
|
|
||||||
install -y {{ bootstrap_fedora_extra }}
|
|
||||||
register: bootstrap_fedora_extra_result
|
|
||||||
changed_when: bootstrap_fedora_extra_result.rc == 0
|
|
||||||
|
|
||||||
- name: Reinstall kernel core
|
|
||||||
ansible.builtin.command: "{{ chroot_command }} dnf reinstall -y kernel-core"
|
|
||||||
register: bootstrap_fedora_kernel_result
|
|
||||||
changed_when: bootstrap_fedora_kernel_result.rc == 0
|
|
||||||
@@ -29,13 +29,13 @@
|
|||||||
- name: Run OS-specific bootstrap process
|
- name: Run OS-specific bootstrap process
|
||||||
vars:
|
vars:
|
||||||
bootstrap_os_task_map:
|
bootstrap_os_task_map:
|
||||||
almalinux: almalinux.yml
|
almalinux: _dnf_family.yml
|
||||||
alpine: alpine.yml
|
alpine: alpine.yml
|
||||||
archlinux: archlinux.yml
|
archlinux: archlinux.yml
|
||||||
debian: debian.yml
|
debian: debian.yml
|
||||||
fedora: fedora.yml
|
fedora: _dnf_family.yml
|
||||||
opensuse: opensuse.yml
|
opensuse: opensuse.yml
|
||||||
rocky: rocky.yml
|
rocky: _dnf_family.yml
|
||||||
rhel: rhel.yml
|
rhel: rhel.yml
|
||||||
ubuntu: ubuntu.yml
|
ubuntu: ubuntu.yml
|
||||||
ubuntu-lts: ubuntu.yml
|
ubuntu-lts: ubuntu.yml
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Bootstrap Rocky Linux
|
|
||||||
vars:
|
|
||||||
bootstrap_rocky_extra: >-
|
|
||||||
{{
|
|
||||||
lookup('vars', bootstrap_var_key)
|
|
||||||
| reject('equalto', '')
|
|
||||||
| join(' ')
|
|
||||||
}}
|
|
||||||
block:
|
|
||||||
- name: Install Rocky Linux base system
|
|
||||||
ansible.builtin.command: >-
|
|
||||||
dnf --releasever={{ os_version }} --best --repo=baseos --repo=appstream
|
|
||||||
--installroot=/mnt --setopt=install_weak_deps=False
|
|
||||||
groupinstall -y core
|
|
||||||
register: bootstrap_rocky_base_result
|
|
||||||
changed_when: bootstrap_rocky_base_result.rc == 0
|
|
||||||
|
|
||||||
- name: Install extra packages
|
|
||||||
ansible.builtin.command: >-
|
|
||||||
{{ chroot_command }} dnf --releasever={{ os_version }} --setopt=install_weak_deps=False
|
|
||||||
install -y {{ bootstrap_rocky_extra }}
|
|
||||||
register: bootstrap_rocky_extra_result
|
|
||||||
changed_when: bootstrap_rocky_extra_result.rc == 0
|
|
||||||
|
|
||||||
- name: Reinstall kernel core
|
|
||||||
ansible.builtin.command: "{{ chroot_command }} dnf reinstall -y kernel-core"
|
|
||||||
register: bootstrap_rocky_kernel_result
|
|
||||||
changed_when: bootstrap_rocky_kernel_result.rc == 0
|
|
||||||
Reference in New Issue
Block a user