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