-
Notifications
You must be signed in to change notification settings - Fork 4
/
01_setup_devices.yml
219 lines (203 loc) · 7.37 KB
/
01_setup_devices.yml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
# Playbook to setup devices from a static inventory list
- name: "PLAY 1: SETUP vEOS"
connection: network_cli
hosts: eos
vars:
ssl_verify: True
tasks:
- name: "TASK 1: EOS >> GATHER FACTS FROM DEVICE"
eos_facts:
gather_subset: "!config"
- name: "TASK 2: NAUTOBOT >> ADD DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
name: "{{ inventory_hostname }}"
device_type: "{{ ansible_facts['net_model'] }}"
platform: EOS
serial: "{{ ansible_facts['net_serialnum'] }}"
rack: MN_01
position: "{{ rack_location }}"
face: "Front"
status: Active
device_role: "Leaf"
site: "MINNESOTA01"
custom_fields:
code_version: "{{ ansible_facts['net_version'] }}"
- name: "TASK 3: NAUTOBOT >> Add temporary interface"
networktocode.nautobot.device_interface:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
device: "{{ inventory_hostname }}"
name: Temporary_Interface
type: Virtual
state: present
- name: "TASK 4: NAUTOBOT >> ADD IP ADDRESS OF ANSIBLE HOST"
networktocode.nautobot.ip_address:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
family: 4
address: "{{ ansible_host }}/24"
status: active
assigned_object:
name: Temporary_Interface
device: "{{ inventory_hostname }}"
- name: "TASK 5: NAUTOBOT >> ADD DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
name: "{{ inventory_hostname }}"
device_type: "{{ ansible_facts['net_model'] }}"
platform: EOS
serial: "{{ ansible_facts['net_serialnum'] }}"
rack: MN_01
face: "Front"
status: Active
site: "MINNESOTA01"
primary_ip4: "{{ ansible_host }}/24"
- name: "PLAY 2: ADD IOS"
connection: network_cli
hosts: routers, switches
vars:
ssl_verify: True
tasks:
- name: "TASK 1: IOS >> GATHER FACTS FROM DEVICE"
ios_facts:
gather_subset: "!config"
- name: "TASK 2: NAUTOBOT >> ADD DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
name: "{{ inventory_hostname }}"
device_type: "{{ ansible_facts['net_model'] }}"
platform: IOS
serial: "{{ ansible_facts['net_serialnum'] }}"
rack: MN_01
face: "Front"
status: Active
device_role: "{{ inventory_hostname | get_role_from_hostname }}"
site: "MINNESOTA01"
# custom_fields:
# code_version: "{{ ansible_facts['net_version'] }}"
- name: "TASK 3: Add temporary interface"
networktocode.nautobot.device_interface:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
device: "{{ inventory_hostname }}"
name: Temporary_Interface
type: Virtual
state: present
# TODO: Add a module to lookup inventory hostname if using only hostnames
- name: "TASK 4: ADD IP ADDRESS OF ANSIBLE HOST"
networktocode.nautobot.ip_address:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
address: "{{ ansible_host }}/24"
status: active
assigned_object:
name: Temporary_Interface
device: "{{ inventory_hostname }}"
- name: "TASK 5: ADD DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
name: "{{ inventory_hostname }}"
device_type: "{{ ansible_facts['net_model'] }}"
platform: IOS
serial: "{{ ansible_facts['net_serialnum'] }}"
rack: MN_01
face: "Front"
status: Active
device_role: "{{ inventory_hostname | get_role_from_hostname }}"
site: "MINNESOTA01"
primary_ip4: "{{ ansible_host }}/24"
- name: "PLAY 3: ADD NXOS"
connection: network_cli
hosts: nxos
tags: [nxos]
vars:
ssl_verify: True
tasks:
- name: "TASK 1: NXOS >> GATHER FACTS FROM DEVICE"
nxos_facts:
gather_subset: "!config"
- name: "TASK 2: ADD DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
name: "{{ inventory_hostname }}"
device_type: "{{ ansible_facts['net_model'] }}"
platform: NXOS
serial: "{{ ansible_facts['net_serialnum'] }}"
rack: MN_01
face: "Front"
status: Active
device_role: "{{ inventory_hostname | get_role_from_hostname }}"
site: "MINNESOTA01"
custom_fields:
code_version: "{{ ansible_facts['net_version'] }}"
- name: "TASK 3: Add temporary interface"
networktocode.nautobot.device_interface:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
device: "{{ inventory_hostname }}"
name: Temporary_Interface
type: Virtual
state: present
- name: "TASK 4: ADD IP ADDRESS OF ANSIBLE HOST"
networktocode.nautobot.ip_address:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
family: 4
address: "{{ ansible_host }}/24"
status: active
assigned_object:
name: Temporary_Interface
device: "{{ inventory_hostname }}"
- name: "TASK 5: ADD DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
name: "{{ inventory_hostname }}"
device_type: "{{ ansible_facts['net_model'] }}"
platform: NXOS
serial: "{{ ansible_facts['net_serialnum'] }}"
rack: MN_01
face: "Front"
status: Active
device_role: "{{ inventory_hostname | get_role_from_hostname }}"
site: "MINNESOTA01"
primary_ip4: "{{ ansible_host }}/24"
- name: "PLAY 4: Add BLANK NODE"
connection: local
hosts: localhost
tags: [setup_demo]
vars:
ssl_verify: True
tasks:
- name: "TASK 1: ADD DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
validate_certs: "{{ ssl_verify }}"
name: "sw-1:2"
device_type: "IOSv"
platform: IOS
serial: "ANSIBLE_FTW"
rack: MN_01
status: Active
device_role: "Switch"
site: "MINNESOTA01"