system/ansible/deployment_poc/tasks/netbox_init_ip.yml

21 lines
627 B
YAML
Raw Normal View History

---
- name: Create IP address object
ansible.builtin.uri:
url: "{{ endpoint }}/ipam/ip-addresses/"
client_cert: "{{ cert }}"
client_key: "{{ key }}"
method: POST
return_content: yes
status_code:
- 201
- 400
headers:
Accept: application/json
Authorization: "Token {{ token }}"
body_format: json
body: ' {"address": "{{ ip_address_cidr }}", "tenant": 1, "status": "active", "assigned_object_type": "virtualization.vminterface", "assigned_object_id": {{ ifid }}, "dns_name": "{{ vm_fqdn }}"}'
register: nb_ip_3
when: "ip_address_type|string == 'new'"
delegate_to: localhost