--- - name: Get next available VMID from Proxmox API ansible.builtin.uri: url: "https://{{ proxmox_api_host }}:8006/api2/json/cluster/nextid" method: GET headers: Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}" validate_certs: false register: nextid_response - name: Set VMID fact ansible.builtin.set_fact: next_vmid: "{{ nextid_response.json.data }}" - name: Clone LXC from template community.proxmox.proxmox: api_host: "{{ proxmox_api_host }}" api_user: "{{ proxmox_api_user }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" node: "{{ target_node }}" clone: "{{ lxc_template_id }}" hostname: "{{ vm_hostname }}" vmid: "{{ next_vmid }}" full: true storage: "local-lvm" timeout: 300 register: cloned_lxc - name: Configure LXC resources community.proxmox.proxmox: api_host: "{{ proxmox_api_host }}" api_user: "{{ proxmox_api_user }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" node: "{{ target_node }}" vmid: "{{ next_vmid }}" cores: "{{ cpu_cores }}" memory: "{{ ram_gb | int * 1024 }}" netif: net0: "name=eth0,bridge=vmbr0,ip=dhcp" state: present - name: Start the LXC container community.proxmox.proxmox: api_host: "{{ proxmox_api_host }}" api_user: "{{ proxmox_api_user }}" api_token_id: "{{ proxmox_api_token_id }}" api_token_secret: "{{ proxmox_api_token_secret }}" node: "{{ target_node }}" vmid: "{{ next_vmid }}" state: started - name: Set VMID fact for later use ansible.builtin.set_fact: created_vmid: "{{ next_vmid }}"