-
Notifications
You must be signed in to change notification settings - Fork 7
/
deploy_fabric.yaml
65 lines (58 loc) · 2.02 KB
/
deploy_fabric.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
# Run with ansible-playbook -i netbox_inventory.yml deploy_fabric.yaml -u ansible -k
- hosts: "all"
connection: network_cli
become: no
gather_facts: no
vars:
netbox_url: http://<your_netbox_url>
netbox_token: <your_netbox_token>
working_folder: results
tasks:
- name: Get all devices from NetBox
uri:
url: "{{ netbox_url }}/api/dcim/devices/"
method: GET
return_content: yes
headers:
accept: "application/json"
Authorization: "Token {{ netbox_token }}"
register: nb_all_devices
- name: Get device from NetBox
uri:
url: "{{ netbox_url }}/api/dcim/devices/?name={{ inventory_hostname }}"
method: GET
return_content: yes
headers:
accept: "application/json"
Authorization: "Token {{ netbox_token }}"
register: nb_device
- name: Get device interfaces from NetBox
uri:
url: "{{ netbox_url }}/api/dcim/interfaces/?device={{ inventory_hostname }}"
method: GET
return_content: yes
headers:
accept: "application/json"
Authorization: "Token {{ netbox_token }}"
register: nb_interfaces
- name: Get device IP addresses from NetBox
uri:
url: "{{ netbox_url }}/api/ipam/ip-addresses/?device={{ inventory_hostname }}"
method: GET
return_content: yes
headers:
accept: "application/json"
Authorization: "Token {{ netbox_token }}"
register: nb_ips
- name: Create temporary folder for {{ inventory_hostname }}
file:
dest: "{{ working_folder }}/{{ inventory_hostname }}"
state: directory
- name: Create configuration file for {{ inventory_hostname }}
template:
src: "templates/{{ platforms[0] }}.j2"
dest: "{{ working_folder }}/{{ inventory_hostname }}/{{ inventory_hostname }}.conf"
# - name: DEPLOY CONFIGURATION
# eos_config:
# src: "{{ working_folder }}/{{ inventory_hostname }}/{{ inventory_hostname }}.conf"