aboutsummaryrefslogtreecommitdiff
path: root/lib/facter/monkeysphere.rb
blob: 6f48a4d63836995dd9256b90acb244e30fc0dc03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
has_hostkey = false
pgp_fingerprint = ' '
pgp_id = ' '
ssh_fingerprint = ' '

if File.exist?('/usr/sbin/monkeysphere-host')

  sk = %x{/usr/sbin/monkeysphere-host show-keys 2>/dev/null}
  if $? == 0
    has_hostkey = true
    sk.lines.each do |line|
      m = line.match('^OpenPGP fingerprint:(.*)$')
      if m
        pgp_fingerprint = m[1].strip
      end
      m = line.match('^uid (.*)$')
      if m
        pgp_id = m[1].strip
      end
      m = line.match('^ssh fingerprint:(.*)$')
      if m
        ssh_fingerprint = m[1].strip
      end
    end
  end
end

Facter.add("monkeysphere_has_hostkey") do
  setcode{ has_hostkey }
end

Facter.add("monkeysphere_pgp_fp") do
  setcode{ pgp_fingerprint }
end

Facter.add("monkeysphere_pgp_id") do
  setcode{ pgp_id }
end

Facter.add("monkeysphere_ssh_fp") do
  setcode{ ssh_fingerprint }
end