--- - name: Deploy VM on Proxmox delegate_to: localhost vars: virtualization_dns_value: "{{ vm_dns if vm_dns is defined else '' }}" virtualization_dns_list_raw: >- {{ virtualization_dns_value if virtualization_dns_value is iterable and virtualization_dns_value is not string else virtualization_dns_value.split(',') }} virtualization_dns_list: >- {{ virtualization_dns_list_raw | map('trim') | reject('equalto', '') | list }} virtualization_search_value: "{{ vm_dns_search if vm_dns_search is defined else '' }}" virtualization_search_list_raw: >- {{ virtualization_search_value if virtualization_search_value is iterable and virtualization_search_value is not string else virtualization_search_value.split(',') }} virtualization_search_list: >- {{ virtualization_search_list_raw | map('trim') | reject('equalto', '') | list }} community.proxmox.proxmox_kvm: api_host: "{{ hypervisor_url }}" api_user: "{{ hypervisor_username }}" api_password: "{{ hypervisor_password }}" ciuser: "{{ user_name }}" cipassword: "{{ user_password }}" ciupgrade: false node: "{{ hypervisor_node }}" vmid: "{{ vm_id }}" name: "{{ hostname }}" cpu: host cores: "{{ vm_cpus }}" memory: "{{ vm_memory }}" balloon: "{{ vm_ballo if vm_ballo is defined and vm_ballo | int > 0 else omit }}" numa_enabled: true hotplug: network,disk update: "{{ virtualization_tpm2_enabled | bool }}" update_unsafe: "{{ virtualization_tpm2_enabled | bool }}" bios: ovmf machine: "{{ 'q35' if virtualization_tpm2_enabled | bool else omit }}" boot: ac scsihw: virtio-scsi-single scsi: scsi0: "{{ hypervisor_storage }}:{{ vm_size }}" efidisk0: efitype: 4m format: raw pre_enrolled_keys: false storage: "{{ hypervisor_storage }}" tpmstate0: >- {{ {'storage': hypervisor_storage, 'version': '2.0'} if virtualization_tpm2_enabled | bool else omit }} ide: ide0: "{{ boot_iso }},media=cdrom" ide1: "{{ rhel_iso + ',media=cdrom' if rhel_iso is defined and rhel_iso | length > 0 else omit }}" ide2: "{{ hypervisor_storage }}:cloudinit" net: net0: virtio,bridge={{ vm_nif }}{% if vlan_name is defined and vlan_name | length > 0 %},tag={{ vlan_name }}{% endif %} ipconfig: ipconfig0: >- {{ 'ip=' ~ vm_ip ~ '/' ~ vm_nms ~ (',gw=' ~ vm_gw if vm_gw is defined and vm_gw | length else '') if vm_ip is defined and vm_ip | length else 'ip=dhcp' }} nameservers: "{{ virtualization_dns_list if virtualization_dns_list | length else omit }}" searchdomains: "{{ virtualization_search_list if virtualization_search_list | length else omit }}" onboot: true state: present - name: Start VM on Proxmox delegate_to: localhost community.proxmox.proxmox_kvm: api_host: "{{ hypervisor_url }}" api_user: "{{ hypervisor_username }}" api_password: "{{ hypervisor_password }}" node: "{{ hypervisor_node }}" name: "{{ hostname }}" vmid: "{{ vm_id }}" state: started