91 lines
3.4 KiB
YAML
91 lines
3.4 KiB
YAML
---
|
|
# Fresh run normalizes raw `system` input. A pre-computed system_cfg (from the main
|
|
# project's deploy_iac) is instead merged with system_defaults to fill the fields
|
|
# bootstrap expects, then convenience facts are derived.
|
|
- name: Normalize system and disk configuration
|
|
when: system_cfg is not defined
|
|
block:
|
|
- name: Validate raw system input types
|
|
ansible.builtin.include_tasks: _validate_input.yml
|
|
|
|
- name: Normalize system configuration
|
|
ansible.builtin.include_tasks: _normalize_system.yml
|
|
|
|
- name: Normalize disk configuration
|
|
ansible.builtin.include_tasks: _normalize_disks.yml
|
|
|
|
- name: Populate primary network fields from first interface
|
|
when:
|
|
- system_cfg is defined
|
|
- system_cfg.network.interfaces | default([]) | length > 0
|
|
- system_cfg.network.ip | default('') | string | length == 0
|
|
vars:
|
|
_primary: "{{ system_cfg.network.interfaces[0] }}"
|
|
ansible.builtin.set_fact:
|
|
system_cfg: >-
|
|
{{
|
|
system_cfg | combine({
|
|
'network': system_cfg.network | combine({
|
|
'bridge': _primary.bridge | default(''),
|
|
'vlan': _primary.vlan | default(''),
|
|
'ip': _primary.ip | default(''),
|
|
'prefix': _primary.prefix | default(''),
|
|
'gateway': _primary.gateway | default('')
|
|
})
|
|
}, recursive=True)
|
|
}}
|
|
|
|
- name: Check if pre-computed system_cfg needs enrichment
|
|
when: system_cfg is defined
|
|
ansible.builtin.set_fact:
|
|
_bootstrap_needs_enrichment: "{{ hostname is not defined }}"
|
|
|
|
- name: Merge pre-computed system_cfg with bootstrap system_defaults
|
|
when:
|
|
- system_cfg is defined
|
|
- _bootstrap_needs_enrichment | default(false) | bool
|
|
ansible.builtin.set_fact:
|
|
system_cfg: "{{ system_defaults | combine(system | default({}), recursive=True) | combine(system_cfg, recursive=True) }}"
|
|
|
|
- name: Populate primary network fields from first interface (pre-computed)
|
|
when:
|
|
- system_cfg is defined
|
|
- _bootstrap_needs_enrichment | default(false) | bool
|
|
- system_cfg.network.interfaces | default([]) | length > 0
|
|
- system_cfg.network.bridge | default('') | string | length == 0
|
|
vars:
|
|
_primary: "{{ system_cfg.network.interfaces[0] }}"
|
|
ansible.builtin.set_fact:
|
|
system_cfg: >-
|
|
{{
|
|
system_cfg | combine({
|
|
'network': system_cfg.network | combine({
|
|
'bridge': _primary.bridge | default(''),
|
|
'vlan': _primary.vlan | default(''),
|
|
'ip': _primary.ip | default(''),
|
|
'prefix': _primary.prefix | default(''),
|
|
'gateway': _primary.gateway | default('')
|
|
})
|
|
}, recursive=True)
|
|
}}
|
|
|
|
- name: Derive convenience facts from pre-computed system_cfg
|
|
when:
|
|
- system_cfg is defined
|
|
- _bootstrap_needs_enrichment | default(false) | bool
|
|
ansible.builtin.set_fact:
|
|
hostname: "{{ system_cfg.name | default(inventory_hostname) }}"
|
|
os: "{{ system_cfg.os | default('') }}"
|
|
os_version: "{{ system_cfg.version | default('') | string }}"
|
|
|
|
- name: Normalize disk configuration (pre-computed system_cfg)
|
|
when:
|
|
- system_cfg is defined
|
|
- install_drive is not defined
|
|
ansible.builtin.include_tasks: _normalize_disks.yml
|
|
|
|
# Runs on every path before validation, so an empty firewall.backend / content.source
|
|
# resolves to the family default even when system_cfg arrived pre-computed.
|
|
- name: Apply family defaults (content source, firewall backend)
|
|
ansible.builtin.include_tasks: _apply_family_defaults.yml
|