system/ansible/deployment_poc/tasks/netbox_primaryip.yml

21 lines
592 B
YAML
Raw Normal View History

---
- name: Register IP address object ID #only for new addresses, existing ones have ipid set in _evaluate_ip.yml
set_fact:
ipid: "{{ nb_ip_3.json.id }}"
when: "ip_address_type|string == 'new'"
- name: Set primary IPv4 address
ansible.builtin.uri:
url: "{{ endpoint }}/virtualization/virtual-machines/{{ id }}/"
client_cert: "{{ cert }}"
client_key: "{{ key }}"
method: PATCH
return_content: yes
headers:
Accept: application/json
Authorization: "Token {{ token }}"
body_format: json
body: ' {"primary_ip4": {{ ipid }}}'
delegate_to: localhost