Puppet Class: snmp::client
- Inherits:
- snmp::params
- Defined in:
- manifests/client.pp
Overview
Class: snmp::client
This class handles installing the Net-SNMP client.
Parameters:
- snmp_config
-
Array of lines to add to the client’s global snmp.conf file. See www.net-snmp.org/docs/man/snmp.conf.html for all options. Default: []
- ensure
-
Ensure if present or absent. Default: present
- autoupgrade
-
Upgrade package automatically, if there is a newer version. Default: false
- package_name
-
Name of the package. Only set this if your platform is not supported or you know what you are doing. Default: auto-set, platform specific
Actions:
Installs the Net-SNMP client package and configuration.
Requires:
Nothing.
Sample Usage:
class { 'snmp::client':
snmp_config => [ 'defVersion 2c', 'defCommunity public', ],
}
Authors:
Mike Arnold <mike@razorsedge.org>
Copyright:
Copyright © 2012 Mike Arnold, unless otherwise noted.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'manifests/client.pp', line 48
class snmp::client (
$snmp_config = $snmp::params::snmp_config,
$ensure = $snmp::params::ensure,
$autoupgrade = $snmp::params::safe_autoupgrade,
$package_name = $snmp::params::client_package_name
) inherits snmp::params {
# Validate our booleans
validate_bool($autoupgrade)
case $ensure {
/(present)/: {
if $autoupgrade == true {
$package_ensure = 'latest'
} else {
$package_ensure = 'present'
}
$file_ensure = 'present'
}
/(absent)/: {
$package_ensure = 'absent'
$file_ensure = 'absent'
}
default: {
fail('ensure parameter must be present or absent')
}
}
if $::osfamily != 'Suse' {
package { 'snmp-client':
ensure => $package_ensure,
name => $package_name,
}
}
if $::osfamily == 'RedHat' {
file { '/etc/snmp':
ensure => directory,
}
}
$req = $::osfamily ? {
'RedHat' => [Package['snmp-client'], File['/etc/snmp']],
'Suse' => undef,
default => Package['snmp-client'],
}
file { 'snmp.conf':
ensure => $file_ensure,
mode => '0644',
owner => 'root',
group => 'root',
path => $snmp::params::client_config,
content => template('snmp/snmp.conf.erb'),
require => $req,
}
}
|