Skip to content

baremetal: Warn when first boot installs no key - #2934

Merged
berendt merged 1 commit into
mainfrom
first-boot-key-warning
Nov 26, 2026
Merged

berendt merged 1 commit into
mainfrom
first-boot-key-warning

Conversation

@ideaship

Copy link
Copy Markdown
Contributor

What

osism baremetal deploy, osism baremetal dump --ironic and the NetBox-mode osism baremetal dump log a warning per node when the first-boot play carries no operator key, naming the node and the reason:

  • NetBox is not configured
  • the NetBox lookup failed
  • no NetBox device matches the node (by name or inventory_hostname)
  • the device carries none of operator_authorized_keys, operator_additional_authorized_keys and operator_authorized_github_accounts in first_boot or local_context_data

For example:

node101: the first boot installs no operator key (no operator_authorized_keys, operator_additional_authorized_keys or operator_authorized_github_accounts in first_boot or local_context_data of NetBox device node101). After the deploy the node is reachable only through credentials built into the image, if it has any.

Why

The first-boot play installs the operator keys through the operator role of osism.commons, from those three variables. When the play carries none of them, the deploy goes on and the node is installed without a key. Today the keys built into the osism-node image hide this, because the node is reachable anyway. Without them the node is active but unreachable, and the first sign is wait-for-connection timing out on the manager.

The code cannot tell what the image contains, so the warning only states what NetBox provides. It fires for every node whose NetBox data carries no operator key. Sites that keep operator_authorized_keys in the device's local_context_data, as the key rotation guide describes, or one of the three under first_boot, do not see it.

Behaviour

Deploy behaviour and exit status are unchanged. The NetBox lookup, which deploy and dump --ironic carried as identical copies, moves into _lookup_netbox_device, which returns the device or the reason it has none; the existing "Failed to fetch NetBox data" warning stays. The NetBox-mode dump already fails when NetBox or the device is missing, so there the warning can only report a device without a key.

Testing

  • New unit tests in tests/unit/commands/test_baremetal.py: every reason for deploy and dump --ironic, a device without a key for the NetBox-mode dump, no warning for each of the three key variables and for a key at the top level, a warning for an empty or null key list under first_boot, deploy --all with one node without a key, a lookup error in dump --ironic, and the device name in the reason when the device is found by inventory_hostname.
  • Deployed on a MetalBox with this change in its osism image: with the key in a NetBox config context the node was deployed without a warning and accepted the key; with the config context inactive the deploy logged the warning above for the device and the deployed node refused SSH logins (Permission denied (publickey)); both dump modes logged the same warning.

🤖 Generated with Claude Code

The first-boot play that osism baremetal deploy puts on a node's config
drive installs the operator keys through the operator role of
osism.commons, from operator_authorized_keys,
operator_additional_authorized_keys and
operator_authorized_github_accounts. When the play carries none of
them, the deploy goes on and the node is installed without a key. That
happens when NetBox is not configured for the client, when the NetBox
lookup fails, when no device matches the node, or when the device
carries none of the three in first_boot or local_context_data. Today
the keys baked into the osism-node image hide this: the node is
reachable anyway. Without them it is active but unreachable, and the
first sign is wait-for-connection timing out on the manager.

osism baremetal deploy, dump --ironic and the NetBox-mode dump now log
a warning per node in that case, naming the node and the reason:

  node101: the first boot installs no operator key (<reason>). After
  the deploy the node is reachable only through credentials built
  into the image, if it has any.

The code cannot tell what the image contains, so the warning only
states what NetBox provides. It fires for every node whose NetBox data
carries no operator key. Sites that keep operator_authorized_keys in
the device's local_context_data, as the key rotation guide describes,
or one of the three under first_boot, do not see it.

Deploy behaviour and exit status are unchanged. The NetBox lookup,
which deploy and dump --ironic carried as identical copies, moves into
_lookup_netbox_device, which returns the device or the reason it has
none; the existing "Failed to fetch NetBox data" warning stays. The
NetBox-mode dump already fails when NetBox or the device is missing,
so there the warning can only report a device without a key.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Roger Luethi <luethi@osism.tech>
@ideaship
ideaship marked this pull request as ready for review November 26, 2026 16:09
@ideaship ideaship self-assigned this Nov 26, 2026
@ideaship
ideaship requested a review from berendt November 26, 2026 16:09
@berendt
berendt merged commit aef0933 into main Nov 26, 2026
3 checks passed
@berendt
berendt deleted the first-boot-key-warning branch November 26, 2026 16:15
@github-project-automation github-project-automation Bot moved this from New to Done in Human Board Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants