--- # Two code paths: # 1. Fresh run (system_cfg undefined): normalize from raw `system` input. # 2. Pre-computed (system_cfg already set, e.g. from main project's deploy_iac): # merge with bootstrap system_defaults to fill missing fields (luks, features, # etc.) that bootstrap expects but the main project doesn't set, then derive # convenience facts (hostname, os, os_version). - 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: 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: 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