Last active
October 24, 2017 11:33
-
-
Save pjdietz/4df6d8cd0d9209cfd9d4 to your computer and use it in GitHub Desktop.
Puppet type for adding SSH authorized keys for users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modules/sshkeys/manifests/init.pp | |
define sshkeys ( | |
$home_directory = '/root', | |
$authorized_keys, | |
) { | |
exec { "/usr/bin/test -e ${home_directory}": } | |
file { "${home_directory}/.ssh": | |
ensure => directory, | |
mode => 0700, | |
require => Exec["/usr/bin/test -e ${home_directory}"] | |
} | |
file { "${home_directory}/.ssh/authorized_keys": | |
ensure => file, | |
mode => 0600, | |
content => $authorized_keys, | |
require => File["${home_directory}/.ssh"], | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add SSH keys for the users root and puppet | |
$authorized_keys = file('/etc/puppet/files/sshkeys/authorized_keys') | |
sshkeys { 'root': | |
home_directory => '/root', | |
authorized_keys => $authorized_keys, | |
} | |
sshkeys { 'puppet': | |
home_directory => '/home/puppet', | |
authorized_keys => $authorized_keys, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment