Puppet Class: snmp::client

Defined in:
manifests/client.pp

Summary

Manage the Net-SNMP client package and configuration.

Overview

Examples:

class { 'snmp::client':
  snmp_config => [
    'defVersion 2c',
    'defCommunity public',
  ],
}

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Ensure if present or absent.

  • snmp_config (Optional[Array[String[1]]]) (defaults to: undef)

    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.

  • autoupgrade (Boolean) (defaults to: false)

    Upgrade package automatically, if there is a newer version.

  • package_name (Optional[String[1]]) (defaults to: undef)

    Name of the package. Only set this if your platform is not supported or you know what you are doing.

  • client_config (Stdlib::Absolutepath) (defaults to: '/etc/snmp/snmp.conf')

    Path to ‘snmp.conf`.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
# File 'manifests/client.pp', line 30

class snmp::client (
  Enum['present', 'absent']  $ensure        = 'present',
  Optional[Array[String[1]]] $snmp_config   = undef,
  Boolean                    $autoupgrade   = false,
  Optional[String[1]]        $package_name  = undef,
  Stdlib::Absolutepath       $client_config = '/etc/snmp/snmp.conf',
) {
  include snmp

  if $ensure == 'present' {
    if $autoupgrade {
      $package_ensure = 'latest'
    } else {
      $package_ensure = 'present'
    }
    $file_ensure = 'present'
  } else {
    $package_ensure = 'absent'
    $file_ensure = 'absent'
  }

  if ($package_name) and ($package_name != $snmp::package_name) {
    package { 'snmp-client':
      ensure => $package_ensure,
      name   => $package_name,
      before => File['snmp.conf'],
    }
  }

  if $facts['os']['family'] == 'RedHat' {
    file { '/etc/snmp':
      ensure => directory,
    }
  }

  file { 'snmp.conf':
    ensure  => $file_ensure,
    path    => $client_config,
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => template('snmp/snmp.conf.erb'),
  }
}