refactor(bootstrap,configuration,environment): add defaults/main.yml and extract hardcoded values
This commit is contained in:
15
roles/bootstrap/defaults/main.yml
Normal file
15
roles/bootstrap/defaults/main.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
# OS → task file mapping for bootstrap dispatch.
|
||||||
|
# Each key matches a supported `os` value; value is the task file to include.
|
||||||
|
bootstrap_os_task_map:
|
||||||
|
almalinux: _dnf_family.yml
|
||||||
|
alpine: alpine.yml
|
||||||
|
archlinux: archlinux.yml
|
||||||
|
debian: debian.yml
|
||||||
|
fedora: _dnf_family.yml
|
||||||
|
opensuse: opensuse.yml
|
||||||
|
rocky: _dnf_family.yml
|
||||||
|
rhel: rhel.yml
|
||||||
|
ubuntu: ubuntu.yml
|
||||||
|
ubuntu-lts: ubuntu.yml
|
||||||
|
void: void.yml
|
||||||
@@ -9,16 +9,3 @@
|
|||||||
Unsupported OS '{{ os | default("undefined") }}' for bootstrap.
|
Unsupported OS '{{ os | default("undefined") }}' for bootstrap.
|
||||||
Supported: {{ bootstrap_os_task_map | dict2items | map(attribute='key') | join(', ') }}
|
Supported: {{ bootstrap_os_task_map | dict2items | map(attribute='key') | join(', ') }}
|
||||||
quiet: true
|
quiet: true
|
||||||
vars:
|
|
||||||
bootstrap_os_task_map:
|
|
||||||
almalinux: _dnf_family.yml
|
|
||||||
alpine: alpine.yml
|
|
||||||
archlinux: archlinux.yml
|
|
||||||
debian: debian.yml
|
|
||||||
fedora: _dnf_family.yml
|
|
||||||
opensuse: opensuse.yml
|
|
||||||
rocky: _dnf_family.yml
|
|
||||||
rhel: rhel.yml
|
|
||||||
ubuntu: ubuntu.yml
|
|
||||||
ubuntu-lts: ubuntu.yml
|
|
||||||
void: void.yml
|
|
||||||
|
|||||||
@@ -31,18 +31,6 @@
|
|||||||
|
|
||||||
- name: Run OS-specific bootstrap process
|
- name: Run OS-specific bootstrap process
|
||||||
vars:
|
vars:
|
||||||
bootstrap_os_task_map:
|
|
||||||
almalinux: _dnf_family.yml
|
|
||||||
alpine: alpine.yml
|
|
||||||
archlinux: archlinux.yml
|
|
||||||
debian: debian.yml
|
|
||||||
fedora: _dnf_family.yml
|
|
||||||
opensuse: opensuse.yml
|
|
||||||
rocky: _dnf_family.yml
|
|
||||||
rhel: rhel.yml
|
|
||||||
ubuntu: ubuntu.yml
|
|
||||||
ubuntu-lts: ubuntu.yml
|
|
||||||
void: void.yml
|
|
||||||
bootstrap_var_key: "{{ 'bootstrap_' + (os | replace('-lts', '') | replace('-', '_')) }}"
|
bootstrap_var_key: "{{ 'bootstrap_' + (os | replace('-lts', '') | replace('-', '_')) }}"
|
||||||
ansible.builtin.include_tasks: "{{ bootstrap_os_task_map[os] }}"
|
ansible.builtin.include_tasks: "{{ bootstrap_os_task_map[os] }}"
|
||||||
|
|
||||||
|
|||||||
7
roles/configuration/defaults/main.yml
Normal file
7
roles/configuration/defaults/main.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
# Network configuration dispatch — maps OS name to the task file
|
||||||
|
# that writes network config. Default (NetworkManager) applies to
|
||||||
|
# all OSes not explicitly listed.
|
||||||
|
configuration_network_task_map:
|
||||||
|
alpine: network_alpine.yml
|
||||||
|
void: network_void.yml
|
||||||
@@ -30,8 +30,4 @@
|
|||||||
fail_msg: Failed to detect any network interfaces.
|
fail_msg: Failed to detect any network interfaces.
|
||||||
|
|
||||||
- name: Configure networking
|
- name: Configure networking
|
||||||
vars:
|
|
||||||
configuration_network_task_map:
|
|
||||||
alpine: network_alpine.yml
|
|
||||||
void: network_void.yml
|
|
||||||
ansible.builtin.include_tasks: "{{ configuration_network_task_map[os] | default('network_nm.yml') }}"
|
ansible.builtin.include_tasks: "{{ configuration_network_task_map[os] | default('network_nm.yml') }}"
|
||||||
|
|||||||
10
roles/environment/defaults/main.yml
Normal file
10
roles/environment/defaults/main.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# Connection and timing
|
||||||
|
environment_wait_timeout: 180
|
||||||
|
environment_wait_delay: 5
|
||||||
|
|
||||||
|
# Pacman installer settings
|
||||||
|
environment_parallel_downloads: 20
|
||||||
|
environment_pacman_lock_timeout: 120
|
||||||
|
environment_pacman_retries: 4
|
||||||
|
environment_pacman_retry_delay: 15
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Wait for connection
|
- name: Wait for connection
|
||||||
ansible.builtin.wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
timeout: 180
|
timeout: "{{ environment_wait_timeout }}"
|
||||||
delay: 5
|
delay: "{{ environment_wait_delay }}"
|
||||||
|
|
||||||
- name: Gather facts
|
- name: Gather facts
|
||||||
ansible.builtin.setup:
|
ansible.builtin.setup:
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/pacman.conf
|
path: /etc/pacman.conf
|
||||||
regexp: ^#ParallelDownloads =
|
regexp: ^#ParallelDownloads =
|
||||||
line: ParallelDownloads = 20
|
line: "ParallelDownloads = {{ environment_parallel_downloads }}"
|
||||||
|
|
||||||
- name: Wait for pacman lock to be released
|
- name: Wait for pacman lock to be released
|
||||||
when: not (custom_iso | bool)
|
when: not (custom_iso | bool)
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
path: /var/lib/pacman/db.lck
|
path: /var/lib/pacman/db.lck
|
||||||
state: absent
|
state: absent
|
||||||
timeout: 120
|
timeout: "{{ environment_pacman_lock_timeout }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Setup Pacman
|
- name: Setup Pacman
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
- { name: ubuntu-keyring, os: [ubuntu, ubuntu-lts] }
|
- { name: ubuntu-keyring, os: [ubuntu, ubuntu-lts] }
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.name }}"
|
label: "{{ item.name }}"
|
||||||
retries: 4
|
retries: "{{ environment_pacman_retries }}"
|
||||||
delay: 15
|
delay: "{{ environment_pacman_retry_delay }}"
|
||||||
|
|
||||||
- name: Prepare /iso mount and repository for RHEL-based systems
|
- name: Prepare /iso mount and repository for RHEL-based systems
|
||||||
when: os == "rhel"
|
when: os == "rhel"
|
||||||
|
|||||||
Reference in New Issue
Block a user