--- - name: "vmid {{ clone_result.vmid }}: getting config via proxmox api" set_fact: vm_config: "{{ lookup('url', config_url, validate_certs=False, headers=config_headers) }}" vars: config_url: "https://{{ proxmox_hostname }}:8006/api2/json/nodes/{{ proxmox_node }}/qemu/{{ clone_result.vmid }}/agent/network-get-interfaces" config_headers: Authorization: "PVEAPIToken={{ proxmox_username }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}" - name: "vmid {{ clone_result.vmid }}: extracting ipv4 address" set_fact: vm_ip: >- {{ vm_config['data']['result'] | map(attribute='ip-addresses') | flatten | selectattr("ip-address-type", "equalto", "ipv4") | selectattr("ip-address", "ne", "127.0.0.1") | map(attribute="ip-address") | first }} - name: "vmid {{ clone_result.vmid }}: ip address result" ansible.builtin.debug: msg: "vmid {{ clone_result.vmid }} ip address is {{ vm_ip }}" - name: "vmid {{ clone_result.vmid }}: set ip to {{ vm_ip }}" set_fact: ansible_host: "{{ vm_ip }}"