Puppet Class: snmp

Defined in:
manifests/init.pp

Summary

Manage the Net-SNMP and Net-SNMP trap daemon package, service, and configuration.

Overview

Examples:

class { 'snmp':
  com2sec       => [ 'notConfigUser default PassW0rd' ],
  manage_client => true,
}

# Only configure and run the snmptrap daemon:
class { 'snmp':
  ro_community        => 'SeCrEt',
  service_ensure      => 'stopped',
  trap_service_ensure => 'running',
  trap_handlers       => [
    'default /usr/bin/perl /usr/bin/traptoemail me@somewhere.local',
    'IF-MIB::linkDown /home/nba/bin/traps down',
  ],
}

Parameters:

  • agentaddress (Array[String[1]]) (defaults to: ['udp:127.0.0.1:161', 'udp6:[::1]:161'])

    An array of addresses, on which snmpd will listen for queries.

  • snmptrapdaddr (Array[String[1]]) (defaults to: ['udp:127.0.0.1:162', 'udp6:[::1]:162'])

    An array of addresses, on which snmptrapd will listen to receive incoming SNMP notifications.

  • ro_community (Variant[Undef, String[1], Array[String[1]]]) (defaults to: 'public')

    Read-only (RO) community string or array for agent and snmptrap daemon.

  • ro_community6 (Variant[Undef, String[1], Array[String[1]]]) (defaults to: 'public')

    Read-only (RO) community string or array for IPv6 agent.

  • rw_community (Variant[Undef, String[1], Array[String[1]]]) (defaults to: undef)

    Read-write (RW) community string or array agent.

  • rw_community6 (Variant[Undef, String[1], Array[String[1]]]) (defaults to: undef)

    Read-write (RW) community string or array for IPv6 agent.

  • ro_network (Variant[Array, Stdlib::IP::Address::V4, Stdlib::IP::Address::V4::CIDR]) (defaults to: '127.0.0.1')

    Network that is allowed to RO query the daemon. Can be string or array.

  • ro_network6 (Variant[Array, Stdlib::IP::Address::V6, Stdlib::IP::Address::V6::CIDR]) (defaults to: '::1')

    Network that is allowed to RO query the daemon via IPv6. Can be string or array.

  • rw_network (Variant[Array, Stdlib::IP::Address::V4, Stdlib::IP::Address::V4::CIDR]) (defaults to: '127.0.0.1')

    Network that is allowed to RW query the daemon. Can be string or array.

  • rw_network6 (Variant[Array, Stdlib::IP::Address::V6, Stdlib::IP::Address::V6::CIDR]) (defaults to: '::1')

    Network that is allowed to RW query the daemon via IPv6. Can be string or array.

  • contact (String[1]) (defaults to: 'Unknown')

    Responsible person for the SNMP system.

  • location (String[1]) (defaults to: 'Unknown')

    Location of the SNMP system.

  • sysname (String[1]) (defaults to: $facts['networking']['fqdn'])

    Name of the system (hostname).

  • services (Integer) (defaults to: 72)

    For a host system, a good value is 72 (application + end-to-end layers).

  • com2sec (Array[String[1]]) (defaults to: ['notConfigUser default public'])

    An array of VACM com2sec mappings. Must provide SECNAME, SOURCE and COMMUNITY. See www.net-snmp.org/docs/man/snmpd.conf.html#lbAL for details.

  • com2sec6 (Array[String[1]]) (defaults to: ['notConfigUser default public'])

    An array of VACM com2sec6 mappings. Must provide SECNAME, SOURCE and COMMUNITY. See www.net-snmp.org/docs/man/snmpd.conf.html#lbAL for details.

  • groups (Array[String[1]]) (defaults to: [ 'notConfigGroup v1 notConfigUser', 'notConfigGroup v2c notConfigUser', ])

    An array of VACM group mappings. Must provide GROUP, <v1|v2c|usm|tsm|ksm>, SECNAME. See www.net-snmp.org/docs/man/snmpd.conf.html#lbAL for details.

  • views (Array[String[1]]) (defaults to: [ 'systemview included .1.3.6.1.2.1.1', 'systemview included .1.3.6.1.2.1.25.1.1', ])

    An array of views that are available to query. Must provide VNAME, TYPE, OID, and [MASK]. See www.net-snmp.org/docs/man/snmpd.conf.html#lbAL for details.

  • accesses (Array[String[1]]) (defaults to: [ 'notConfigGroup "" any noauth exact systemview none none', ])

    An array of access controls that are available to query. Must provide GROUP, CONTEXT, <any|v1|v2c|usm|tsm|ksm>, LEVEL, PREFX, READ, WRITE, and NOTIFY. See www.net-snmp.org/docs/man/snmpd.conf.html#lbAL for details.

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

    Array of dlmod lines to add to the snmpd.conf file. Must provide NAME and PATH (ex. “cmaX /usr/lib64/libcmaX64.so”). See www.net-snmp.org/docs/man/snmpd.conf.html#lbBD for details.

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

    Array of extend lines to add to the snmpd.conf file. Must provide NAME, PROG and ARG. See www.net-snmp.org/docs/man/snmpd.conf.html#lbBA for details.

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

    Array of pass lines to add to the snmpd.conf file. Must provide MIBOID and PROG. See www.net-snmp.org/docs/man/snmpd.conf.html#lbBB for details.

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

    Array of pass_persist lines to add to the snmpd.conf file. Must provide MIBOID and PROG. See www.net-snmp.org/docs/man/snmpd.conf.html#lbBB for details.

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

    Safety valve. Array of lines to add to the snmpd.conf file. See www.net-snmp.org/docs/man/snmpd.conf.html for all options.

  • disable_authorization (Enum['yes','no']) (defaults to: 'no')

    Disable all access control checks.

  • do_not_log_traps (Enum['yes','no']) (defaults to: 'no')

    Disable the logging of notifications altogether.

  • do_not_log_tcpwrappers (Enum['yes','no']) (defaults to: 'no')

    Disable the logging of tcpwrappers messages, e.g. “Connection from UDP: ” messages in syslog.

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

    An array of programs to invoke on receipt of traps. Must provide OID and PROGRAM (ex. “IF-MIB::linkDown /bin/traps down”). See www.net-snmp.org/docs/man/snmptrapd.conf.html#lbAI for details.

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

    An array of destinations to send to on receipt of traps. Must provide OID and DESTINATION (ex. “IF-MIB::linkUp udp:1.2.3.5:162”). See www.net-snmp.org/docs/man/snmptrapd.conf.html#lbAI for details.

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

    Safety valve. Array of lines to add to the snmptrapd.conf file. See www.net-snmp.org/docs/man/snmptrapd.conf.html for all options.

  • manage_client (Boolean) (defaults to: false)

    Whether to install the Net-SNMP client package.

  • manage_snmptrapd (Boolean) (defaults to: true)

    Whether to install the Net-SNMP snmptrapd package. True by default, except on Darwin where there is no service available.

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

    Safety valve. 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.

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

    Ensure if present or absent.

  • autoupgrade (Boolean) (defaults to: false)

    Upgrade package automatically, if there is a newer version.

  • manage_packages (Boolean) (defaults to: true)

    Controls whether module attempts to manage the packages for SNMPD. On by default, except on Darwin where it ships with the OS.

  • package_name (String[1]) (defaults to: 'net-snmp')

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

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

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

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

    Commandline options passed to snmpd via init script.

  • sysconfig (Stdlib::Absolutepath) (defaults to: '/etc/sysconfig/snmpd')

    Path to sysconfig file for snmpd.

  • trap_sysconfig (Stdlib::Absolutepath) (defaults to: '/etc/sysconfig/snmptrapd')

    Path to sysconfig file for snmptrapd.

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

    Path to snmptrapd.conf.

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

    Path to snmpd.conf.

  • service_config_perms (Stdlib::Filemode) (defaults to: '0600')

    Set permissions for the service configuration file.

  • service_config_dir_path (Stdlib::Absolutepath) (defaults to: '/usr/local/etc/snmp')

    Path to services configuration directory.

  • service_config_dir_owner (String[1]) (defaults to: 'root')

    Owner for the service configuration directory.

  • service_config_dir_group (String[1]) (defaults to: 'root')

    Set group ownership for the service configuration directory.

  • service_config_dir_perms (String[1]) (defaults to: '0755')

    Mode of the service configuration directory.

  • service_ensure (Stdlib::Ensure::Service) (defaults to: 'running')

    Ensure if service is running or stopped.

  • service_name (String[1]) (defaults to: 'snmpd')

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

  • service_enable (Boolean) (defaults to: true)

    Start service at boot.

  • service_hasstatus (Boolean) (defaults to: true)

    Service has status command.

  • service_hasrestart (Boolean) (defaults to: true)

    Service has restart command.

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

    Commandline options passed to snmptrapd via init script.

  • trap_service_ensure (Stdlib::Ensure::Service) (defaults to: 'stopped')

    Ensure if service is running or stopped.

  • trap_service_name (String[1]) (defaults to: 'snmptrapd')

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

  • trap_service_enable (Boolean) (defaults to: false)

    Start service at boot.

  • trap_service_hasstatus (Boolean) (defaults to: true)

    Service has status command.

  • trap_service_hasrestart (Boolean) (defaults to: true)

    Service has restart command.

  • openmanage_enable (Boolean) (defaults to: false)

    Adds the smuxpeer directive to the snmpd.conf file to allow net-snmp to talk with Dell’s OpenManage

  • master (Boolean) (defaults to: false)

    Include the master option to enable AgentX registrations.

  • agentx_perms (Optional[Stdlib::Filemode]) (defaults to: undef)

    Defines the permissions and ownership of the AgentX Unix Domain socket.

  • agentx_ping_interval (Optional[Integer]) (defaults to: undef)

    This will make the subagent try and reconnect every NUM seconds to the master if it ever becomes (or starts) disconnected.

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

    Defines the address the master agent listens at, or the subagent should connect to.

  • agentx_timeout (Integer[0]) (defaults to: 1)

    Defines the timeout period (NUM seconds) for an AgentX request.

  • agentx_retries (Integer[0]) (defaults to: 5)

    Defines the number of retries for an AgentX request.

  • snmpv2_enable (Boolean) (defaults to: true)

    Disable com2sec, group, and access in snmpd.conf

  • var_net_snmp (Stdlib::Absolutepath) (defaults to: '/var/lib/net-snmp')

    Path to snmp’s var directory.

  • varnetsnmp_perms (Stdlib::Filemode) (defaults to: '0755')

    Mode of ‘var_net_snmp` directory.

  • varnetsnmp_owner (String[1]) (defaults to: 'root')

    Owner of ‘var_net_snmp` directory.

  • varnetsnmp_group (String[1]) (defaults to: 'root')

    Group of ‘var_net_snmp` directory.



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'manifests/init.pp', line 263

class snmp (
  Enum['present','absent']                                        $ensure        = 'present',
  Array[String[1]]                                                $agentaddress  = ['udp:127.0.0.1:161', 'udp6:[::1]:161'],
  Array[String[1]]                                                $snmptrapdaddr = ['udp:127.0.0.1:162', 'udp6:[::1]:162'],
  Variant[Undef, String[1], Array[String[1]]]                     $ro_community  = 'public',
  Variant[Undef, String[1], Array[String[1]]]                     $ro_community6 = 'public',
  Variant[Undef, String[1], Array[String[1]]]                     $rw_community  = undef,
  Variant[Undef, String[1], Array[String[1]]]                     $rw_community6 = undef,
  Variant[Array, Stdlib::IP::Address::V4, Stdlib::IP::Address::V4::CIDR] $ro_network    = '127.0.0.1',
  Variant[Array, Stdlib::IP::Address::V6, Stdlib::IP::Address::V6::CIDR] $ro_network6   = '::1',
  Variant[Array, Stdlib::IP::Address::V4, Stdlib::IP::Address::V4::CIDR] $rw_network    = '127.0.0.1',
  Variant[Array, Stdlib::IP::Address::V6, Stdlib::IP::Address::V6::CIDR] $rw_network6   = '::1',
  String[1]                                                       $contact       = 'Unknown',
  String[1]                                                       $location      = 'Unknown',
  String[1]                                                       $sysname       = $facts['networking']['fqdn'],
  Integer                                                         $services      = 72,
  Array[String[1]]                                                $com2sec       = ['notConfigUser  default       public'],
  Array[String[1]]                                                $com2sec6      = ['notConfigUser  default       public'],
  Array[String[1]] $groups = [
    'notConfigGroup v1            notConfigUser',
    'notConfigGroup v2c           notConfigUser',
  ],
  Array[String[1]] $views = [
    'systemview    included   .1.3.6.1.2.1.1',
    'systemview    included   .1.3.6.1.2.1.25.1.1',
  ],
  Array[String[1]] $accesses = [
    'notConfigGroup ""      any       noauth    exact  systemview none  none',
  ],
  Optional[Array[String[1]]] $dlmod                        = undef,
  Optional[Array[String[1]]] $extends                      = undef,
  Optional[Array[String[1]]] $pass                         = undef,
  Optional[Array[String[1]]] $pass_persist                 = undef,
  Optional[Array[String[1]]] $snmpd_config                 = undef,
  Enum['yes','no']           $disable_authorization        = 'no',
  Enum['yes','no']           $do_not_log_traps             = 'no',
  Enum['yes','no']           $do_not_log_tcpwrappers       = 'no',
  Optional[Array[String[1]]] $trap_handlers                = undef,
  Optional[Array[String[1]]] $trap_forwards                = undef,
  Optional[Array[String[1]]] $snmptrapd_config             = undef,
  Boolean                    $manage_client                = false,
  Boolean                    $manage_snmptrapd             = true,
  Boolean                    $manage_packages              = true,
  Optional[Array[String[1]]] $snmp_config                  = undef,
  Boolean                    $autoupgrade                  = false,
  String[1]                  $package_name                 = 'net-snmp',
  Optional[String[1]]        $snmptrapd_package_name       = undef,
  Optional[String[1]]        $snmpd_options                = undef,
  Stdlib::Absolutepath       $sysconfig                    = '/etc/sysconfig/snmpd',
  Stdlib::Absolutepath       $trap_sysconfig               = '/etc/sysconfig/snmptrapd',
  Stdlib::Absolutepath       $trap_service_config          = '/etc/snmp/snmptrapd.conf',
  Stdlib::Absolutepath       $service_config               = '/etc/snmp/snmpd.conf',
  Stdlib::Filemode           $service_config_perms         = '0600',
  Stdlib::Absolutepath       $service_config_dir_path      = '/usr/local/etc/snmp',
  String[1]                  $service_config_dir_owner     = 'root',
  String[1]                  $service_config_dir_group     = 'root',
  String[1]                  $service_config_dir_perms     = '0755',
  Stdlib::Ensure::Service    $service_ensure               = 'running',
  String[1]                  $service_name                 = 'snmpd',
  Boolean                    $service_enable               = true,
  Boolean                    $service_hasstatus            = true,
  Boolean                    $service_hasrestart           = true,
  Optional[String[1]]        $snmptrapd_options            = undef,
  Stdlib::Ensure::Service    $trap_service_ensure          = 'stopped',
  String[1]                  $trap_service_name            = 'snmptrapd',
  Boolean                    $trap_service_enable          = false,
  Boolean                    $trap_service_hasstatus       = true,
  Boolean                    $trap_service_hasrestart      = true,
  Boolean                    $openmanage_enable            = false,
  Boolean                    $master                       = false,
  Optional[Stdlib::Filemode] $agentx_perms                 = undef,
  Optional[Integer]          $agentx_ping_interval         = undef,
  Optional[String[1]]        $agentx_socket                = undef,
  Integer[0]                 $agentx_timeout               = 1,
  Integer[0]                 $agentx_retries               = 5,
  Boolean                    $snmpv2_enable                = true,
  Stdlib::Absolutepath       $var_net_snmp                 = '/var/lib/net-snmp',
  String[1]                  $varnetsnmp_owner             = 'root',
  String[1]                  $varnetsnmp_group             = 'root',
  Stdlib::Filemode           $varnetsnmp_perms             = '0755',
) {
  $template_snmpd_conf           = 'snmp/snmpd.conf.erb'
  $template_snmpd_sysconfig      = "snmp/snmpd.sysconfig-${facts['os']['family']}.erb"
  $template_snmpd_service_dropin = "snmp/snmpd.service-dropin-${facts['os']['family']}.epp"

  $template_snmptrapd            = 'snmp/snmptrapd.conf.erb'
  $template_snmptrapd_sysconfig  = "snmp/snmptrapd.sysconfig-${facts['os']['family']}.erb"
  $template_snmptrapd_service_dropin = "snmp/snmptrapd.service-dropin-${facts['os']['family']}.epp"

  if $ensure == 'present' {
    if $autoupgrade {
      $package_ensure = 'latest'
    } else {
      $package_ensure = 'present'
    }
    $file_ensure = 'present'
    $trap_service_ensure_real = $trap_service_ensure
    $trap_service_enable_real = $trap_service_enable
    $var_net_snmp_ensure = 'directory'

    # Make sure that if $trap_service_ensure == 'running' that
    # $service_ensure_real == 'running' on Debian.
    if ($facts['os']['family'] == 'Debian') and ($trap_service_ensure_real == 'running') {
      $service_ensure_real = $trap_service_ensure_real
      $service_enable_real = $trap_service_enable_real
    } else {
      $service_ensure_real = $service_ensure
      $service_enable_real = $service_enable
    }
  } else {
    $package_ensure = 'absent'
    $file_ensure = 'absent'
    $service_ensure_real = 'stopped'
    $service_enable_real = false
    $trap_service_ensure_real = 'stopped'
    $trap_service_enable_real = false
    $var_net_snmp_ensure = absent
  }

  if $service_ensure == 'running' {
    $snmpdrun = 'yes'
  } else {
    $snmpdrun = 'no'
  }
  if $trap_service_ensure == 'running' {
    $trapdrun = 'yes'
  } else {
    $trapdrun = 'no'
  }

  $manage_snmp_conf_requires = $manage_packages ? {
    true  => Package['snmpd'],
    false => undef,
  }

  $manage_snmp_trap_conf_requires = $manage_packages ? {
    true  => $snmptrapd_package_name ? {
      default => Package['snmptrapd'],
      undef   => Package['snmpd'],
    },
    false => undef,
  }

  if $manage_client {
    class { 'snmp::client':
      ensure      => $ensure,
      autoupgrade => $autoupgrade,
      snmp_config => $snmp_config,
    }
  }

  if $package_name and $manage_packages {
    package { 'snmpd':
      ensure => $package_ensure,
      name   => $package_name,
    }
  }

  # Since ubuntu 16.04 platforms, there is a differente snmptrad package
  if ($snmp::snmptrapd_package_name) and ($manage_snmptrapd) and $manage_packages {
    package { 'snmptrapd':
      ensure => $package_ensure,
      name   => $snmp::snmptrapd_package_name,
    }
  }

  if $var_net_snmp {
    file { 'var-net-snmp':
      ensure  => $var_net_snmp_ensure,
      path    => $var_net_snmp,
      owner   => $varnetsnmp_owner,
      group   => $varnetsnmp_group,
      mode    => $varnetsnmp_perms,
      require => $manage_snmp_conf_requires,
    }
  }

  if $facts['os']['family'] == 'FreeBSD' {
    file { $service_config_dir_path:
      ensure  => 'directory',
      owner   => $service_config_dir_owner,
      group   => $service_config_dir_group,
      mode    => $service_config_dir_perms,
      require => $manage_snmp_conf_requires,
    }
  }

  if ($facts['os']['family'] == 'Suse') and ($manage_snmptrapd) {
    file { '/etc/init.d/snmptrapd':
      source  => '/usr/share/doc/packages/net-snmp/rc.snmptrapd',
      owner   => 'root',
      group   => 'root',
      mode    => '0755',
      require => $manage_snmp_trap_conf_requires,
      before  => Service['snmptrapd'],
    }
  }

  file { 'snmpd.conf':
    ensure  => $file_ensure,
    path    => $service_config,
    owner   => 'root',
    group   => $service_config_dir_group,
    mode    => $service_config_perms,
    content => template($template_snmpd_conf),
    require => $manage_snmp_conf_requires,
  }
  if ($manage_snmptrapd) {
    file { 'snmptrapd.conf':
      ensure  => $file_ensure,
      path    => $trap_service_config,
      owner   => 'root',
      group   => $service_config_dir_group,
      mode    => $service_config_perms,
      content => template($template_snmptrapd),
      require => $manage_snmp_conf_requires,
    }
  }

  unless $facts['os']['family'] in ['FreeBSD', 'Darwin'] {
    # Note: The snmpd.systemd file is ignored in current versions of Debian
    # and Ubuntu where the snmp daemons are managed by systemd. This is for
    # backwards compatibility with other tools.
    file { 'snmpd.sysconfig':
      ensure  => $file_ensure,
      path    => $sysconfig,
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template($template_snmpd_sysconfig),
      require => $manage_snmp_conf_requires,
      notify  => Service['snmpd'],
    }
  }

  # Debian (as of v9) and Ubuntu (as of v18.04) use systemd
  if ( $facts['os']['family'] == 'Debian' ) {
    systemd::dropin_file { 'snmpd.conf':
      unit    => 'snmpd.service',
      content => epp($template_snmpd_service_dropin),
    } ~> Service['snmpd']
  }

  if ($facts['os']['family'] == 'RedHat') and ($manage_snmptrapd) {
    file { 'snmptrapd.sysconfig':
      ensure  => $file_ensure,
      path    => $trap_sysconfig,
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template($template_snmptrapd_sysconfig),
      require => $manage_snmp_trap_conf_requires,
      notify  => Service['snmptrapd'],
    }
  } elsif $facts['os']['family'] == 'Debian' and $manage_snmptrapd {
    systemd::dropin_file { 'snmptrapd.conf':
      unit    => 'snmptrapd.service',
      content => epp($template_snmptrapd_service_dropin),
    } ~> Service['snmpd']

    # Note: The snmptrapd.systemd file is ignored in current versions of Debian
    # and Ubuntu where the snmp daemons are managed by systemd. This is for
    # backwards compatibility with other tools.
    file { 'snmptrapd.sysconfig':
      ensure  => $file_ensure,
      path    => $trap_sysconfig,
      owner   => 'root',
      group   => 'root',
      mode    => '0644',
      content => template($template_snmptrapd_sysconfig),
      require => $manage_snmp_trap_conf_requires,
      notify  => Service['snmptrapd'],
    }

    service { 'snmptrapd':
      ensure     => $trap_service_ensure_real,
      name       => $trap_service_name,
      enable     => $trap_service_enable_real,
      hasstatus  => $trap_service_hasstatus,
      hasrestart => $trap_service_hasrestart,
      require    => File['var-net-snmp'],
      subscribe  => File['snmptrapd.conf'],
    }

    if $manage_packages {
      Package['snmptrapd'] -> Service['snmptrapd']
    }
  }

  if ($facts['os']['family'] != 'Debian') and ($manage_snmptrapd) {
    service { 'snmptrapd':
      ensure     => $trap_service_ensure_real,
      name       => $trap_service_name,
      enable     => $trap_service_enable_real,
      hasstatus  => $trap_service_hasstatus,
      hasrestart => $trap_service_hasrestart,
      require    => File['var-net-snmp'],
      subscribe  => File['snmptrapd.conf'],
    }
  }

  service { 'snmpd':
    ensure     => $service_ensure_real,
    name       => $service_name,
    enable     => $service_enable_real,
    hasstatus  => $service_hasstatus,
    hasrestart => $service_hasrestart,
    require    => File['var-net-snmp'],
    subscribe  => File['snmpd.conf'],
  }

  if ($facts['os']['family'] == 'Debian') and ($manage_snmptrapd) {
    File['snmptrapd.conf'] ~> Service['snmpd']
  }
}