Snmpd: Replace hiera by lookup

The hiera function is deprecated and does not work with the latest
hieradata version 5. It should be replaced by the new lookup
function[1].

[1] https://puppet.com/docs/puppet/7/hiera_automatic.html

With the lookup function, we can define value type and merge behavior,
but these are kept default at this moment to limit scope of this change
to just simple replacement. Adding value type might be useful to make
sure the value is in expected type (especially when a boolean value is
expected), but we will revisit that later.

example:
lookup(<NAME>, [<VALUE TYPE>], [<MERGE BEHAVIOR>], [<DEFAULT VALUE>])

Change-Id: I8f784be9a77729c83b55da634796e1565656e9e1
This commit is contained in:
Takashi Kajinami 2022-04-27 10:41:28 +09:00
parent 2b2c08a45d
commit 369134ecd8
1 changed files with 8 additions and 8 deletions

View File

@ -34,27 +34,27 @@
#
# [*snmpd_auth_type*]
# The SNMP auth type
# Defaults to hiera('snmpd_readonly_user_authtype') if set else 'MD5'
# Defaults to lookup('snmpd_readonly_user_authtype', undef, undef, 'MD5')
#
# [*snmpd_password*]
# The SNMP password
# Defaults to hiera('snmpd_readonly_user_password')
# Defaults to lookup('snmpd_readonly_user_password')
#
# [*snmpd_user*]
# The SNMP username
# Defaults to hiera('snmpd_readonly_user_name')
# Defaults to lookup('snmpd_readonly_user_name')
#
# [*step*]
# (Optional) The current step in deployment. See tripleo-heat-templates
# for more details.
# Defaults to hiera('step')
# Defaults to Integer(lookup('step'))
#
class tripleo::profile::base::snmp (
$snmpd_config = undef,
$snmpd_auth_type = hiera('snmpd_readonly_user_authtype', 'MD5'),
$snmpd_password = hiera('snmpd_readonly_user_password'),
$snmpd_user = hiera('snmpd_readonly_user_name'),
$step = Integer(hiera('step')),
$snmpd_auth_type = lookup('snmpd_readonly_user_authtype', undef, undef, 'MD5'),
$snmpd_password = lookup('snmpd_readonly_user_password'),
$snmpd_user = lookup('snmpd_readonly_user_name'),
$step = Integer(lookup('step')),
) {
if $step >= 4 {
snmp::snmpv3_user { $snmpd_user: