system/ansible/deployment_poc/tasks/netbox_init_interface.yml

21 lines
753 B
YAML
Raw Permalink Normal View History

---
- name: Create VM interface objects
ansible.builtin.uri:
url: "{{ endpoint }}/virtualization/interfaces/"
client_cert: "{{ cert }}"
client_key: "{{ key }}"
method: POST
return_content: yes
status_code:
- 201
- 400 #interface name already exists. is there an elegant way to limit 400 to this particular case? regex parsing the response text for "The fields virtual_machine, name must make a unique set." would be ugly.
headers:
Accept: application/json
Authorization: "Token {{ token }}"
body_format: json
body: ' {"virtual_machine": {{ id }}, "name": "eth0", "enabled": true, "mac_address": "{{ mac_address }}", "mode": "access"}'
register: nb_interface_1
delegate_to: localhost
#no_log: true