refactor(vars): remove legacy variable inputs
This commit is contained in:
@@ -17,87 +17,79 @@
|
||||
{{
|
||||
system.name
|
||||
if system.name is defined and (system.name | string | length) > 0
|
||||
else (
|
||||
hostname
|
||||
if hostname is defined and (hostname | string | length) > 0
|
||||
else inventory_hostname
|
||||
)
|
||||
else inventory_hostname
|
||||
}}
|
||||
system_id_effective: >-
|
||||
{{
|
||||
system.id
|
||||
if system.id is defined and (system.id | string | length) > 0
|
||||
else (vm_id | default(''))
|
||||
else ''
|
||||
}}
|
||||
system_cpus_effective: >-
|
||||
{{
|
||||
system.cpus
|
||||
if system.cpus is defined and (system.cpus | int) > 0
|
||||
else (vm_cpus | default(0))
|
||||
else 0
|
||||
}}
|
||||
system_memory_mb_effective: >-
|
||||
{{
|
||||
system.memory_mb
|
||||
if system.memory_mb is defined and (system.memory_mb | int) > 0
|
||||
else (vm_memory | default(0))
|
||||
else 0
|
||||
}}
|
||||
system_balloon_mb_effective: >-
|
||||
{{
|
||||
system.balloon_mb
|
||||
if system.balloon_mb is defined and (system.balloon_mb | int) > 0
|
||||
else (vm_ballo | default(''))
|
||||
else 0
|
||||
}}
|
||||
system_network_effective: >-
|
||||
{{
|
||||
system.network
|
||||
if system.network is defined and (system.network | string | length) > 0
|
||||
else (vm_nif | default(''))
|
||||
else ''
|
||||
}}
|
||||
system_vlan_effective: >-
|
||||
{{
|
||||
system.vlan
|
||||
if system.vlan is defined and (system.vlan | string | length) > 0
|
||||
else (vlan_name | default(''))
|
||||
else ''
|
||||
}}
|
||||
system_ip_effective: >-
|
||||
{{
|
||||
system.ip
|
||||
if system.ip is defined and (system.ip | string | length) > 0
|
||||
else (vm_ip | default(''))
|
||||
else ''
|
||||
}}
|
||||
system_prefix_effective: >-
|
||||
{{
|
||||
system.prefix
|
||||
if system.prefix is defined and (system.prefix | int) > 0
|
||||
else (vm_nms | default(''))
|
||||
else ''
|
||||
}}
|
||||
system_gateway_effective: >-
|
||||
{{
|
||||
system.gateway
|
||||
if system.gateway is defined and (system.gateway | string | length) > 0
|
||||
else (vm_gw | default(''))
|
||||
else ''
|
||||
}}
|
||||
system_dns_servers_effective: >-
|
||||
{{
|
||||
system.dns_servers
|
||||
if system.dns_servers is defined
|
||||
else (vm_dns | default([]))
|
||||
else []
|
||||
}}
|
||||
system_dns_search_effective: >-
|
||||
{{
|
||||
system.dns_search
|
||||
if system.dns_search is defined
|
||||
else (vm_dns_search | default([]))
|
||||
else []
|
||||
}}
|
||||
system_path_effective: >-
|
||||
{{
|
||||
system.path
|
||||
if system.path is defined and (system.path | string | length) > 0
|
||||
else (
|
||||
system.hypervisor_path
|
||||
if system.hypervisor_path is defined and (system.hypervisor_path | string | length) > 0
|
||||
else (vm_path | default(''))
|
||||
)
|
||||
else ''
|
||||
}}
|
||||
ansible.builtin.set_fact:
|
||||
hostname: "{{ system_name_effective }}"
|
||||
@@ -141,29 +133,21 @@
|
||||
if system_cfg.disks is defined
|
||||
else []
|
||||
}}
|
||||
system_disks_legacy: >-
|
||||
{{
|
||||
[ {'size': vm_size} ]
|
||||
if (system_disks_raw | length) == 0 and (vm_size is defined and (vm_size | float) > 0)
|
||||
else []
|
||||
}}
|
||||
system_disks_effective: >-
|
||||
{{
|
||||
system_disks_raw
|
||||
if (system_disks_raw | length) > 0
|
||||
else system_disks_legacy
|
||||
}}
|
||||
system_disk_device_prefix: >-
|
||||
{{
|
||||
'/dev/vd'
|
||||
if (install_type | default('')) == 'virtual' and (hypervisor | default('')) == 'libvirt'
|
||||
if (install_type | default('')) == 'virtual' and (hypervisor_type | default('')) == 'libvirt'
|
||||
else (
|
||||
'/dev/xvd'
|
||||
if (install_type | default('')) == 'virtual' and (hypervisor | default('')) == 'xen'
|
||||
if (install_type | default('')) == 'virtual' and (hypervisor_type | default('')) == 'xen'
|
||||
else (
|
||||
'/dev/sd'
|
||||
if (install_type | default('')) == 'virtual'
|
||||
and (hypervisor | default('')) in ['proxmox', 'vmware']
|
||||
and (hypervisor_type | default('')) in ['proxmox', 'vmware']
|
||||
else ''
|
||||
)
|
||||
)
|
||||
@@ -272,20 +256,3 @@
|
||||
ansible.builtin.set_fact:
|
||||
install_drive: "{{ system_disks_cfg[0].device }}"
|
||||
changed_when: false
|
||||
|
||||
- name: Set legacy vm_* aliases (compat)
|
||||
ansible.builtin.set_fact:
|
||||
vm_id: "{{ system_cfg.id }}"
|
||||
vm_cpus: "{{ system_cfg.cpus }}"
|
||||
vm_memory: "{{ system_cfg.memory_mb }}"
|
||||
vm_ballo: "{{ system_cfg.balloon_mb }}"
|
||||
vm_nif: "{{ system_cfg.network }}"
|
||||
vlan_name: "{{ system_cfg.vlan }}"
|
||||
vm_ip: "{{ system_cfg.ip }}"
|
||||
vm_nms: "{{ system_cfg.prefix }}"
|
||||
vm_gw: "{{ system_cfg.gateway }}"
|
||||
vm_dns: "{{ system_cfg.dns_servers }}"
|
||||
vm_dns_search: "{{ system_cfg.dns_search }}"
|
||||
vm_path: "{{ system_cfg.path }}"
|
||||
vm_size: "{{ (system_cfg.disks | default([]) | first | default({})).size | default(0) }}"
|
||||
changed_when: false
|
||||
|
||||
Reference in New Issue
Block a user