From 2f609a7223765667cc7f680a54603c3748aaa1a0 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 28 Feb 2013 12:20:33 -0500 Subject: [PATCH] Adds RHEL support to snmpd module. Parameterize the package name so that things work on multiple distros. Also, updates the snmpd module so that that the init script is written out on Ubuntu only (this is not required on RHEL). Change-Id: Id5868b85fc0a7a6057d9be16c76dad2efb834f0e Reviewed-on: https://review.openstack.org/23186 Reviewed-by: Jeremy Stanley Reviewed-by: Khai Do Reviewed-by: James E. Blair Reviewed-by: Clark Boylan Approved: James E. Blair Tested-by: Jenkins --- modules/snmpd/manifests/init.pp | 35 ++++++++++++++++++++----------- modules/snmpd/manifests/params.pp | 17 +++++++++++++++ 2 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 modules/snmpd/manifests/params.pp diff --git a/modules/snmpd/manifests/init.pp b/modules/snmpd/manifests/init.pp index 99a5e965dd..e4fa2b3759 100644 --- a/modules/snmpd/manifests/init.pp +++ b/modules/snmpd/manifests/init.pp @@ -1,8 +1,12 @@ # == Class: snmpd # class snmpd { + + include snmpd::params + package { 'snmpd': ensure => present, + name => $::snmpd::params::package_name, } service { 'snmpd': ensure => running, @@ -12,19 +16,26 @@ class snmpd { File['/etc/init.d/snmpd'], ], } - # This file is only needed on machines pre-precise. There is a bug in - # the previous init script versions which causes them to attempt - # snmptrapd even if it's configured not to run, and then to report - # failure. - file { '/etc/init.d/snmpd': - ensure => present, - owner => 'root', - group => 'root', - mode => '0755', - source => 'puppet:///modules/snmpd/snmpd.init', - replace => true, - require => Package['snmpd'], + + if ($::operatingsystem == 'Ubuntu') { + # This file is only needed on machines pre-precise. There is a bug in + # the previous init script versions which causes them to attempt + # snmptrapd even if it's configured not to run, and then to report + # failure. + file { '/etc/init.d/snmpd': + ensure => present, + owner => 'root', + group => 'root', + mode => '0755', + source => 'puppet:///modules/snmpd/snmpd.init', + replace => true, + require => Package['snmpd'], + } + + File['/etc/init.d/snmpd'] -> Service['snmpd'] + } + file { '/etc/snmp/snmpd.conf': ensure => present, owner => 'root', diff --git a/modules/snmpd/manifests/params.pp b/modules/snmpd/manifests/params.pp new file mode 100644 index 0000000000..0808467bf1 --- /dev/null +++ b/modules/snmpd/manifests/params.pp @@ -0,0 +1,17 @@ +# Class: snmpd::params +# +# This class holds parameters that need to be +# accessed by other classes. +class snmpd::params { + case $::osfamily { + 'Redhat': { + $package_name = 'net-snmp' + } + 'Debian', 'Ubuntu': { + $package_name = 'snmpd' + } + default: { + fail("Unsupported osfamily: ${::osfamily} The 'snmpd' module only supports osfamily Ubuntu or Redhat(slaves only).") + } + } +}