Skip to content

Commit

Permalink
Make manage_ssh_key generate a valid key instead of creating a 0 byte…
Browse files Browse the repository at this point in the history
… invalid one.
  • Loading branch information
mikaelfrykholm committed Oct 19, 2023
1 parent f809124 commit 873e9a7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions manifests/dehydrated.pp
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,17 @@
undef => $domain,
default => $ssh_id,
}
if $manage_ssh_key {
ensure_resource('sunet::snippets::secret_file', "${home}/.ssh/id_${_ssh_id}", {
if $manage_ssh_key {
$key_path = "${home}/.ssh/id_${_ssh_id}"
if lookup("${_ssh_id}_ssh_key", undef, undef, undef) { #Key is in secrets, write it to host
ensure_resource('sunet::snippets::secret_file', "$key_path", {
hiera_key => "${_ssh_id}_ssh_key",
})
}else{
if (!find_file($key_path)){
sunet::snippets::ssh_keygen{$key_path:} #This will not overwrite an existing key
}
}
}
if $single_domain {
cron { "rsync_dehydrated_${domain}":
Expand Down

0 comments on commit 873e9a7

Please sign in to comment.