aboutsummaryrefslogtreecommitdiff
path: root/lib/puppet
diff options
context:
space:
mode:
authorCiprian Badescu <ciprian.badescu@puppet.com>2020-02-20 15:32:52 +0200
committerCiprian Badescu <ciprian.badescu@puppet.com>2020-02-25 14:27:27 +0200
commit92a734a6620fcc51691d60347e344f87ac801bde (patch)
tree8309796c9485c084ec87cd84d26d17ecfb904213 /lib/puppet
parent9f710d8e502b5bf2ca3d213d2bddea13f7a4b7b8 (diff)
downloadpuppet-sshkeys_core-92a734a6620fcc51691d60347e344f87ac801bde.tar.gz
puppet-sshkeys_core-92a734a6620fcc51691d60347e344f87ac801bde.tar.bz2
(MODULES-7613) use name and type as composite namevar
After this modification it will be possible to add two or more keys of different types for the same host
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/provider/sshkey/parsed.rb5
-rw-r--r--lib/puppet/type/sshkey.rb26
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb
index 3713df1..965c20d 100644
--- a/lib/puppet/provider/sshkey/parsed.rb
+++ b/lib/puppet/provider/sshkey/parsed.rb
@@ -46,4 +46,9 @@ Puppet::Type.type(:sshkey).provide(
'/etc/ssh/ssh_known_hosts'
end
end
+
+ def self.resource_for_record(record, resources)
+ name = "#{record[:name]}@#{record[:type]}"
+ resources[name]
+ end
end
diff --git a/lib/puppet/type/sshkey.rb b/lib/puppet/type/sshkey.rb
index 6e51cff..c3cce5d 100644
--- a/lib/puppet/type/sshkey.rb
+++ b/lib/puppet/type/sshkey.rb
@@ -8,9 +8,33 @@ module Puppet
ensurable
- newproperty(:type) do
+ def name
+ "#{self[:name]}@#{self[:type]}"
+ end
+
+ def self.title_patterns
+ [
+ [
+ %r{^(.*)@(.*)$},
+ [
+ [:name],
+ [:type],
+ ],
+ ],
+ [
+ %r{^([^@]+)$},
+ [
+ [:name],
+ ],
+ ],
+ ]
+ end
+
+ newparam(:type) do
desc 'The encryption type used. Probably ssh-dss or ssh-rsa.'
+ isnamevar
+
newvalues :'ssh-dss', :'ssh-ed25519', :'ssh-rsa', :'ecdsa-sha2-nistp256', :'ecdsa-sha2-nistp384', :'ecdsa-sha2-nistp521'
aliasvalue(:dsa, :'ssh-dss')