-
Notifications
You must be signed in to change notification settings - Fork 4
/
00_setup_nautobot_devices.yml
214 lines (202 loc) · 7.23 KB
/
00_setup_nautobot_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
---
- name: "PLAY 1: SETUP DEVICES WITHIN NAUTOBOT"
hosts: localhost
connection: local
vars:
install_state: present
tasks:
- name: "TASK 1: SETUP SITES"
networktocode.nautobot.site:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ site['name'] }}"
time_zone: "{{ site['time_zone'] }}"
status: "{{ site['status'] }}"
description: "{{ site['description'] }}"
contact_name: "{{ site['contact_name'] }}"
contact_email: "{{ site['contact_email'] }}"
validate_certs: False
register: site_setup
loop: "{{ sites }}"
loop_control:
loop_var: site
label: "{{ site['name'] }}"
tags: [sites, devices]
- name: "TASK 2: SETUP RACKS"
networktocode.nautobot.rack:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ rack['name'] }}"
site: "{{ rack['site'] }}"
status: "{{ rack['status'] }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ racks }}"
loop_control:
loop_var: rack
label: "{{ rack['name'] }}"
tags: [sites, devices]
- name: "TASK 3: SETUP MANUFACTURERS"
networktocode.nautobot.manufacturer:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ manufacturer }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ manufacturers }}"
loop_control:
loop_var: manufacturer
tags: [devices]
- name: "TASK 4: SETUP DEVICE TYPES"
networktocode.nautobot.device_type:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
model: "{{ device_type.model }}"
manufacturer: "{{ device_type.manufacturer }}"
slug: "{{ device_type.slug }}"
part_number: "{{ device_type.part_number }}"
u_height: 1
is_full_depth: "{{ device_type.full_depth }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ device_types }}"
loop_control:
loop_var: device_type
label: "{{ device_type['model'] }}"
tags: [devices]
- name: "TASK 5: SETUP PLATFORMS"
networktocode.nautobot.platform:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ platform.name }}"
slug: "{{ platform.slug }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ platforms }}"
loop_control:
loop_var: platform
label: "{{ platform['name'] }}"
tags: [devices]
- name: "TASK 6: SETUP DEVICE ROLES"
networktocode.nautobot.device_role:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ device_role.name }}"
color: "{{ device_role.color }}"
vm_role: "{{ device_role.vmrole }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ device_roles }}"
loop_control:
loop_var: device_role
label: "{{ device_role['name'] }}"
tags: [devices]
- name: "TASK 7: SETUP VLANS"
networktocode.nautobot.vlan:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "VLAN{{ vlan.vid }}"
vid: "{{ vlan.vid }}"
site: "MINNESOTA01"
description: "{{ vlan.desc }}"
status: "Active"
state: "{{ install_state }}"
validate_certs: False
register: result
loop: "{{ vlans }}"
loop_control:
loop_var: vlan
label: "{{ vlan['vid'] }}"
tags: [ipam]
- name: "TASK 8: SETUP RFC1918 RIR"
networktocode.nautobot.rir:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: RFC1918
is_private: True
state: "{{ install_state }}"
validate_certs: False
loop: "{{ rirs }}"
loop_control:
loop_var: rir
label: "{{ rir['name'] }}"
tags: [ipam]
- name: "TASK 8: SETUP AGGREGRATES"
networktocode.nautobot.aggregate:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
prefix: "{{ aggregate.name }}"
description: "{{ aggregate.desc }}"
rir: "{{ aggregate.rir }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ aggregates }}"
loop_control:
loop_var: aggregate
label: "{{ aggregate['name'] }}"
tags: [ipam]
- name: "TASK 9: SETUP PREFIXES"
networktocode.nautobot.prefix:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
family: 4
prefix: "{{ prefix.prefix }}"
site: "{{ prefix.site | default(omit) }}"
status: "{{ prefix.status | default('Active') }}"
description: "{{ prefix.desc }}"
is_pool: "{{ prefix.ispool }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ prefixes }}"
loop_control:
loop_var: prefix
label: "{{ prefix['prefix'] }}"
tags: [ipam]
- name: "TASK 10: SETUP CIRCUIT PROVIDER"
networktocode.nautobot.provider:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ circuit_provider['name'] }}"
asn: "{{ circuit_provider['asn'] }}"
account: "{{ circuit_provider['account'] }}"
portal_url: "{{ circuit_provider['portal_url'] }}"
noc_contact: "{{ circuit_provider['noc_contact'] }}"
comments: "{{ circuit_provider['comments'] }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ circuit_providers }}"
loop_control:
loop_var: circuit_provider
label: "{{ circuit_provider['name'] }}"
tags: [circuit]
- name: Create type within Nautobot with only required information
networktocode.nautobot.circuit_type:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ circuit_type['name'] }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ circuit_types }}"
loop_control:
loop_var: circuit_type
label: "{{ circuit_type['name'] }}"
tags: [circuit]
- name: "CREATE LOCAL CIRCUIT"
networktocode.nautobot.circuit:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
cid: "{{ circuit['cid'] }}"
provider: "{{ circuit['provider'] }}"
circuit_type: "{{ circuit['circuit_type'] }}"
status: "{{ circuit['status'] }}"
install_date: "{{ circuit['install_date'] }}"
commit_rate: "{{ circuit['commit_rate'] }}"
description: "{{ circuit['description'] }}"
comments: "{{ circuit['comments'] }}"
state: "{{ install_state }}"
validate_certs: False
loop: "{{ circuits }}"
loop_control:
loop_var: circuit
label: "{{ circuit['cid'] }}"
tags: [circuit]