portforwarder facters
authorPeter Palfrader <peter@palfrader.org>
Thu, 20 Aug 2015 07:03:25 +0000 (09:03 +0200)
committerPeter Palfrader <peter@palfrader.org>
Thu, 20 Aug 2015 07:03:25 +0000 (09:03 +0200)
modules/debian-org/lib/facter/roleaccounts.rb

index c2c778b..afa6f19 100644 (file)
@@ -75,6 +75,31 @@ begin
         end
     end
 
+    Facter.add("portforwarder_key") do
+        setcode do
+            key = nil
+            keyfile = '/home/portforwarder/.ssh/id_rsa.pub'
+            if FileTest.exist?(keyfile)
+                key = File.open(keyfile).read.chomp
+            end
+            key
+        end
+    end
+
+    Facter.add("portforwarder_user_exists") do
+        setcode do
+            result = ''
+            begin
+                if Etc.getpwnam('portforwarder')
+                    result = true
+                end
+            rescue ArgumentError
+            end
+            result
+        end
+    end
+
+
 
 rescue Exception => e
 end