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

21 lines
760 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
ansible.builtin.set_fact:
hypervisor_cfg: "{{ hypervisor_defaults | combine(hypervisor, recursive=True) }}"
hypervisor_type: "{{ (hypervisor_defaults | combine(hypervisor, recursive=True)).type | string | lower }}"
changed_when: false