summaryrefslogtreecommitdiffstats
path: root/ansible/deployment_poc/tasks/netbox_primaryip.yml
blob: 1b319dcf16fe562bf35b8c29d4d622f4661604e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
- 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