Skip to content

Commit abd4e92

Browse files
authored
Add metalbox hosts_additional_entries to deploy playbook (#2114)
Adds the metalbox primary IPv4 address as hosts_additional_entries (metalbox.osism.xyz) to the bootstrap playbook used during baremetal deploy. The entry is omitted when the metalbox has no primary IPv4. AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
1 parent 811f63a commit abd4e92

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

osism/commands/baremetal.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from osism import settings, utils
2323
from osism.tasks.conductor.netbox import get_nb_device_query_list_ironic
24+
from osism.tasks.conductor.ironic import _get_metalbox_primary_ip4
2425
from osism.tasks.conductor.utils import deep_decrypt, get_vault
2526
from osism.tasks import netbox
2627
from osism.utils.ssh import cleanup_ssh_known_hosts_for_node
@@ -230,6 +231,7 @@ def take_action(self, parsed_args):
230231
try:
231232
# Get default vars from NetBox local_context_data if available
232233
default_vars = {}
234+
device = None
233235
if utils.nb:
234236
try:
235237
# Try to find device by name first
@@ -291,6 +293,12 @@ def take_action(self, parsed_args):
291293
play["vars"].update(
292294
{"hostname_name": node.name, "hosts_type": "template"}
293295
)
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+
}
294302
if (
295303
"netplan_parameters" in node.extra
296304
and node.extra["netplan_parameters"]
@@ -405,6 +413,7 @@ def take_action(self, parsed_args):
405413

406414
# Get default vars from NetBox local_context_data if available
407415
default_vars = {}
416+
device = None
408417
if utils.nb:
409418
try:
410419
# Try to find device by name first
@@ -466,6 +475,12 @@ def take_action(self, parsed_args):
466475
play["vars"].update(
467476
{"hostname_name": node.name, "hosts_type": "template"}
468477
)
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+
}
469484

470485
# Get netplan_parameters from Ironic node extra (JSON string, needs parsing)
471486
if (
@@ -573,6 +588,11 @@ def take_action(self, parsed_args):
573588
play["vars"].update(
574589
{"hostname_name": device.name, "hosts_type": "template"}
575590
)
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+
}
576596

577597
# Get netplan_parameters from NetBox custom fields (already a dict, no JSON parsing needed)
578598
if (

0 commit comments

Comments
 (0)