Skip to content

Commit a028216

Browse files
Jeremy GutierrezJeremy Gutierrez
authored andcommitted
fixup! Add TLS PSK encryption support to zabbix_host
1 parent db587a9 commit a028216

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

lib/puppet/type/zabbix_host.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Puppet::Type.newtype(:zabbix_host) do
44
@doc = 'Manage zabbix hosts'
55

6+
encryptions = {
7+
unencrypted: 0b001,
8+
psk: 0b010,
9+
cert: 0b100
10+
}
11+
612
ensurable do
713
desc 'The basic property that the resource should be in.'
814
defaultvalues
@@ -21,11 +27,6 @@ def munge_boolean(value)
2127
end
2228

2329
def munge_encryption(value)
24-
encryptions = {
25-
unencrypted: 0b001,
26-
psk: 0b010,
27-
cert: 0b100
28-
}
2930
case value
3031
when Array
3132
value.uniq.reduce(0b0) { |acc, elem| acc | (encryptions[elem.to_sym].nil? ? 0b0 : encryptions[elem.to_sym]) }
@@ -41,7 +42,7 @@ def munge_encryption(value)
4142
end
4243

4344
validate do
44-
raise Puppet::ParseError, _("'tls_psk' and 'tls_psk_identity' are required for 'tls_accept' and/or 'tls_connect' set to PSK") if ((!self[:tls_accept].nil? && (munge_encryption(self[:tls_accept]) & 2) == 2) || (!self[:tls_connect].nil? && munge_encryption(self[:tls_connect]) == 2)) && (self[:tls_psk].nil? || self[:tls_psk_identity].nil?)
45+
raise Puppet::ParseError, _("'tls_psk' and 'tls_psk_identity' are required for 'tls_accept' and/or 'tls_connect' set to PSK") if ((!self[:tls_accept].nil? && (munge_encryption(self[:tls_accept]) & encryptions[:psk]) == encryptions[:psk]) || (!self[:tls_connect].nil? && munge_encryption(self[:tls_connect]) == 2)) && (self[:tls_psk].nil? || self[:tls_psk_identity].nil?)
4546
end
4647

4748
newparam(:hostname, namevar: true) do

0 commit comments

Comments
 (0)