--- /dev/null
+# create an ssh key for user
+define ssh::keygen(
+ String $user = $name,
+) {
+ if $facts["${user}_user_exists"] == undef {
+ notify{"We do not have facters for user ${user} existance and keys -- add it to modules/debian_org/lib/facter/roleaccounts.rb": }
+ }
+ if $facts["${user}_user_exists"] {
+ if ! $facts["${user}_key"] {
+ exec { "create-${user}-ssh-key":
+ command => @("EOF"),
+ /bin/su - ${user} -c 'mkdir -p -m 02700 .ssh && ssh-keygen -C "`whoami`@`hostname` (`date +%Y-%m-%d`)" -P "" -f .ssh/id_rsa -q'
+ | EOF
+ onlyif => "/usr/bin/getent passwd ${user} > /dev/null && ! [ -e ~${user}/.ssh/id_rsa ]"
+ }
+ }
+ } else {
+ notify{"User ${user} does not exist on this host. Will not create ssh key": }
+ }
+}