Normalize user-facing defaults
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
---
|
||||
virtualization_tpm2_enabled: >-
|
||||
{{
|
||||
(partitioning_luks_enabled | default(luks_enabled | default(false)) | bool)
|
||||
and (partitioning_luks_auto_decrypt | default(luks_auto_decrypt | default(true)) | bool)
|
||||
(partitioning_luks_enabled | bool)
|
||||
and (partitioning_luks_auto_decrypt | bool)
|
||||
and (
|
||||
(partitioning_luks_auto_decrypt_method | default(luks_auto_decrypt_method | default('tpm2')))
|
||||
| lower
|
||||
(partitioning_luks_auto_decrypt_method | lower)
|
||||
== 'tpm2'
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
- name: Set libvirt image paths
|
||||
delegate_to: localhost
|
||||
vars:
|
||||
virtualization_libvirt_image_dir_value: "{{ vm_path | default('/var/lib/libvirt/images') }}"
|
||||
virtualization_libvirt_image_dir_value: >-
|
||||
{{ vm_path if vm_path | length > 0 else '/var/lib/libvirt/images' }}
|
||||
ansible.builtin.set_fact:
|
||||
virtualization_libvirt_image_dir: "{{ virtualization_libvirt_image_dir_value }}"
|
||||
virtualization_libvirt_disk_path: >-
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: Deploy VM on Proxmox
|
||||
delegate_to: localhost
|
||||
vars:
|
||||
virtualization_dns_value: "{{ vm_dns | default('') }}"
|
||||
virtualization_dns_value: "{{ vm_dns }}"
|
||||
virtualization_dns_list_raw: >-
|
||||
{{
|
||||
virtualization_dns_value
|
||||
@@ -11,7 +11,7 @@
|
||||
}}
|
||||
virtualization_dns_list: >-
|
||||
{{ virtualization_dns_list_raw | map('trim') | reject('equalto', '') | list }}
|
||||
virtualization_search_value: "{{ vm_dns_search | default('') }}"
|
||||
virtualization_search_value: "{{ vm_dns_search }}"
|
||||
virtualization_search_list_raw: >-
|
||||
{{
|
||||
virtualization_search_value
|
||||
@@ -33,7 +33,7 @@
|
||||
cpu: host
|
||||
cores: "{{ vm_cpus }}"
|
||||
memory: "{{ vm_memory }}"
|
||||
balloon: "{{ vm_ballo | default(omit) }}"
|
||||
balloon: "{{ vm_ballo if vm_ballo | int > 0 else omit }}"
|
||||
numa_enabled: true
|
||||
hotplug: network,disk
|
||||
update: "{{ virtualization_tpm2_enabled | bool }}"
|
||||
@@ -57,16 +57,16 @@
|
||||
}}
|
||||
ide:
|
||||
ide0: "{{ boot_iso }},media=cdrom"
|
||||
ide1: "{{ rhel_iso + ',media=cdrom' if rhel_iso is defined else omit }}"
|
||||
ide1: "{{ rhel_iso + ',media=cdrom' if rhel_iso | length > 0 else omit }}"
|
||||
ide2: "{{ hypervisor_storage }}:cloudinit"
|
||||
net:
|
||||
net0: virtio,bridge={{ vm_nif }}{% if vlan_name is defined and vlan_name %},tag={{ vlan_name }}{% endif %}
|
||||
net0: virtio,bridge={{ vm_nif }}{% if vlan_name | length > 0 %},tag={{ vlan_name }}{% endif %}
|
||||
ipconfig:
|
||||
ipconfig0: >-
|
||||
{{
|
||||
'ip=' ~ vm_ip ~ '/' ~ (vm_nms | default(24))
|
||||
~ (',gw=' ~ vm_gw if vm_gw is defined and vm_gw | length else '')
|
||||
if vm_ip is defined and vm_ip | length
|
||||
'ip=' ~ vm_ip ~ '/' ~ vm_nms
|
||||
~ (',gw=' ~ vm_gw if vm_gw | length else '')
|
||||
if vm_ip | length
|
||||
else 'ip=dhcp'
|
||||
}}
|
||||
nameservers: "{{ virtualization_dns_list if virtualization_dns_list | length else omit }}"
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
validate_certs: false
|
||||
datacenter: "{{ hypervisor_datacenter }}"
|
||||
cluster: "{{ hypervisor_cluster }}"
|
||||
folder: "{{ vm_path | default(omit) }}"
|
||||
folder: "{{ vm_path if vm_path | length > 0 else omit }}"
|
||||
name: "{{ hostname }}"
|
||||
guest_id: otherLinux64Guest
|
||||
annotation: |
|
||||
{{ note | default('') }}
|
||||
{{ note }}
|
||||
state: "{{ 'poweredoff' if virtualization_tpm2_enabled | bool else 'poweredon' }}"
|
||||
disk:
|
||||
- size_gb: "{{ vm_size }}"
|
||||
@@ -41,12 +41,12 @@
|
||||
"state": "present",
|
||||
"type": "iso",
|
||||
"iso_path": rhel_iso
|
||||
} ] if rhel_iso is defined and rhel_iso|length > 0 else [] )
|
||||
} ] if rhel_iso | length > 0 else [] )
|
||||
}}
|
||||
networks:
|
||||
- name: "{{ vm_nif }}"
|
||||
type: dhcp
|
||||
vlan: "{{ vlan_name | default(omit) }}"
|
||||
vlan: "{{ vlan_name if vlan_name | length > 0 else omit }}"
|
||||
|
||||
- name: Ensure vTPM2 is enabled when required
|
||||
when: virtualization_tpm2_enabled | bool
|
||||
@@ -57,7 +57,7 @@
|
||||
password: "{{ hypervisor_password }}"
|
||||
validate_certs: false
|
||||
datacenter: "{{ hypervisor_datacenter }}"
|
||||
folder: "{{ vm_path | default(omit) }}"
|
||||
folder: "{{ vm_path if vm_path | length > 0 else omit }}"
|
||||
name: "{{ hostname }}"
|
||||
state: present
|
||||
|
||||
|
||||
@@ -4,27 +4,27 @@ network:
|
||||
id0:
|
||||
match:
|
||||
macaddress: "{{ virtualization_mac_address }}"
|
||||
{% set has_static = vm_ip is defined and vm_ip | length %}
|
||||
{% set dns_value = vm_dns | default('') %}
|
||||
{% set has_static = vm_ip | length %}
|
||||
{% set dns_value = vm_dns %}
|
||||
{% set dns_list_raw = dns_value if dns_value is iterable and dns_value is not string else dns_value.split(',') %}
|
||||
{% set dns_list = dns_list_raw | map('trim') | reject('equalto', '') | list %}
|
||||
{% set search_value = vm_dns_search | default('') %}
|
||||
{% set search_value = vm_dns_search %}
|
||||
{% set search_list_raw = search_value if search_value is iterable and search_value is not string else search_value.split(',') %}
|
||||
{% set search_list = search_list_raw | map('trim') | reject('equalto', '') | list %}
|
||||
{% if has_static %}
|
||||
addresses:
|
||||
- "{{ vm_ip }}/{{ vm_nms | default(24) }}"
|
||||
{% if vm_gw is defined and vm_gw | length %}
|
||||
- "{{ vm_ip }}/{{ vm_nms }}"
|
||||
{% if vm_gw | length %}
|
||||
gateway4: "{{ vm_gw }}"
|
||||
{% endif %}
|
||||
{% else %}
|
||||
dhcp4: true
|
||||
{% if (vm_dns is defined and vm_dns | length) or (vm_dns_search is defined and vm_dns_search | length) %}
|
||||
{% if (vm_dns | length) or (vm_dns_search | length) %}
|
||||
dhcp4-overrides:
|
||||
{% if vm_dns is defined and vm_dns | length %}
|
||||
{% if vm_dns | length %}
|
||||
use-dns: false
|
||||
{% endif %}
|
||||
{% if vm_dns_search is defined and vm_dns_search | length %}
|
||||
{% if vm_dns_search | length %}
|
||||
use-domains: false
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<domain type='kvm'>
|
||||
<name>{{ hostname }}</name>
|
||||
<memory>{{ vm_memory | int * 1024 }}</memory>
|
||||
{% if vm_ballo is defined %}<currentMemory>{{ vm_ballo | int * 1024 }}</currentMemory>{% endif %}
|
||||
{% if vm_ballo | int > 0 %}<currentMemory>{{ vm_ballo | int * 1024 }}</currentMemory>{% endif %}
|
||||
<vcpu placement='static'>{{ vm_cpus }}</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine="pc-q35-8.0">hvm</type>
|
||||
@@ -37,7 +37,7 @@
|
||||
<source file="{{ virtualization_libvirt_cloudinit_path }}"/>
|
||||
<target dev="sdb" bus="sata"/>
|
||||
</disk>
|
||||
{% if rhel_iso is defined %}
|
||||
{% if rhel_iso | length > 0 %}
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="{{ rhel_iso }}"/>
|
||||
@@ -49,7 +49,7 @@
|
||||
<source network='default'/>
|
||||
<model type='virtio'/>
|
||||
</interface>
|
||||
{% if virtualization_tpm2_enabled | default(false) %}
|
||||
{% if virtualization_tpm2_enabled %}
|
||||
<tpm model='tpm-crb'>
|
||||
<backend type='emulator' version='2.0'/>
|
||||
</tpm>
|
||||
|
||||
Reference in New Issue
Block a user