Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace instances of validate_re with Enum type #146

Merged
merged 1 commit into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@
$dlmod = $snmp::params::dlmod,
$extends = $snmp::params::extends,
$snmpd_config = $snmp::params::snmpd_config,
$disable_authorization = $snmp::params::disable_authorization,
$do_not_log_traps = $snmp::params::do_not_log_traps,
$do_not_log_tcpwrappers = $snmp::params::do_not_log_tcpwrappers,
Enum['yes','no'] $disable_authorization = $snmp::params::disable_authorization,
Enum['yes','no'] $do_not_log_traps = $snmp::params::do_not_log_traps,
Enum['yes','no'] $do_not_log_tcpwrappers = $snmp::params::do_not_log_tcpwrappers,
$trap_handlers = $snmp::params::trap_handlers,
$trap_forwards = $snmp::params::trap_forwards,
$snmptrapd_config = $snmp::params::snmptrapd_config,
Expand Down Expand Up @@ -374,12 +374,6 @@
validate_array($snmpd_config)
validate_array($snmptrapd_config)

# Validate our regular expressions
$states = [ '^yes$', '^no$' ]
validate_re($disable_authorization, $states, '$disable_authorization must be either yes or no.')
validate_re($do_not_log_traps, $states, '$do_not_log_traps must be either yes or no.')
validate_re($do_not_log_tcpwrappers, $states, '$do_not_log_tcpwrappers must be either yes or no.')

case $ensure {
/(present)/: {
if $autoupgrade {
Expand Down
16 changes: 5 additions & 11 deletions manifests/snmpv3_user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,13 @@
#
define snmp::snmpv3_user (
$authpass,
$authtype = 'SHA',
Enum['SHA','MD5'] $authtype = 'SHA',

$privpass = undef,
$privtype = 'AES',
$daemon = 'snmpd'
) {
# Validate our regular expressions
$hash_options = [ '^SHA$', '^MD5$' ]
validate_re($authtype, $hash_options, '$authtype must be either SHA or MD5.')
$enc_options = [ '^AES$', '^DES$' ]
validate_re($privtype, $enc_options, '$privtype must be either AES or DES.')
$daemon_options = [ '^snmpd$', '^snmptrapd$' ]
validate_re($daemon, $daemon_options, '$daemon must be either snmpd or snmptrapd.')
Enum['AES','DES'] $privtype = 'AES',

Enum['snmpd','snmptrapd'] $daemon = 'snmpd'
) {
include ::snmp

if ($daemon == 'snmptrapd') and ($::osfamily != 'Debian') {
Expand Down