|
21 | 21 | ) |
22 | 22 | from osism import settings, utils |
23 | 23 | from osism.tasks.conductor.netbox import get_nb_device_query_list_ironic |
| 24 | +from osism.tasks.conductor.ironic import _get_metalbox_primary_ip4 |
24 | 25 | from osism.tasks.conductor.utils import deep_decrypt, get_vault |
25 | 26 | from osism.tasks import netbox |
26 | 27 | from osism.utils.ssh import cleanup_ssh_known_hosts_for_node |
@@ -230,6 +231,7 @@ def take_action(self, parsed_args): |
230 | 231 | try: |
231 | 232 | # Get default vars from NetBox local_context_data if available |
232 | 233 | default_vars = {} |
| 234 | + device = None |
233 | 235 | if utils.nb: |
234 | 236 | try: |
235 | 237 | # Try to find device by name first |
@@ -291,6 +293,12 @@ def take_action(self, parsed_args): |
291 | 293 | play["vars"].update( |
292 | 294 | {"hostname_name": node.name, "hosts_type": "template"} |
293 | 295 | ) |
| 296 | + if device: |
| 297 | + metalbox_ip = _get_metalbox_primary_ip4(device) |
| 298 | + if metalbox_ip: |
| 299 | + play["vars"]["hosts_additional_entries"] = { |
| 300 | + "metalbox.osism.xyz": metalbox_ip |
| 301 | + } |
294 | 302 | if ( |
295 | 303 | "netplan_parameters" in node.extra |
296 | 304 | and node.extra["netplan_parameters"] |
@@ -405,6 +413,7 @@ def take_action(self, parsed_args): |
405 | 413 |
|
406 | 414 | # Get default vars from NetBox local_context_data if available |
407 | 415 | default_vars = {} |
| 416 | + device = None |
408 | 417 | if utils.nb: |
409 | 418 | try: |
410 | 419 | # Try to find device by name first |
@@ -466,6 +475,12 @@ def take_action(self, parsed_args): |
466 | 475 | play["vars"].update( |
467 | 476 | {"hostname_name": node.name, "hosts_type": "template"} |
468 | 477 | ) |
| 478 | + if device: |
| 479 | + metalbox_ip = _get_metalbox_primary_ip4(device) |
| 480 | + if metalbox_ip: |
| 481 | + play["vars"]["hosts_additional_entries"] = { |
| 482 | + "metalbox.osism.xyz": metalbox_ip |
| 483 | + } |
469 | 484 |
|
470 | 485 | # Get netplan_parameters from Ironic node extra (JSON string, needs parsing) |
471 | 486 | if ( |
@@ -573,6 +588,11 @@ def take_action(self, parsed_args): |
573 | 588 | play["vars"].update( |
574 | 589 | {"hostname_name": device.name, "hosts_type": "template"} |
575 | 590 | ) |
| 591 | + metalbox_ip = _get_metalbox_primary_ip4(device) |
| 592 | + if metalbox_ip: |
| 593 | + play["vars"]["hosts_additional_entries"] = { |
| 594 | + "metalbox.osism.xyz": metalbox_ip |
| 595 | + } |
576 | 596 |
|
577 | 597 | # Get netplan_parameters from NetBox custom fields (already a dict, no JSON parsing needed) |
578 | 598 | if ( |
|
0 commit comments