diff options
author | heqnx <root@heqnx.com> | 2025-07-11 21:55:20 +0300 |
---|---|---|
committer | heqnx <root@heqnx.com> | 2025-07-11 21:55:20 +0300 |
commit | 6ec2eb61a02f9e55ef5b8d22a5ca61ca53ca05e7 (patch) | |
tree | d975569e35991a02c73706ce81c0fc1f2e92405c /ansible/roles/proxmox_vm/tasks/get_ip.yaml | |
parent | 742fa0d51cd384ea3d856438861bb86738fdabb8 (diff) | |
download | ansible-active-directory-range-6ec2eb61a02f9e55ef5b8d22a5ca61ca53ca05e7.tar.gz ansible-active-directory-range-6ec2eb61a02f9e55ef5b8d22a5ca61ca53ca05e7.zip |
added initial setup for domain controller
Diffstat (limited to 'ansible/roles/proxmox_vm/tasks/get_ip.yaml')
-rw-r--r-- | ansible/roles/proxmox_vm/tasks/get_ip.yaml | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ansible/roles/proxmox_vm/tasks/get_ip.yaml b/ansible/roles/proxmox_vm/tasks/get_ip.yaml new file mode 100644 index 0000000..584b44d --- /dev/null +++ b/ansible/roles/proxmox_vm/tasks/get_ip.yaml @@ -0,0 +1,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 }}" |