Skip to content

Commit

Permalink
Merge pull request #181 from ghoneycutt/data_in_module
Browse files Browse the repository at this point in the history
Convert from params to data in module
  • Loading branch information
alexjfisher authored Feb 23, 2019
2 parents e506724 + e2e1aaa commit 56869e2
Show file tree
Hide file tree
Showing 18 changed files with 327 additions and 337 deletions.
19 changes: 19 additions & 0 deletions data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
snmp::client::client_config: '/etc/snmp/snmp.conf'
snmp::client::package_name: 'snmp'
snmp::package_name: 'snmpd'
snmp::service_config: '/etc/snmp/snmpd.conf'
snmp::service_config_dir_group: 'root'
snmp::service_config_perms: '0600'
snmp::service_name: 'snmpd'
snmp::snmpd_options: "-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid"
snmp::snmptrapd_options: '-Lsd -p /var/run/snmptrapd.pid'
snmp::snmptrapd_package_name: 'snmptrapd'
snmp::sysconfig: '/etc/default/snmpd'
snmp::trap_service_config: '/etc/snmp/snmptrapd.conf'
snmp::trap_service_name: 'snmptrapd'
snmp::trap_sysconfig: '/etc/default/snmptrapd'
snmp::var_net_snmp: '/var/lib/snmp'
snmp::varnetsnmp_group: 'snmp'
snmp::varnetsnmp_owner: 'snmp'
snmp::varnetsnmp_perms: '0755'
3 changes: 3 additions & 0 deletions data/os/Debian/14.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
snmp::snmptrapd_package_name: ~
snmp::trap_service_name: ~
4 changes: 4 additions & 0 deletions data/os/Debian/18.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
snmp::snmpd_options: "-Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux -p /var/run/snmpd.pid"
snmp::varnetsnmp_group: 'Debian-snmp'
snmp::varnetsnmp_owner: 'Debian-snmp'
4 changes: 4 additions & 0 deletions data/os/Debian/9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
snmp::snmpd_options: "-Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux -p /var/run/snmpd.pid"
snmp::varnetsnmp_group: 'Debian-snmp'
snmp::varnetsnmp_owner: 'Debian-snmp'
20 changes: 20 additions & 0 deletions data/os/FreeBSD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
snmp::client::client_config: '/usr/local/etc/snmp/snmp.conf'
snmp::client::package_name: 'net-mgmt/net-snmp'
snmp::package_name: 'net-mgmt/net-snmp'
snmp::service_config: '/usr/local/etc/snmp/snmpd.conf'
snmp::service_config_dir_group: 'wheel'
snmp::service_config_dir_owner: 'root'
snmp::service_config_dir_path: '/usr/local/etc/snmp'
snmp::service_config_dir_perms: '0755'
snmp::service_config_perms: '0755'
snmp::service_name: 'snmpd'
snmp::snmpd_options: 'd'
snmp::snmptrapd_options: ~
snmp::snmptrapd_package_name: ~
snmp::trap_service_config: '/usr/local/etc/snmp/snmptrapd.conf'
snmp::trap_service_name: 'snmptrapd'
snmp::var_net_snmp: '/var/net-snmp'
snmp::varnetsnmp_group: 'wheel'
snmp::varnetsnmp_owner: 'root'
snmp::varnetsnmp_perms: '0600'
20 changes: 20 additions & 0 deletions data/os/OpenBSD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
snmp::client::client_config: '/etc/snmp/snmp.conf'
snmp::client::package_name: 'net-snmp'
snmp::package_name: 'net-snmp'
snmp::service_config: '/etc/snmp/snmpd.conf'
snmp::service_config_dir_group: 'wheel'
snmp::service_config_dir_owner: 'root'
snmp::service_config_dir_path: '/etc/snmp'
snmp::service_config_dir_perms: '0755'
snmp::service_config_perms: '0755'
snmp::service_name: 'netsnmpd'
snmp::snmpd_options: ~
snmp::snmptrapd_options: ~
snmp::snmptrapd_package_name: ~
snmp::trap_service_config: '/etc/snmp/snmptrapd.conf'
snmp::trap_service_name: 'netsnmptrapd'
snmp::var_net_snmp: '/var/net-snmp'
snmp::varnetsnmp_group: 'wheel'
snmp::varnetsnmp_owner: '_netsnmp'
snmp::varnetsnmp_perms: '0600'
19 changes: 19 additions & 0 deletions data/os/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
snmp::client::client_config: '/etc/snmp/snmp.conf'
snmp::client::package_name: 'net-snmp-utils'
snmp::package_name: 'net-snmp'
snmp::service_config: '/etc/snmp/snmpd.conf'
snmp::service_config_dir_group: 'root'
snmp::service_config_perms: '0600'
snmp::service_name: 'snmpd'
snmp::snmpd_options: '-LS0-6d'
snmp::snmptrapd_options: '-Lsd'
snmp::snmptrapd_package_name: ~
snmp::sysconfig: '/etc/sysconfig/snmpd'
snmp::trap_service_config: '/etc/snmp/snmptrapd.conf'
snmp::trap_service_name: 'snmptrapd'
snmp::trap_sysconfig: '/etc/sysconfig/snmptrapd'
snmp::var_net_snmp: '/var/lib/net-snmp'
snmp::varnetsnmp_group: 'root'
snmp::varnetsnmp_owner: 'root'
snmp::varnetsnmp_perms: '0755'
8 changes: 8 additions & 0 deletions data/os/RedHat/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
snmp::service_config_perms: '0600'
snmp::snmpd_options: '-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid'
snmp::snmptrapd_options: '-Lsd -p /var/run/snmptrapd.pid'
snmp::sysconfig: '/etc/sysconfig/snmpd'
snmp::trap_sysconfig: '/etc/sysconfig/snmptrapd'
snmp::var_net_snmp: '/var/lib/net-snmp'
snmp::varnetsnmp_perms: '0755'
18 changes: 18 additions & 0 deletions data/os/Suse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
snmp::client::client_config: '/etc/snmp/snmp.conf'
snmp::client::package_name: 'net-snmp'
snmp::package_name: 'net-snmp'
snmp::service_config: '/etc/snmp/snmpd.conf'
snmp::service_config_dir_group: 'root'
snmp::service_config_perms: '0600'
snmp::service_name: 'snmpd'
snmp::snmpd_options: 'd'
snmp::snmptrapd_options: ~
snmp::snmptrapd_package_name: ~
snmp::sysconfig: '/etc/sysconfig/net-snmp'
snmp::trap_service_config: '/etc/snmp/snmptrapd.conf'
snmp::trap_service_name: 'snmptrapd'
snmp::var_net_snmp: '/var/lib/net-snmp'
snmp::varnetsnmp_group: 'root'
snmp::varnetsnmp_owner: 'root'
snmp::varnetsnmp_perms: '0755'
10 changes: 10 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
version: 5
defaults:
datadir: data
data_hash: yaml_data
hierarchy:
- name: "osfamily/major_release"
path: "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
- name: "osfamily"
path: "os/%{facts.os.family}.yaml"
47 changes: 29 additions & 18 deletions manifests/client.pp
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# @summary
# Installs the Net-SNMP client package and configuration.
# @summary
# Manage the Net-SNMP client package and configuration.
#
# @example
# class { 'snmp::client':
# snmp_config => [ 'defVersion 2c', 'defCommunity public', ],
# snmp_config => [
# 'defVersion 2c',
# 'defCommunity public',
# ],
# }
#
# @param ensure
# Ensure if present or absent.
#
# @param snmp_config
# Array of lines to add to the client's global snmp.conf file.
# See http://www.net-snmp.org/docs/man/snmp.conf.html for all options.
#
# @param ensure
# Ensure if present or absent.
#
# @param autoupgrade
# Upgrade package automatically, if there is a newer version.
#
Expand All @@ -21,12 +24,18 @@
# Only set this if your platform is not supported or you know what you are
# doing.
#
# @param client_config
# Path to `snmp.conf`.
#
class snmp::client (
$snmp_config = $snmp::params::snmp_config,
Enum['present', 'absent'] $ensure = $snmp::params::ensure,
Boolean $autoupgrade = $snmp::params::autoupgrade,
$package_name = $snmp::params::client_package_name
) inherits snmp::params {
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 {
Expand All @@ -40,11 +49,13 @@
$file_ensure = 'absent'
}

unless $facts['os']['family'] == 'Suse' {
package { 'snmp-client':
ensure => $package_ensure,
name => $package_name,
before => File['snmp.conf'],
if $facts['os']['family'] != 'Suse' {
if $package_name != undef {
package { 'snmp-client':
ensure => $package_ensure,
name => $package_name,
before => File['snmp.conf'],
}
}
}

Expand All @@ -56,10 +67,10 @@

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

0 comments on commit 56869e2

Please sign in to comment.