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

Add $snmpv2_enable parameter #136

Merged
merged 1 commit into from
Sep 23, 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
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@
# Defines the number of retries for an AgentX request.
# Default: 5
#
# [*snmpv2_enable*]
# Disable com2sec, group, and access in snmpd.conf
#
# Default: true
#
# === Actions:
#
# Installs the Net-SNMP daemon package, service, and configuration.
Expand Down Expand Up @@ -353,6 +358,7 @@
$agentx_socket = $snmp::params::agentx_socket,
$agentx_timeout = $snmp::params::agentx_timeout,
$agentx_retries = $snmp::params::agentx_retries,
Boolean $snmpv2_enable = $snmp::params::snmpv2_enable,
) inherits snmp::params {
# Validate our booleans
validate_bool($master)
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
$safe_trap_service_hasrestart = $trap_service_hasrestart
}

$snmpv2_enable = true
$template_snmpd_conf = 'snmp/snmpd.conf.erb'
$template_snmpd_sysconfig = "snmp/snmpd.sysconfig-${::osfamily}.erb"
$template_snmptrapd = 'snmp/snmptrapd.conf.erb'
Expand Down
33 changes: 33 additions & 0 deletions spec/classes/snmp_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1282,4 +1282,37 @@
end
end
end

on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end

describe 'snmpv2_enable => true' do
let(:params) { { snmpv2_enable: true } }

it 'contains File[snmpd.conf] with expected contents' do
verify_contents(catalogue, 'snmpd.conf', [
'com2sec notConfigUser default public',
'com2sec6 notConfigUser default public',
'group notConfigGroup v1 notConfigUser',
'group notConfigGroup v2c notConfigUser',
'view systemview included .1.3.6.1.2.1.1',
'view systemview included .1.3.6.1.2.1.25.1.1',
'access notConfigGroup "" any noauth exact systemview none none'
])
end
end
describe 'snmpv2_enable => badvalue' do
let(:params) { { snmpv2_enable: 'badvalue' } }

it 'fails' do
expect do
is_expected.to raise_error(Puppet::Error, %r{"badvalue" is not a boolean.})
end
end
end
end
end
end
12 changes: 6 additions & 6 deletions templates/snmpd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ rocommunity6 <%= c %> <%= n %>
# ------------------------------------------------------------------------------
# VACM Configuration
# sec.name source community
<% if @snmpv2_enable -%>
<% @com2sec.each do |c| -%>
com2sec <%= c %>
<% end -%>
Expand All @@ -73,16 +74,15 @@ com2sec6 <%= c %>
group <%= group %>
<% end -%>

# name incl/excl subtree mask(optional)
<% @views.each do |view| -%>
view <%= view %>
<% end -%>

# group context sec.model sec.level prefix read write notif
<% @accesses.each do |access| -%>
access <%= access %>
<% end -%>

<% end -%>
# name incl/excl subtree mask(optional)
<% @views.each do |view| -%>
view <%= view %>
<% end -%>
# ------------------------------------------------------------------------------
# Typed-View Configuration

Expand Down