Skip to content

Commit

Permalink
Merge pull request #14 from jordiprats/master
Browse files Browse the repository at this point in the history
Added snmpd::extend
  • Loading branch information
jordiprats committed Apr 2, 2020
2 parents 4b88102 + b445077 commit db0429d
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.2.6

* Added **snmpd::extend**

## 0.2.5

* flag to ignore not prexistent users in autoACL mode
Expand Down
2 changes: 2 additions & 0 deletions examples/fail_autoacl.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# this example should FAIL

class { 'snmpd':
add_default_acls => false,
}
Expand Down
2 changes: 2 additions & 0 deletions examples/ignore_inexistent_autoacl_user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# snmpwalk -v3 -l authPriv -u v3testuser -a SHA -A "1234567890" -x AES -X "1234567890" 127.0.0.1 system

# this resource should be IGNORED

snmpd::acl { 'notfound':
auto_acl => true,
fail_on_absent_autoacl => false,
Expand Down
16 changes: 16 additions & 0 deletions examples/test_extend.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class { 'snmpd':
add_default_acls => false,
}

class { 'snmpd::loadavg': }

snmpd::v3user { 'v3testuser':
authpass => '1234567890',
encpass => '1234567890',
}

# snmpwalk -v3 -l authPriv -u v3testuser -a SHA -A "1234567890" -x AES -X "1234567890" 127.0.0.1 .1 | grep demodate

snmpd::extend { 'demodate':
script => '/usr/bin/date +%s',
}
23 changes: 23 additions & 0 deletions manifests/extend.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
define snmpd::extend(
$script,
$extend_name = $name,
$description = undef,
$mib_oid = undef,
$order = '42',
) {
# extend [MIBOID] NAME PROG ARGS
# works in a similar manner to the exec directive, but with a number of improvements. The MIB tables (nsExtendConfigTable etc) are indexed by the NAME token, so are unaffected by the order in
# which entries are read from the configuration files. There are two result tables - one (nsExtendOutput1Table) containing the exit status, the first line and full output (as a single string)
# for each extend entry, and the other (nsExtendOutput2Table) containing the complete output as a series of separate lines.
#
# If MIBOID is specified, then the configuration and result tables will be rooted at this point in the OID tree, but are otherwise structured in exactly the same way. This means that several
# separate extend directives can specify the same MIBOID root, without conflicting.
#
# The exit status and output is cached for each entry individually, and can be cleared (and the caching behaviour configured) using the nsCacheTable.

concat::fragment { "eyp-snmpd - extend ${extend_name}":
target => '/etc/snmp/snmpd.conf',
order => "02-${order}",
content => template("${module_name}/extend.erb"),
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eyp-snmpd",
"version": "0.2.5",
"version": "0.2.6",
"author": "eyp",
"summary": "SNMP agent management",
"license": "Apache-2.0",
Expand Down
5 changes: 5 additions & 0 deletions templates/extend.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if defined?(@description) -%>

# <%= @description %>
<% end -%>
extend <% if defined?(@mib_oid) %> <%= @mib_oid %><% end %><%= @extend_name %> <%= @script %>

0 comments on commit db0429d

Please sign in to comment.