diff options
author | Jacob Helwig <jacob@technosorcery.net> | 2018-06-04 11:30:09 -0700 |
---|---|---|
committer | Jacob Helwig <jacob@technosorcery.net> | 2018-06-21 14:27:04 -0700 |
commit | d1719de1d77b9c139b1b5f5832330807c0fe11fe (patch) | |
tree | 69c541233bc64c5d47746e062e0efcba0c5436b5 /lib/puppet/provider/sshkey | |
download | puppet-sshkeys_core-d1719de1d77b9c139b1b5f5832330807c0fe11fe.tar.gz puppet-sshkeys_core-d1719de1d77b9c139b1b5f5832330807c0fe11fe.tar.bz2 |
Initial sshkey type import from Puppet repository
Imported from dbf5a8964af9b87446542d24f46534cf90f11f59 in the Puppet repo.
Diffstat (limited to 'lib/puppet/provider/sshkey')
-rw-r--r-- | lib/puppet/provider/sshkey/parsed.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb new file mode 100644 index 0000000..1c42aeb --- /dev/null +++ b/lib/puppet/provider/sshkey/parsed.rb @@ -0,0 +1,50 @@ +require 'puppet/provider/parsedfile' + +Puppet::Type.type(:sshkey).provide( + :parsed, + :parent => Puppet::Provider::ParsedFile, + :filetype => :flat +) do + desc "Parse and generate host-wide known hosts files for SSH." + + text_line :comment, :match => /^#/ + text_line :blank, :match => /^\s*$/ + + record_line :parsed, :fields => %w{name type key}, + :post_parse => proc { |hash| + names = hash[:name].split(",", -1) + hash[:name] = names.shift + hash[:host_aliases] = names + }, + :pre_gen => proc { |hash| + if hash[:host_aliases] + hash[:name] = [hash[:name], hash[:host_aliases]].flatten.join(",") + hash.delete(:host_aliases) + end + } + + # Make sure to use mode 644 if ssh_known_hosts is newly created + def self.default_mode + 0644 + end + + def self.default_target + case Facter.value(:operatingsystem) + when "Darwin" + # Versions 10.11 and up use /etc/ssh/ssh_known_hosts + version = Facter.value(:macosx_productversion_major) + if version + if Puppet::Util::Package.versioncmp(version, '10.11') >= 0 + "/etc/ssh/ssh_known_hosts" + else + "/etc/ssh_known_hosts" + end + else + "/etc/ssh_known_hosts" + end + else + "/etc/ssh/ssh_known_hosts" + end + end +end + |