refactor(bootstrap): standardize patterns, extract common logic, remove dead code
- Make timezone, locale, and keymap configurable via system_cfg - Consolidate rhel8/9/10.repo.j2 into single rhel.repo.j2 template - Extract bootstrap_common_conditional for shared firewall/LUKS/guest packages - Remove redundant version aliases (fedora40-43, debian10-13, rhel8-10, etc.) - Simplify bootstrap dispatch from 10 conditional blocks to single mapping - Merge bootstrap_ubuntu_lts into bootstrap_ubuntu (identical) - Remove orphaned firstrun.sh.j2 template - Remove configuration/defaults/main.yml aliases, inline into banner.yml - Remove unnecessary changed_when: false on set_fact/debug tasks - Deduplicate hostname variable computation in locales.yml - Update README with timezone/locale/keymap variable reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: Configure MOTD
|
||||
when: configuration_motd_enabled | bool
|
||||
when: system_cfg.features.banner.motd | bool
|
||||
block:
|
||||
- name: Create MOTD file
|
||||
ansible.builtin.copy:
|
||||
@@ -24,7 +24,7 @@
|
||||
failed_when: false
|
||||
|
||||
- name: Configure sudo banner
|
||||
when: configuration_sudo_banner_enabled | bool
|
||||
when: system_cfg.features.banner.sudo | bool
|
||||
block:
|
||||
- name: Create sudoers banner directory
|
||||
ansible.builtin.file:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
- name: Set local timezone
|
||||
ansible.builtin.file:
|
||||
src: /usr/share/zoneinfo/Europe/Vienna
|
||||
src: /usr/share/zoneinfo/{{ system_cfg.timezone }}
|
||||
dest: /mnt/etc/localtime
|
||||
state: link
|
||||
force: true
|
||||
@@ -20,7 +20,7 @@
|
||||
regexp: "{{ item.regex }}"
|
||||
line: "{{ item.line }}"
|
||||
loop:
|
||||
- { regex: en_US\.UTF-8 UTF-8, line: en_US.UTF-8 UTF-8 }
|
||||
- { regex: "{{ system_cfg.locale }} UTF-8", line: "{{ system_cfg.locale }} UTF-8" }
|
||||
|
||||
- name: Generate locales
|
||||
when: not is_rhel | bool
|
||||
@@ -29,19 +29,22 @@
|
||||
changed_when: configuration_locale_result.rc == 0
|
||||
|
||||
|
||||
- name: Set hostname
|
||||
vars:
|
||||
configuration_dns_domain: "{{ (system_cfg.network.dns.search | default([]) | first | default('')) | string }}"
|
||||
- name: Compute hostname variables
|
||||
ansible.builtin.set_fact:
|
||||
configuration_dns_domain: >-
|
||||
{{ (system_cfg.network.dns.search | default([]) | first | default('')) | string }}
|
||||
configuration_hostname_fqdn: >-
|
||||
{{
|
||||
hostname
|
||||
if '.' in hostname
|
||||
else (
|
||||
hostname + '.' + configuration_dns_domain
|
||||
if configuration_dns_domain | length > 0
|
||||
hostname + '.' + (system_cfg.network.dns.search | default([]) | first | default('') | string)
|
||||
if (system_cfg.network.dns.search | default([]) | first | default('') | string) | length > 0
|
||||
else hostname
|
||||
)
|
||||
}}
|
||||
|
||||
- name: Set hostname
|
||||
ansible.builtin.copy:
|
||||
content: "{{ configuration_hostname_fqdn }}"
|
||||
dest: /mnt/etc/hostname
|
||||
@@ -49,17 +52,6 @@
|
||||
|
||||
- name: Add host entry to /etc/hosts
|
||||
vars:
|
||||
configuration_dns_domain: "{{ (system_cfg.network.dns.search | default([]) | first | default('')) | string }}"
|
||||
configuration_hostname_fqdn: >-
|
||||
{{
|
||||
hostname
|
||||
if '.' in hostname
|
||||
else (
|
||||
hostname + '.' + configuration_dns_domain
|
||||
if configuration_dns_domain | length > 0
|
||||
else hostname
|
||||
)
|
||||
}}
|
||||
configuration_hostname_short: "{{ hostname.split('.')[0] }}"
|
||||
configuration_hostname_entries: >-
|
||||
{{ [configuration_hostname_fqdn, configuration_hostname_short] | unique | join(' ') }}
|
||||
@@ -78,13 +70,13 @@
|
||||
|
||||
- name: Create vconsole.conf
|
||||
ansible.builtin.copy:
|
||||
content: KEYMAP=us
|
||||
content: "KEYMAP={{ system_cfg.keymap }}"
|
||||
dest: /mnt/etc/vconsole.conf
|
||||
mode: "0644"
|
||||
|
||||
- name: Create locale.conf
|
||||
ansible.builtin.copy:
|
||||
content: LANG=en_US.UTF-8
|
||||
content: "LANG={{ system_cfg.locale }}"
|
||||
dest: /mnt/etc/locale.conf
|
||||
mode: "0644"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user