Created
November 10, 2010 17:41
-
-
Save panterch/671193 to your computer and use it in GitHub Desktop.
authorized keys recipe
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
class authorized_keys { | |
# install the given keys in the users authorized_keys file | |
# user name is given as title, keys are names of template files located in | |
# the modules templates directory | |
# | |
# key names are expanded to $keydir/<name>.pub. This ensures minimal writing | |
# and maintains compatibility with other tools like gitosis. | |
define install( keys = [ "seb" ], keydir = "/etc/puppet/files/ssh_keys" ) { | |
$home = $title ? { "root" => "/root", default => "/home/$title" } | |
file { "$home/.ssh": | |
ensure => directory, | |
owner => $title, | |
mode => 700, | |
require => $title ? { "root" => undef, default => User[$title] } , | |
} | |
$keyfiles = regsubst($keys, '^.+$', "$keydir/\0.pub") | |
file { "$home/.ssh/authorized_keys": | |
ensure => present, | |
owner => $title, | |
mode => 600, | |
content => inline_template("<%=keyfiles.map{ |f| open(f).read }.join()%>"), | |
require => File["$home/.ssh"], | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment