blob: cb1010c5b2bb037c9b11ca86d9fa8e4fc3ebee92 (
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
|
require 'puppet/provider/parsedfile'
known = nil
case Facter.value(:operatingsystem)
when "Darwin": known = "/etc/ssh_known_hosts"
else
known = "/etc/ssh/ssh_known_hosts"
end
Puppet::Type.type(:sshkey).provide(:parsed,
:parent => Puppet::Provider::ParsedFile,
:default_target => known,
:filetype => :flat
) do
text_line :comment, :match => /^#/
text_line :blank, :match => /^\s+/
record_line :parsed, :fields => %w{name type key},
:post_parse => proc { |hash|
if hash[:name] =~ /,/
names = hash[:name].split(",")
hash[:name] = names.shift
hash[:alias] = names
end
},
:pre_gen => proc { |hash|
if hash[:alias]
names = [hash[:name], hash[:alias]].flatten
hash[:name] = [hash[:name], hash[:alias]].flatten.join(",")
hash.delete(:alias)
end
}
end
|