Skip to content

Commit d4a7957

Browse files
committed
P:puppet::server: generate SSH key for syncing data
We will need SSH keys to sync CA and other private data between Puppet servers. Generate a dedicated SSH key for this that we can then deploy to the other Puppet servers using PuppetDB exported resources.
1 parent 56dd7de commit d4a7957

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

modules/profile/manifests/puppet/server.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@
247247

248248
include profile::ssh::ca
249249

250+
ssh::client::user_key { 'puppet-sync': }
251+
250252
# Expose SSH keys so users can verify them
251253
file { '/srv/www':
252254
ensure => directory,

modules/ssh/manifests/client.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@
1010
mode => '0444',
1111
}
1212
}
13+
14+
file { '/etc/ssh/local_keys.d':
15+
ensure => directory,
16+
owner => 'root',
17+
group => 'root',
18+
mode => '0555',
19+
}
1320
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# @summary Generates an SSH keypair in a way that the public part will
2+
# be available as a fact for use elsewhere.
3+
define ssh::client::user_key (
4+
String[1] $owner = 'root',
5+
String[1] $group = 'root',
6+
) {
7+
exec { "ssh-key-generate-${title}":
8+
command => "/usr/bin/ssh-keygen -f /etc/ssh/local_keys.d/${title} -C '${title} ${facts['networking']['fqdn']}' -t ed25519",
9+
creates => "/etc/ssh/local_keys.d/${title}",
10+
user => $owner,
11+
group => $group,
12+
}
13+
14+
file { "/etc/ssh/local_keys.d/${title}":
15+
ensure => file,
16+
owner => $owner,
17+
group => $group,
18+
mode => '0400',
19+
require => Exec["ssh-key-generate-${title}"],
20+
}
21+
22+
file { "/etc/ssh/local_keys.d/${title}.pub":
23+
ensure => file,
24+
owner => $owner,
25+
group => $group,
26+
mode => '0444',
27+
require => File["/etc/ssh/local_keys.d/${title}"],
28+
}
29+
}

0 commit comments

Comments
 (0)