refactor(vars): add system/hypervisor dict inputs
This commit is contained in:
@@ -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 if vm_dns is defined else '' %}
|
||||
{% set has_static = system_cfg.ip is defined and system_cfg.ip | string | length %}
|
||||
{% set dns_value = system_cfg.dns_servers if system_cfg.dns_servers is defined else '' %}
|
||||
{% 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 if vm_dns_search is defined else '' %}
|
||||
{% set search_value = system_cfg.dns_search if system_cfg.dns_search is defined else '' %}
|
||||
{% 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 }}"
|
||||
{% if vm_gw is defined and vm_gw | length %}
|
||||
gateway4: "{{ vm_gw }}"
|
||||
- "{{ system_cfg.ip }}/{{ system_cfg.prefix }}"
|
||||
{% if system_cfg.gateway is defined and system_cfg.gateway | string | length %}
|
||||
gateway4: "{{ system_cfg.gateway }}"
|
||||
{% 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 (system_cfg.dns_servers is defined and system_cfg.dns_servers | length) or (system_cfg.dns_search is defined and system_cfg.dns_search | length) %}
|
||||
dhcp4-overrides:
|
||||
{% if vm_dns is defined and vm_dns | length %}
|
||||
{% if system_cfg.dns_servers is defined and system_cfg.dns_servers | length %}
|
||||
use-dns: false
|
||||
{% endif %}
|
||||
{% if vm_dns_search is defined and vm_dns_search | length %}
|
||||
{% if system_cfg.dns_search is defined and system_cfg.dns_search | length %}
|
||||
use-domains: false
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<domain type='kvm'>
|
||||
<name>{{ hostname }}</name>
|
||||
<memory>{{ vm_memory | int * 1024 }}</memory>
|
||||
{% if vm_ballo is defined and vm_ballo | int > 0 %}<currentMemory>{{ vm_ballo | int * 1024 }}</currentMemory>{% endif %}
|
||||
<vcpu placement='static'>{{ vm_cpus }}</vcpu>
|
||||
<memory>{{ system_cfg.memory_mb | int * 1024 }}</memory>
|
||||
{% if system_cfg.balloon_mb is defined and system_cfg.balloon_mb | int > 0 %}<currentMemory>{{ system_cfg.balloon_mb | int * 1024 }}</currentMemory>{% endif %}
|
||||
<vcpu placement='static'>{{ system_cfg.cpus }}</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine="pc-q35-8.0">hvm</type>
|
||||
<bootmenu enable='no'/>
|
||||
@@ -22,11 +22,13 @@
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
{% for disk in virtualization_libvirt_disks | default([]) %}
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='qcow2'/>
|
||||
<source file='{{ virtualization_libvirt_disk_path }}'/>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
<driver name='qemu' type='{{ disk.format }}'/>
|
||||
<source file='{{ disk.path }}'/>
|
||||
<target dev='{{ disk.target }}' bus='{{ disk.bus }}'/>
|
||||
</disk>
|
||||
{% endfor %}
|
||||
<disk type="file" device="cdrom">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="{{ boot_iso }}"/>
|
||||
|
||||
Reference in New Issue
Block a user