Skip to content

Commit 4275c90

Browse files
committed
Fix issues with inspection rules
The by_path attribute from plugin data was being used with the root_device/name property, which failed to match. Revert to using serial, which was the original intent anyway. Check if root disk serial is not empty to avoid setting root_device to {'serial': 'None'} which would cause deploy failures. Fix syntax for accessing node data inside dictionaries: interpolation of "{node.driver_info.ipmi_username}" does not work, we need to use "{node.driver_info[ipmi_username]}" instead. Fix syntax for accessing inventory data: inventory is a ShallowMaskDict object, so we need to use "{inventory[system_vendor]}" instead of "{inventory.system_vendor}". Update all regular expressions to match and remove unneeded escaping of curly braces. Fix syntax for setting properties: the path needs to be "/driver_info/ipmi_username" instead of "driver_info/ipmi_username". Change-Id: I552f21c73a69340132244ea15089f01a2f9d20d0 Signed-off-by: Pierre Riteau <pierre@stackhpc.com>
1 parent 0363434 commit 4275c90

File tree

1 file changed

+52
-49
lines changed

1 file changed

+52
-49
lines changed

ansible/inventory/group_vars/all/inspector

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,24 @@ inspector_rule_ipmi_credentials:
119119
description: "Set IPMI driver_info if no credentials"
120120
conditions:
121121
- args:
122-
value: "{node.driver_info.ipmi_username}"
123-
regex: '\\{node\\.driver_info\\.ipmi_username\\}'
122+
# If value matches itself as a regex, this is becaused interpolation
123+
# failed which means the ipmi_username key was not set.
124+
value: "{node.driver_info[ipmi_username]}"
125+
regex: "{node\\.driver_info\\[ipmi_username\\]}"
124126
op: "matches"
125127
- args:
126-
value: "{node.driver_info.ipmi_password}"
127-
regex: '\\{node\\.driver_info\\.ipmi_password\\}'
128+
value: "{node.driver_info[ipmi_password]}"
129+
regex: "{node\\.driver_info\\[ipmi_password\\]}"
128130
op: "matches"
129131
sensitive: "true"
130132
actions:
131133
- op: "set-attribute"
132134
args:
133-
path: "driver_info/ipmi_username"
135+
path: "/driver_info/ipmi_username"
134136
value: "{{ inspector_rule_var_ipmi_username }}"
135137
- op: "set-attribute"
136138
args:
137-
path: "driver_info/ipmi_password"
139+
path: "/driver_info/ipmi_password"
138140
value: "{{ inspector_rule_var_ipmi_password }}"
139141

140142
# Deployment kernel referenced by inspector rule.
@@ -145,13 +147,13 @@ inspector_rule_deploy_kernel:
145147
description: "Set deploy kernel"
146148
conditions:
147149
- args:
148-
value: "{node.driver_info.deploy_kernel}"
149-
regex: '\\{node\\.driver_info\\.deploy_kernel\\}'
150+
value: "{node.driver_info[deploy_kernel]}"
151+
regex: "{node\\.driver_info\\[deploy_kernel\\]}"
150152
op: "matches"
151153
actions:
152154
- op: "set-attribute"
153155
args:
154-
path: "driver_info/deploy_kernel"
156+
path: "/driver_info/deploy_kernel"
155157
value: "{{ inspector_rule_var_deploy_kernel }}"
156158

157159
# Deployment ramdisk referenced by inspector rule.
@@ -162,13 +164,13 @@ inspector_rule_deploy_ramdisk:
162164
description: "Set deploy ramdisk"
163165
conditions:
164166
- args:
165-
value: "{node.driver_info.deploy_ramdisk}"
166-
regex: '\\{node\\.driver_info\\.deploy_ramdisk\\}'
167+
value: "{node.driver_info[deploy_ramdisk]}"
168+
regex: "{node\\.driver_info\\[deploy_ramdisk\\]}"
167169
op: "matches"
168170
actions:
169171
- op: "set-attribute"
170172
args:
171-
path: "driver_info/deploy_ramdisk"
173+
path: "/driver_info/deploy_ramdisk"
172174
value: "{{ inspector_rule_var_deploy_ramdisk }}"
173175

174176
# Ironic inspector rule to set serial root device hint.
@@ -177,27 +179,29 @@ inspector_rule_root_hint_serial:
177179
conditions:
178180
- args:
179181
value: "{node.properties[root_device]}"
180-
regex: "\\{node\\.properties\\[root_device\\]\\}"
182+
regex: "{node\\.properties\\[root_device\\]}"
181183
op: "matches"
184+
- args:
185+
value: "{plugin_data[root_disk][serial]}"
186+
op: "!is-empty"
182187
actions:
183188
- op: "set-attribute"
184189
args:
185-
path: "properties/root_device/name"
186-
value: "{plugin_data[root_disk][by_path]}"
187-
190+
path: "/properties/root_device/serial"
191+
value: "{plugin_data[root_disk][serial]}"
188192

189193
# Ironic inspector rule to set the interface on which the node PXE booted.
190194
inspector_rule_set_pxe_interface_mac:
191195
description: "Set node PXE interface MAC address"
192196
conditions:
193197
- args:
194198
value: "{plugin_data[boot_interface]}"
195-
regex: "'\\{plugin_data\\[boot_interface\\]\\}'"
199+
regex: "{plugin_data\\[boot_interface\\]}"
196200
op: "!matches"
197201
actions:
198202
- op: "set-attribute"
199203
args:
200-
path: "extra/pxe_interface_mac"
204+
path: "/extra/pxe_interface_mac"
201205
value: "{plugin_data[boot_interface]}"
202206

203207
# Name of network interface to use for LLDP referenced by switch port
@@ -255,7 +259,7 @@ inspector_rule_lldp_switch_port_desc_to_name:
255259
actions:
256260
- op: "set-attribute"
257261
args:
258-
path: "name"
262+
path: "/name"
259263
value: "{{ _inspector_rule_switch_port_description_path }}"
260264

261265
# Ironic inspector rule to save system vendor manufacturer data in the node's
@@ -264,17 +268,17 @@ inspector_rule_save_system_vendor_manufacturer:
264268
description: "Save system vendor manufacturer data in Ironic node metadata"
265269
conditions:
266270
- args:
267-
value: "{inventory.system_vendor}"
268-
regex: "\\{inventory\\.system_vendor\\}"
271+
value: "{inventory[system_vendor]}"
272+
regex: "{inventory\\[system_vendor\\]}"
269273
op: "!matches"
270274
- args:
271-
value: "{inventory.system_vendor.manufacturer}"
272-
regex: "\\{inventory\\.system_vendor\\.manufacturer\\}"
275+
value: "{inventory[system_vendor][manufacturer]}"
276+
regex: "{inventory\\[system_vendor\\]\\[manufacturer\\]}"
273277
op: "!matches"
274278
actions:
275279
- op: "set-attribute"
276280
args:
277-
path: "extra/system_vendor/manufacturer"
281+
path: "/extra/system_vendor/manufacturer"
278282
value: "{inventory[system_vendor][manufacturer]}"
279283

280284
# Ironic inspector rule to save system vendor serial number in the node's
@@ -283,17 +287,17 @@ inspector_rule_save_system_vendor_serial_number:
283287
description: "Save system vendor serial number in Ironic node metadata"
284288
conditions:
285289
- args:
286-
value: "{inventory.system_vendor}"
287-
regex: "\\{inventory\\.system_vendor\\}"
290+
value: "{inventory[system_vendor]}"
291+
regex: "{inventory\\[system_vendor\\]}"
288292
op: "!matches"
289293
- args:
290-
value: "{inventory.system_vendor.serial_number}"
291-
regex: "\\{inventory\\.system_vendor\\.serial_number\\}"
294+
value: "{inventory[system_vendor][serial_number]}"
295+
regex: "{inventory\\[system_vendor\\]\\[serial_number\\]}"
292296
op: "!matches"
293297
actions:
294298
- op: "set-attribute"
295299
args:
296-
path: "extra/system_vendor/serial_number"
300+
path: "/extra/system_vendor/serial_number"
297301
value: "{inventory[system_vendor][serial_number]}"
298302

299303
# Ironic inspector rule to save system vendor product name in the node's
@@ -302,17 +306,17 @@ inspector_rule_save_system_vendor_product_name:
302306
description: "Save system vendor product name in Ironic node metadata"
303307
conditions:
304308
- args:
305-
value: "{inventory.system_vendor}"
306-
regex: "\\{inventory\\.system_vendor\\}"
309+
value: "{inventory[system_vendor]}"
310+
regex: "{inventory\\[system_vendor\\]}"
307311
op: "!matches"
308312
- args:
309-
value: "{inventory.system_vendor.product_name}"
310-
regex: "\\{inventory\\.system_vendor\\.product_name\\}"
313+
value: "{inventory[system_vendor][product_name]}"
314+
regex: "{inventory\\[system_vendor\\]\\[product_name\\]}"
311315
op: "!matches"
312316
actions:
313317
- op: "set-attribute"
314318
args:
315-
path: "extra/system_vendor/product_name"
319+
path: "/extra/system_vendor/product_name"
316320
value: "{inventory[system_vendor][product_name]}"
317321

318322
# Ironic inspector rule to save introspection data to the node.
@@ -322,11 +326,11 @@ inspector_rule_save_data:
322326
actions:
323327
- op: "set-attribute"
324328
args:
325-
path: "extra/introspection_data/inventory"
329+
path: "/extra/introspection_data/inventory"
326330
value: "{inventory}"
327331
- op: "set-attribute"
328332
args:
329-
path: "extra/introspection_data/plugin_data"
333+
path: "/extra/introspection_data/plugin_data"
330334
value: "{plugin_data}"
331335

332336
# Redfish rules
@@ -335,50 +339,50 @@ inspector_rule_redfish_credentials:
335339
description: "Set Redfish driver_info if no credentials"
336340
conditions:
337341
- args:
338-
value: "{node.driver_info.redfish_username}"
339-
regex: "\\{node\\.driver_info\\.redfish_username\\}"
342+
value: "{node.driver_info[redfish_username]}"
343+
regex: "{node\\.driver_info\\[redfish_username\\]}"
340344
op: "matches"
341345
- args:
342-
value: "{node.driver_info.redfish_password}"
343-
regex: "\\{node\\.driver_info\\.redfish_password\\}"
346+
value: "{node.driver_info[redfish_password]}"
347+
regex: "{node\\.driver_info\\[redfish_password\\]}"
344348
op: "matches"
345349
sensitive: true
346350
actions:
347351
- op: "set-attribute"
348352
args:
349-
path: "driver_info/redfish_username"
353+
path: "/driver_info/redfish_username"
350354
value: "{{ inspector_rule_var_redfish_username }}"
351355
- op: "set-attribute"
352356
args:
353-
path: "driver_info/redfish_password"
357+
path: "/driver_info/redfish_password"
354358
value: "{{ inspector_rule_var_redfish_password }}"
355359

356360
# Ironic inspector rule to set Redfish address.
357361
inspector_rule_redfish_address:
358362
description: "Set Redfish address"
359363
conditions:
360364
- args:
361-
value: "{node.driver_info.redfish_address}"
362-
regex: "\\{node\\.driver_info\\.redfish_address\\}"
365+
value: "{node.driver_info[redfish_address]}"
366+
regex: "{node\\.driver_info\\[redfish_address\\]}"
363367
op: "matches"
364368
actions:
365369
- op: "set-attribute"
366370
args:
367-
path: "driver_info/redfish_address"
371+
path: "/driver_info/redfish_address"
368372
value: "{inventory[bmc_address]}"
369373

370374
# Ironic inspector rule to set Redfish certificate authority.
371375
inspector_rule_redfish_verify_ca:
372376
description: "Set Redfish Verify CA"
373377
conditions:
374378
- args:
375-
value: "{node.driver_info.redfish_verify_ca}"
376-
regex: "\\{node\\.driver_info\\.redfish_verify_ca\\}"
379+
value: "{node.driver_info[redfish_verify_ca]}"
380+
regex: "{node\\.driver_info\\[redfish_verify_ca\\]}"
377381
op: "matches"
378382
actions:
379383
- op: "set-attribute"
380384
args:
381-
path: "driver_info/redfish_verify_ca"
385+
path: "/driver_info/redfish_verify_ca"
382386
value: "{{ inspector_rule_var_redfish_verify_ca }}"
383387

384388
# List of default ironic inspector rules.
@@ -421,4 +425,3 @@ inspector_rules: "{{ inspector_rules_default + inspector_rules_extra + (inspecto
421425
# Ansible group containing switch hosts to which the workaround should be
422426
# applied.
423427
inspector_dell_switch_lldp_workaround_group:
424-

0 commit comments

Comments
 (0)