--- - name: Deploy VM on Proxmox delegate_to: localhost vars: virtualization_proxmox_scsi: >- {%- set out = {} -%} {%- for disk in system_cfg.disks -%} {%- set _ = out.update({ 'scsi' ~ loop.index0: hypervisor_cfg.storage ~ ':' ~ (disk.size | int) }) -%} {%- endfor -%} {{ out }} community.proxmox.proxmox_kvm: api_host: "{{ hypervisor_cfg.url }}" api_user: "{{ hypervisor_cfg.username }}" api_password: "{{ hypervisor_cfg.password }}" ciuser: "{{ system_cfg.user.name }}" cipassword: "{{ system_cfg.user.password }}" ciupgrade: false node: "{{ hypervisor_cfg.host }}" vmid: "{{ system_cfg.id }}" name: "{{ hostname }}" cpu: host cores: "{{ system_cfg.cpus }}" memory: "{{ system_cfg.memory }}" balloon: "{{ system_cfg.balloon if system_cfg.balloon is defined and system_cfg.balloon | 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: "{{ virtualization_proxmox_scsi }}" efidisk0: efitype: 4m format: raw pre_enrolled_keys: false storage: "{{ hypervisor_cfg.storage }}" tpmstate0: >- {{ {'storage': hypervisor_cfg.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_cfg.storage }}:cloudinit" net: net0: >- virtio,bridge={{ system_cfg.network.bridge }}{% if system_cfg.network.vlan is defined and system_cfg.network.vlan | string | length > 0 %},tag={{ system_cfg.network.vlan }}{% endif %} ipconfig: ipconfig0: >- {{ 'ip=' ~ system_cfg.network.ip ~ '/' ~ system_cfg.network.prefix ~ (',gw=' ~ system_cfg.network.gateway if system_cfg.network.gateway is defined and system_cfg.network.gateway | length else '') if system_cfg.network.ip is defined and system_cfg.network.ip | string | length else 'ip=dhcp' }} nameservers: "{{ system_cfg.network.dns.servers if system_cfg.network.dns.servers | length else omit }}" searchdomains: "{{ system_cfg.network.dns.search if system_cfg.network.dns.search | length else omit }}" onboot: true state: present - name: Start VM on Proxmox delegate_to: localhost community.proxmox.proxmox_kvm: api_host: "{{ hypervisor_cfg.url }}" api_user: "{{ hypervisor_cfg.username }}" api_password: "{{ hypervisor_cfg.password }}" node: "{{ hypervisor_cfg.host }}" name: "{{ hostname }}" vmid: "{{ system_cfg.id }}" state: started register: virtualization_proxmox_start_result - name: Set VM created fact ansible.builtin.set_fact: virtualization_vm_created_in_run: true when: virtualization_proxmox_start_result is defined and virtualization_proxmox_start_result.changed | bool