summaryrefslogtreecommitdiffstats
path: root/lib/facter/Cfkey.rb
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-05-17 00:32:34 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-05-17 00:32:34 +1000
commite02b0b386ed84384daeb2da0879bf215cfcfa2ef (patch)
tree36cdd5c3cc6143ce6faccb87ba6461bf5f481a29 /lib/facter/Cfkey.rb
parent9c91a6d3fb9da933d8e1ba4149ee1b5587e6b007 (diff)
downloadfacter-e02b0b386ed84384daeb2da0879bf215cfcfa2ef.tar.gz
facter-e02b0b386ed84384daeb2da0879bf215cfcfa2ef.tar.xz
facter-e02b0b386ed84384daeb2da0879bf215cfcfa2ef.zip
Updated version. Moved most facts to seperate files.
Diffstat (limited to 'lib/facter/Cfkey.rb')
-rw-r--r--lib/facter/Cfkey.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/facter/Cfkey.rb b/lib/facter/Cfkey.rb
new file mode 100644
index 0000000..794971b
--- /dev/null
+++ b/lib/facter/Cfkey.rb
@@ -0,0 +1,43 @@
+## Cfkey.rb
+## Facts related to cfengine
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation (version 2 of the License)
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA
+##
+
+ Facter.add(:Cfkey) do
+ setcode do
+ value = nil
+ ["/usr/local/etc/cfkey.pub",
+ "/etc/cfkey.pub",
+ "/var/cfng/keys/localhost.pub",
+ "/var/cfengine/ppkeys/localhost.pub",
+ "/var/lib/cfengine/ppkeys/localhost.pub",
+ "/var/lib/cfengine2/ppkeys/localhost.pub"
+ ].each { |file|
+ if FileTest.file?(file)
+ File.open(file) { |openfile|
+ value = openfile.readlines.reject { |line|
+ line =~ /PUBLIC KEY/
+ }.collect { |line|
+ line.chomp
+ }.join("")
+ }
+ end
+ if value
+ break
+ end
+ }
+
+ value
+ end
+ end
+