blob: 584b44d7e099154157b08d9f730f145e3c41cb6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
---
- 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 }}"
|