--- - name: Normalize hypervisor configuration when: hypervisor_cfg is not defined block: - name: Ensure hypervisor input is a dictionary ansible.builtin.set_fact: hypervisor: "{{ hypervisor | default({}) }}" - name: Validate hypervisor input ansible.builtin.assert: that: - hypervisor is mapping - hypervisor.type is defined - hypervisor.type | string | length > 0 fail_msg: "hypervisor must be a dictionary and hypervisor.type must be set (e.g. libvirt|proxmox|vmware|xen|none)." quiet: true - name: Merge hypervisor defaults with input vars: merged: "{{ hypervisor_defaults | combine(hypervisor, recursive=True) }}" ansible.builtin.set_fact: hypervisor_cfg: "{{ merged }}" hypervisor_type: "{{ merged.type | string | lower }}" no_log: true