-
Notifications
You must be signed in to change notification settings - Fork 4
/
99_clean_env.yml
299 lines (281 loc) · 10.1 KB
/
99_clean_env.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
---
- name: "PLAY 1: CLEANUP NETWORK DEVICES"
connection: local
hosts: platforms_nxos, platforms_ios, platforms_eos
tags: [ios, nxos]
tasks:
- name: "TASK 1: NAUTOBOT >> REMOVE DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ inventory_hostname }}"
state: absent
- name: "TASK 2: DELETE SW1:2 DEVICE TO NAUTOBOT"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "sw-1:2"
device_type: "IOSv"
platform: IOS
serial: "ANSIBLE_FTW"
rack: MN_01
status: Active
device_role: "Switch"
site: "MINNESOTA01"
state: absent
delegate_to: localhost
run_once: yes
- name: "PLAY 2: DELETE VM INFO"
connection: local
hosts: localhost
vars:
vms:
- { name: gns3, address: 192.168.0.101/24 }
- { name: awx, address: 192.168.0.102/24 }
- { name: prometheus, address: 192.168.0.104/24 }
- { name: docker01, address: 192.168.0.105/24 }
- { name: docker02, address: 192.168.0.106/24 }
pves:
- { name: pve01, address: "192.168.0.254/24" }
- { name: pve02, address: "192.168.0.253/24" }
nautobot_headers:
Content-Type: "application/json"
Authorization: "token {{ lookup('env', 'NAUTOBOT_TOKEN') }}"
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
tasks:
- name: "TASK 1: SYS >> DELETE SOME VMs"
networktocode.nautobot.virtual_machine:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ item.name }}"
cluster: JoshV_Cluster1
state: absent
loop: "{{ vms }}"
- name: "TASK 2: SYS >> DELETE CLUSTER HOSTS"
networktocode.nautobot.device:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ item.name }}"
device_type: CustomServer
device_role: Server
site: minnesota01
state: absent
loop: "{{ pves }}"
- name: "TASK 3: SYS >> DELETE VM CLUSTER"
networktocode.nautobot.cluster:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: JoshV_Cluster1
cluster_type: Proxmox
state: absent
- name: "TASK 4: DELETE CLUSTER TYPE"
networktocode.nautobot.cluster_type:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: Proxmox
state: absent
- name: "PLAY 3: CLEANUP BASE NAUTOBOT"
hosts: localhost
connection: local
vars:
install_state: absent
tasks:
- name: "TASK 1: DELETE LOCAL CIRCUIT"
networktocode.nautobot.circuit:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
cid: my-circuit-id
state: "{{ install_state }}"
- name: "TASK 2: DELETE CIRCUIT TYPE"
networktocode.nautobot.circuit_type:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: Cable
state: "{{ install_state }}"
tags: [circuit]
- name: "TASK 3: DELETE CIRCUIT PROVIDER"
networktocode.nautobot.provider:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: Charter Spectrum
asn: 7843
account: AGOODPAYING_ONE
portal_url: http://spectrum.net
noc_contact: noc@spectrum.net
comments: "BEST I CAN GET"
state: "{{ install_state }}"
tags: [circuit]
- name: "TASK 4: DELETE PREFIXES"
networktocode.nautobot.prefix:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
family: 4
prefix: "{{ item.prefix }}"
site: "MINNESOTA01"
status: Active
description: "{{ item.desc }}"
is_pool: "{{ item.ispool }}"
state: "{{ install_state }}"
loop:
- { prefix: 10.50.50.0/24, desc: GNS3 Loopbacks, ispool: true }
- { prefix: 172.31.0.0/24, desc: GNS3 - DC, ispool: false }
- { prefix: 172.31.1.0/24, desc: GNS3 - DC Mgmt, ispool: false }
- { prefix: 192.168.0.0/24, desc: GNS3 Remote, ispool: false }
- { prefix: 192.0.2.0/24, desc: Example Network, ispool: true }
tags: [ipam]
- name: "TASK 5: DELETE AGGREGRATES"
networktocode.nautobot.aggregate:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
prefix: "{{ item.name }}"
description: "{{ item.desc }}"
rir: RFC1918
state: "{{ install_state }}"
loop:
- { name: "10.0.0.0/8", desc: RFC1918 - 10 }
- { name: "172.16.0.0/12", desc: RFC1918 - 172 }
- { name: "192.0.2.0/24", desc: RFC5735 - 192.0.2.0 }
- { name: "192.168.0.0/16", desc: RFC1918 - 192 }
tags: [ipam]
- name: "TASK 6: DELETE RFC1918 RIR"
networktocode.nautobot.rir:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: RFC1918
is_private: True
state: "{{ install_state }}"
tags: [ipam]
- name: "TASK 7: DELETE VLANS"
networktocode.nautobot.vlan:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "VLAN{{ item.vid }}"
vid: "{{ item.vid }}"
site: "MINNESOTA01"
description: "{{ item.desc }}"
state: "{{ install_state }}"
register: result
tags: [ipam]
loop:
- { vid: 100, desc: Demo VLAN }
- { vid: 200, desc: Primary VLAN }
- { vid: 300, desc: Secondary VLAN }
- name: "TASK 8: DELETE DEVICE ROLES"
networktocode.nautobot.device_role:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ item.name }}"
color: "{{ item.color }}"
vm_role: "{{ item.vmrole }}"
state: "{{ install_state }}"
loop:
- { name: Firewall, color: FF0000, vmrole: true }
- { name: Router, color: 000080, vmrole: true }
- { name: Switch, color: 008000, vmrole: true }
- { name: Server, color: "000000", vmrole: false }
- { name: VM, color: 00FFFF, vmrole: true }
- { name: Leaf, color: 008000, vmrole: false }
- { name: Spine, color: 0000FF, vmrole: false }
tags: [devices]
- name: "TASK 9: DELETE PLATFORMS"
networktocode.nautobot.platform:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ item.name }}"
slug: "{{ item.slug }}"
state: "{{ install_state }}"
loop:
- { name: EOS, slug: eos }
- { name: IOS, slug: ios }
- { name: IOS-XE, slug: ios-xe }
- { name: NXOS, slug: nxos }
- { name: Raspbian, slug: raspbian }
- { name: Ubuntu 18.04, slug: ubuntu1804 }
- { name: Ubuntu 16.04, slug: ubuntu1604 }
- { name: Ubuntu 20.04, slug: ubuntu2004 }
- { name: Windows 2012, slug: win2012 }
- { name: Windows 2016, slug: win2016 }
- { name: Windows 2019, slug: win2019 }
tags: [devices]
- name: "TASK 10: DELETE DEVICE TYPES"
networktocode.nautobot.device_type:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
model: "{{ item.model }}"
manufacturer: "{{ item.manufacturer }}"
slug: "{{ item.slug }}"
part_number: "{{ item.part_number }}"
u_height: 1
is_full_depth: "{{ item.full_depth }}"
state: "{{ install_state }}"
loop:
- model: "IOSv"
manufacturer: "Cisco"
slug: "iosv"
part_number: "iosv"
full_depth: False
- model: "nxosv"
manufacturer: "Cisco"
slug: "nxosv"
part_number: "nxosv"
full_depth: False
- model: "nx-osv-chassis-nx-osv-supervisor-module"
manufacturer: "Cisco"
slug: "nx-osv-chassis-nx-osv-supervisor-module"
part_number: "nx-osv-chassis-nx-osv-supervisor-module"
full_depth: False
- model: "CSR1000v"
manufacturer: "Cisco"
slug: "csr1000v"
part_number: "csr1000v"
full_depth: False
- model: "ASAv"
manufacturer: "Cisco"
slug: "asav"
part_number: "asav"
full_depth: False
- model: "CustomServer"
manufacturer: "CustomBuild"
slug: "customserver"
part_number: "home"
full_depth: True
- model: "vEOS"
manufacturer: "Arista"
slug: "veos"
part_number: "veos"
full_depth: False
tags: [devices]
- name: "TASK 11: DELETE MANUFACTURERS"
networktocode.nautobot.manufacturer:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "{{ item }}"
state: "{{ install_state }}"
loop:
- Arista
- Cisco
- CustomBuild
- Raspberry Pi
tags: [devices]
- name: "TASK 12: DELETE RACKS"
networktocode.nautobot.rack:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "MN_01"
site: "MINNESOTA01"
state: "{{ install_state }}"
tags: [sites, devices]
- name: "TASK 13: DELETE SITES"
networktocode.nautobot.site:
url: "{{ lookup('env', 'NAUTOBOT_URL') }}"
token: "{{ lookup('env', 'NAUTOBOT_TOKEN') }}"
name: "MINNESOTA01"
time_zone: America/Chicago
status: active
description: Josh's Home
contact_name: Josh V
contact_email: josh@josh-v.com
state: "{{ install_state }}"
register: site_setup
tags: [sites, devices]