create ssh key for buildd
authorPeter Palfrader <peter@palfrader.org>
Sat, 14 Feb 2015 14:01:00 +0000 (15:01 +0100)
committerPeter Palfrader <peter@palfrader.org>
Sat, 14 Feb 2015 14:01:00 +0000 (15:01 +0100)
modules/buildd/manifests/init.pp
modules/debian-org/lib/facter/roleaccounts.rb

index 2fe6b6a..f11f647 100644 (file)
@@ -166,4 +166,11 @@ class buildd ($ensure=present) {
                owner   => buildd,
        }
 
+        if ! $::buildd_key {
+                exec { 'create-buildd-key':
+                        command => '/bin/su - buildd -c \'mkdir -p -m 02700 .ssh && ssh-keygen -C "`whoami`@`hostname` (`date +%Y-%m-%d`)" -P "" -f .ssh/id_rsa -q\'',
+                        onlyif  => '/usr/bin/getent passwd buildd > /dev/null && ! [ -e /home/buildd/.ssh/id_rsa ]'
+                }
+        }
+
 }
index 9726919..bb652f8 100644 (file)
@@ -26,7 +26,6 @@ begin
     end
 
 
-
     Facter.add("weblogsync_key") do
         setcode do
             key = nil
@@ -51,6 +50,18 @@ begin
         end
     end
 
+    Facter.add("buildd_key") do
+        setcode do
+            key = nil
+            keyfile = '/home/buildd/.ssh/id_rsa.pub'
+            if FileTest.exist?(keyfile)
+                key = File.open(keyfile).read.chomp
+            end
+            key
+        end
+    end
+
+
 rescue Exception => e
 end
 # vim:set et: