Files
Ansible-Bootstrap/roles/global_defaults/tasks/hypervisor.yml

27 lines
825 B
YAML

---
- name: Ensure hypervisor input is a dictionary
ansible.builtin.set_fact:
hypervisor: "{{ hypervisor | default({}) }}"
changed_when: false
- 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: Normalize hypervisor configuration
vars:
hypervisor_cfg_effective: >-
{{
hypervisor_defaults
| combine(hypervisor, recursive=True)
}}
ansible.builtin.set_fact:
hypervisor_cfg: "{{ hypervisor_cfg_effective }}"
hypervisor_type: "{{ hypervisor_cfg_effective.type | string | lower }}"
changed_when: false