From f1a456b7f59c103492354eff8671f8f52993f785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taavi=20V=C3=A4=C3=A4n=C3=A4nen?= Date: Sat, 28 Mar 2026 13:33:37 +0200 Subject: [PATCH] hostkeys: Properly set name of created sshkey objects By default, the sshkey resource assumes the resource title is a hostname that should end up in the known hosts file, so with the current setup hosts like some.fdqn.example_ed25519 are ending up in there which is wrong and messes up tab completion and similar. This commit removes those incorrect names by updating the resource to override the name attribute to the host FQDN instead of relying on the default resource title and setting the host FQDN as an alias. --- manifests/hostkeys.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/hostkeys.pp b/manifests/hostkeys.pp index 19d05cec..421bb090 100644 --- a/manifests/hostkeys.pp +++ b/manifests/hostkeys.pp @@ -51,9 +51,9 @@ if $export_ipaddresses == true { $ipaddresses = ssh::ipaddresses($exclude_interfaces, $exclude_interfaces_re) $ipaddresses_real = $ipaddresses - $exclude_ipaddresses - $host_aliases = sort(unique(flatten([$fqdn_real, $hostname_real, $extra_aliases, $ipaddresses_real]))) + $host_aliases = sort(unique(flatten([$hostname_real, $extra_aliases, $ipaddresses_real]))) } else { - $host_aliases = sort(unique(flatten([$fqdn_real, $hostname_real, $extra_aliases]))) + $host_aliases = sort(unique(flatten([$hostname_real, $extra_aliases]))) } $storeconfigs_groups = $storeconfigs_group ? { @@ -77,6 +77,7 @@ if $key_type in $facts['ssh'] { @@sshkey { "${fqdn_real}_${key_type}": ensure => present, + name => $fqdn_real, host_aliases => $host_aliases, type => $facts['ssh'][$key_type]['type'], key => $facts['ssh'][$key_type]['key'],