blob: f974898ec701eec397f224bf536847af48d38ed2 [file] [log] [blame]
David K. Bainbridgea677d4e2016-09-11 20:01:32 -07001---
2- name: Ensure Prerequisites
3 apt:
4 name: "{{ item }}"
5 state: present
6 with_items:
7 - python-ethtool=0.7*
8
David K. Bainbridgea677d4e2016-09-11 20:01:32 -07009- name: Establish Interface Lists
10 set_fact:
11 reboot_required: false
12 fabric_iface_list: []
David K. Bainbridge603ee542016-10-04 21:11:05 -070013 fabric_iface_excluded_list: []
14 management_iface_list: []
15 management_iface_excluded_list: []
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070016 changed_when: false
17
David K. Bainbridge603ee542016-10-04 21:11:05 -070018- name: Explicitly Ignore External and Specified Interfaces From Fabric
19 set_fact:
20 ignore_names_combined: "{{ compute_node.interfaces.external }},{{ compute_node.fabric.ignore.names }}"
21 when:
22 - compute_node.interfaces.external
23 - compute_node.fabric.ignore.names is defined and compute_node.fabric.ignore.names != omit
24 changed_when: false
25
26- name: Ignore External Interface From Fabric
27 set_fact:
28 ignore_names_combined: "{{ compute_node.interfaces.external }}"
29 when:
30 - compute_node.interfaces.external
31 - compute_node.fabric.ignore.names is not defined or compute_node.fabric.ignore.names == omit
32 changed_when: false
33
34- name: Explicity Ingnore Specified Interfaces From Fabric
35 set_fact:
36 ignore_names_combined: "{{ compute_node.fabric.ignore.names }}"
37 when:
38 - not compute_node.interfaces.external
39 - compute_node.fabric.ignore.names is defined and compute_node.fabric.ignore.names != omit
40 changed_when: false
41
42- name: Discovery Fabric Interfaces
43 netinfo:
44 include-names: "{{ compute_node.fabric.include.names }}"
45 include-module-types: "{{ compute_node.fabric.include.module_types }}"
46 include-bus-types: "{{ compute_node.fabric.include.bus_types }}"
47 ignore-names: "{{ ignore_names_combined | default(omit) }}"
48 ignore-module-types: "{{ compute_node.fabric.ignore.module_types }}"
49 ignore-bus-types: "{{ compute_node.fabric.ignore.bus_types }}"
50 exclude-names: "{{ compute_node.fabric.exclude.names }}"
51 exclude-module-types: "{{ compute_node.fabric.exclude.module_types }}"
52 exclude-bus-types: "{{ compute_node.fabric.exclude.bus_types }}"
53 debug: on
54
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070055- name: Gather Fabric Interfaces
56 set_fact:
57 fabric_iface_list: "{{ fabric_iface_list + [item] }}"
58 with_items:
David K. Bainbridge603ee542016-10-04 21:11:05 -070059 - "{{ netinfo.included.keys() | sort }}"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070060 changed_when: false
61
David K. Bainbridge603ee542016-10-04 21:11:05 -070062- name: Gather Excluded Fabric Interfaces
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070063 set_fact:
David K. Bainbridge603ee542016-10-04 21:11:05 -070064 fabric_iface_excluded_list: "{{ fabric_iface_excluded_list + [item] }}"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -070065 with_items:
David K. Bainbridge603ee542016-10-04 21:11:05 -070066 - "{{ netinfo.excluded.keys() | sort }}"
67 changed_when: false
68
David K. Bainbridge5ec81872016-10-14 14:49:09 -070069- name: Initialize Modules Ignored for Management Bond
David K. Bainbridge603ee542016-10-04 21:11:05 -070070 set_fact:
71 ignore_module_types_combined: "{{ compute_node.management.ignore.module_types }}"
72 changed_when: false
73
David K. Bainbridge5ec81872016-10-14 14:49:09 -070074- name: Ignore Fabric Modules for Management Bond
David K. Bainbridge603ee542016-10-04 21:11:05 -070075 set_fact:
76 ignore_module_types_combined: "{{ compute_node.fabric.include.module_types }}"
77 when:
78 - compute_node.management.ignore.module_types is not defined or compute_node.management.ignore.module_types == omit
79 - compute_node.fabric.include.module_types is defined and compute_node.fabric.include.module_types != omit
80 changed_when: false
81
David K. Bainbridge5ec81872016-10-14 14:49:09 -070082- name: Explicitly Ignore External and Specified Interfaces From Management Bond
David K. Bainbridge603ee542016-10-04 21:11:05 -070083 set_fact:
84 ignore_names_combined: "{{ compute_node.interfaces.external }},{{ compute_node.management.ignore.names }}"
85 when:
86 - compute_node.interfaces.external
87 - compute_node.management.ignore.names is defined and compute_node.management.ignore.names != omit
88 changed_when: false
89
David K. Bainbridge5ec81872016-10-14 14:49:09 -070090- name: Ignore External Interface From Management Bond
David K. Bainbridge603ee542016-10-04 21:11:05 -070091 set_fact:
92 ignore_names_combined: "{{ compute_node.interfaces.external }}"
93 when:
94 - compute_node.interfaces.external
95 - compute_node.management.ignore.names is not defined or compute_node.management.ignore.names == omit
96 changed_when: false
97
David K. Bainbridge5ec81872016-10-14 14:49:09 -070098- name: Explicity Ingnore Specified Interfaces From Management Bond
David K. Bainbridge603ee542016-10-04 21:11:05 -070099 set_fact:
100 exclude_names_combined: "{{ compute_node.management.ignore.names }}"
101 when:
102 - not compute_node.interfaces.external
103 - compute_node.management.ignore.names is defined and compute_node.management.ignore.names != omit
104 changed_when: false
105
106- name: Discover Management Interfaces
107 netinfo:
108 include-names: "{{ compute_node.management.include.names }}"
109 include-module-types: "{{ compute_node.management.include.module_types }}"
110 include-bus-types: "{{ compute_node.management.include.bus_types }}"
111 ignore-names: "{{ ignore_names_combined | default(omit) }}"
112 ignore-module-types: "{{ ignore_module_types_combined | default(omit) }}"
113 ignore-bus-types: "{{ compute_node.management.ignore.bus_types }}"
114 exclude-names: "{{ compute_node.management.exclude.names }}"
115 exclude-module-types: "{{ compute_node.management.exclude.module_types }}"
116 exclude-bus-types: "{{ compute_node.management.exclude.bus_types }}"
117 debug: on
118
119- name: Gather Management Interfaces
120 set_fact:
121 management_iface_list: "{{ management_iface_list + [item] }}"
122 with_items:
123 - "{{ netinfo.included.keys() | sort }}"
124 changed_when: false
125
126- name: Gather Excluded Management Interfaces
127 set_fact:
128 management_iface_excluded_list: "{{ management_iface_excluded_list + [item] }}"
129 with_items:
130 - "{{ netinfo.excluded.keys() | sort }}"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700131 changed_when: false
132
David K. Bainbridge5135c552016-09-25 18:47:43 -0700133#- name: Ensure Loopback
134# netfile:
135# src: "{{ compute_node.interfaces.file }}"
136# state: present
137# name: lo
138# config: loopback
139# auto: true
140# description: "Loopback interface"
141# register: net_changed
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700142
David K. Bainbridge5135c552016-09-25 18:47:43 -0700143#- name: Verify Loopback Change
144# set_fact:
145# reboot_required: "{{ net_changed.changed }}"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700146
147- name: Ensure Fabric
148 netfile:
149 src: "{{ compute_node.interfaces.file }}"
150 state: present
151 name: fabric
152 config: static
153 auto: true
154 address: "{{ compute_node.addresses.fabric }}"
155 bond-mode: active-backup
156 bond-miimon: 100
157 bond-slaves: none
158 description: "Leaf - Spine bonded fabric interface"
159 register: net_changed
160
161- name: Verify Network Change
162 set_fact:
David K. Bainbridge5135c552016-09-25 18:47:43 -0700163 reboot_required: "{{ net_changed.changed }}"
164# reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700165
166- name: Gather Primary Fabric Interface
167 set_fact:
168 fabric_primary_iface: "{{ fabric_iface_list | sort | first }}"
169 changed_when: false
170 when: fabric_iface_list|length > 0
171
172- name: Ensure Primary Fabric Interface
173 netfile:
174 src: "{{ compute_node.interfaces.file }}"
175 state: present
176 auto: true
177 name: "{{ fabric_primary_iface }}"
178 config: manual
179 bond-master: fabric
180 bond-primary: "{{ fabric_primary_iface }}"
181 description: "Primary fabric interface"
182 register: net_changed
183 when: fabric_iface_list|length > 0
184
185- name: Verify Primary Fabric Interface Changed
186 set_fact:
187 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
188
189- name: Ensure Fabric Interfaces
190 netfile:
191 src: "{{ compute_node.interfaces.file }}"
192 state: present
193 auto: true
194 name: "{{ item }}"
195 config: manual
196 bond-master: fabric
197 description: "Fabric interface"
198 register: net_changed
199 when: fabric_iface_list|length > 1 and item != fabric_primary_iface
200 with_items:
201 - "{{ fabric_iface_list | sort }}"
202
203- name: Verify Fabric Interfaces Changed
204 set_fact:
205 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
206
David K. Bainbridge603ee542016-10-04 21:11:05 -0700207- name: Mark Explicitly Excluded Fabric Interfaces as Manual
208 netfile:
209 src: "{{ compute_node.interfaces.file }}"
210 state: present
211 auto: false
212 name: "{{ item }}"
213 config: manual
214 description: "Explicitly Excluded Fabric Interface"
215 register: net_changed
216 with_items:
217 - "{{ fabric_iface_excluded_list | sort }}"
218
219- name: Verify Fabric Interfaces Changed
220 set_fact:
221 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
222
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700223- name: Ensure Management Bridge DHCP
224 netfile:
225 src: "{{ compute_node.interfaces.file }}"
226 state: present
227 name: mgmtbr
228 config: "dhcp"
229 auto: true
David K. Bainbridge5ec81872016-10-14 14:49:09 -0700230 bridge_ports: "mgmtbond"
231 description: "Internal POD management bridge"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700232 register: net_changed
233 when: compute_node.addresses.management == "dhcp"
234
235- name: Verify Management Bridge DHCP Changed
236 set_fact:
237 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
238
239- name: Ensure Management Bridge STATIC
240 netfile:
241 src: "{{ compute_node.interfaces.file }}"
242 state: present
243 name: mgmtbr
244 config: static
245 auto: true
246 address: "{{ compute_node.addresses.management }}"
David K. Bainbridge603ee542016-10-04 21:11:05 -0700247 gateway: "{{ compute_node.gateway.management }}"
248 broadcast: "{{ compute_node.broadcast.management }}"
David K. Bainbridge5ec81872016-10-14 14:49:09 -0700249 bridge_ports: "mgmtbond"
250 description: "Internal POD management bridge"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700251 register: net_changed
252 when: compute_node.addresses.management != "dhcp"
253
254- name: Verify Management Bridge STATIC Changed
255 set_fact:
256 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
257
David K. Bainbridge5ec81872016-10-14 14:49:09 -0700258- name: Ensure Management Bond
259 netfile:
260 src: "{{ compute_node.interfaces.file }}"
261 state: present
262 name: mgmtbond
263 config: "manual"
264 auto: true
265 bond-mode: active-backup
266 bond-miimon: 100
267 bond-slaves: none
268 description: "Internal POD management bond"
269 register: net_changed
270
271- name: Verify Management Bond DHCP Changed
272 set_fact:
273 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
274
275- name: Gather Primary Management Interface
276 set_fact:
277 management_primary_iface: "{{ management_iface_list | sort | first }}"
278 changed_when: false
279 when: management_iface_list|length > 0
280
281- name: Ensure Primary Management Interface
282 netfile:
283 src: "{{ compute_node.interfaces.file }}"
284 state: present
285 auto: true
286 name: "{{ management_primary_iface }}"
287 config: manual
288 bond-master: mgmtbond
289 bond-primary: "{{ management_primary_iface }}"
290 description: "Primary management interface"
291 register: net_changed
292 when: management_iface_list|length > 0
293
294- name: Verify Primary Management Interface Changed
295 set_fact:
296 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
297
298- name: Ensure Management Interfaces
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700299 netfile:
300 src: "{{ compute_node.interfaces.file }}"
301 state: present
302 auto: true
303 name: "{{ item }}"
304 config: manual
David K. Bainbridge5ec81872016-10-14 14:49:09 -0700305 bond-master: mgmtbond
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700306 description: "Management interface"
307 register: net_changed
David K. Bainbridge5ec81872016-10-14 14:49:09 -0700308 when: management_iface_list|length > 1 and item != management_primary_iface
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700309 with_items:
David K. Bainbridge603ee542016-10-04 21:11:05 -0700310 - "{{ management_iface_list | sort }}"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700311
David K. Bainbridge5ec81872016-10-14 14:49:09 -0700312- name: Verify Management Interfaces Changed
313 set_fact:
314 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
315
316- name: Mark Explicitly Excluded Management Bond Interfaces as Manual
317 netfile:
318 src: "{{ compute_node.interfaces.file }}"
319 state: present
320 auto: false
321 name: "{{ item }}"
322 config: manual
323 description: "Explicitly Excluded Management Bond Interface"
324 register: net_changed
325 with_items:
326 - "{{ management_iface_excluded_list | sort }}"
327
328- name: Verify Explicitly Excluded Management Interfaces Changed
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700329 set_fact:
330 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
331
332- name: Ensure External Interface DHCP
333 netfile:
334 src: "{{ compute_node.interfaces.file }}"
335 state: present
336 auto: true
337 name: "{{ compute_node.interfaces.external }}"
338 config: dhcp
339 description: "External interface from POD to Internet (uplink)"
340 register: net_changed
341 when: compute_node.interfaces.external and compute_node.addresses.external == "dhcp"
342
343- name: Verify External Interface DHCP Changed
344 set_fact:
345 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
346
347- name: Ensure External Interface STATIC
348 netfile:
349 src: "{{ compute_node.interfaces.file }}"
350 state: present
351 auto: true
352 name: "{{ compute_node.interfaces.external }}"
353 config: static
354 address: "{{ compute_node.addresses.external }}"
David K. Bainbridge603ee542016-10-04 21:11:05 -0700355 gateway: "{{ compute_node.gateway.external }}"
356 broadcast: "{{ compute_node.broadcast.external }}"
David K. Bainbridgea677d4e2016-09-11 20:01:32 -0700357 description: "External interface from POD to Internet (uplink)"
358 register: net_changed
359 when: compute_node.interfaces.external and compute_node.addresses.external != "dhcp"
360
361- name: Verify External Interface STATIC Changed
362 set_fact:
363 reboot_required: "{{ reboot_required }} or {{ net_changed.changed }}"
364
365- name: Reboot Required
366 command: /sbin/reboot
367 async: 0
368 poll: 0
369 ignore_errors: true
370 when: reboot_required
371 tags:
372 - interface_config
373 - reboot
374
375- name: Ensure Port Defined
376 set_fact:
377 ansible_ssh_port: 22
378 when: ansible_ssh_port is not defined
379
380- name: Wait For Restart
381 local_action: wait_for port={{ ansible_ssh_port }} host={{ inventory_hostname }} search_regex=OpenSSH delay=120 timeout=600 connect_timeout=15
382 when: reboot_required
383 tags:
384 - interface_config
385 - reboot