Skip to content

Commit

Permalink
Merge branch 'ubuntu-port' of github.com:3dna/puppet-ganglia into 3dn…
Browse files Browse the repository at this point in the history
…a-ubuntu-port

Conflicts:
	spec/classes/params_spec.rb
  • Loading branch information
Joshua Hoblitt committed Dec 21, 2013
2 parents d11f7f4 + aed3ee5 commit 5791a6c
Show file tree
Hide file tree
Showing 7 changed files with 461 additions and 24 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ It has been tested on:

* el5.x
* el6.x
* ubuntu 12.04
* ubuntu 13.04

`$::osfamily == RedHat` and EPEL packages
-----------------------------------------
Expand Down
15 changes: 11 additions & 4 deletions manifests/gmetad/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@

class ganglia::gmetad::service inherits ganglia::gmetad {

if ($gmetad_status_command) {
$hasstatus = false
} else {
$hasstatus = true
}

service { $gmetad_service_name:
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
ensure => running,
hasstatus => $hasstatus,
hasrestart => true,
enable => true,
status => $gmetad_status_command,
}
}
18 changes: 12 additions & 6 deletions manifests/gmond/service.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# == Class: ganglia::gmond::service
#
# enables the gmond service
# # enables the gmond service
#
# === Authors
#
Expand All @@ -13,10 +12,17 @@

class ganglia::gmond::service inherits ganglia::gmond{

if ($gmond_status_command) {
$hasstatus = false
} else {
$hasstatus = true
}

service { $gmond_service_name:
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
ensure => running,
hasstatus => $hasstatus,
hasrestart => true,
enable => true,
status => $gmond_status_command,
}
}
53 changes: 45 additions & 8 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@
#

class ganglia::params {
$gmond_package_name = 'ganglia-gmond'
$gmond_service_name = 'gmond'

$gmetad_package_name = 'ganglia-gmetad'
$gmetad_service_name = 'gmetad'

# paths are the same for el5.x & el6.x
$web_package_name = 'ganglia-web'
$web_php_config = '/etc/ganglia/conf.php'
# files are the same for ubuntu and el5/el6
$web_php_erb = 'ganglia/conf.php.el6.erb'

case $::osfamily {
redhat: {
$gmond_package_name = 'ganglia-gmond'
$gmond_service_name = 'gmond'

$gmetad_package_name = 'ganglia-gmetad'
$gmetad_service_name = 'gmetad'
$gmetad_user = 'ganglia'

# paths are the same for el5.x & el6.x
$web_package_name = 'ganglia-web'
$web_php_config = '/etc/ganglia/conf.php'

case $::operatingsystemmajrelease {
# the epel packages change uid/gids + install paths between 5 & 6
5: {
Expand All @@ -50,6 +54,39 @@
}
}
}
debian: {
case $::operatingsystem {
ubuntu: {
# I use ubuntu 12.04 and 13.04, have not tested others
$gmond_package_name = 'ganglia-monitor'
$gmond_service_name = 'ganglia-monitor'

$gmetad_package_name = 'gmetad'
$gmetad_service_name = 'gmetad'
$gmetad_user = 'nobody'

$web_package_name = 'ganglia-webfrontend'
$web_php_config = '/usr/share/ganglia-webfrontend/conf.php'

$gmond_service_config = '/etc/ganglia/gmond.conf'
$gmond_service_erb = 'ganglia/gmond.conf.ubuntu.erb'

$gmetad_service_config = '/etc/ganglia/gmetad.conf'
# it's the same file as el6 with only the default user comment changed
$gmetad_service_erb = 'ganglia/gmetad.conf.el6.erb'

# ubuntu 12.10 and below didn't have a status command in the init script
if ($::lsbmajdistrelease <= 12) {
$gmond_status_command = 'pgrep -u ganglia -f /usr/sbin/gmond'
$gmetad_status_command = 'pgrep -u nobody -f /usr/sbin/gmetad'
}
}
default: {
fail("Module ${module_name} is not supported on osfamily/operatingsystem: ${::osfamily}/${::operatingsystem}")
}
}
}

default: {
fail("Module ${module_name} is not supported on ${::operatingsystem}")
}
Expand Down
30 changes: 27 additions & 3 deletions spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,41 @@
end
end

describe 'for osfamily debian' do
let :facts do
{
:osfamily => 'Debian'
}
end

describe 'for operatingsystem ubuntu' do
before { facts[:operatingsystem] = 'Ubuntu' ; facts[:lsbmajdistrelease] = 12 }

it { should contain_class('ganglia::params') }
end

describe 'for operatingsystem debian' do
before { facts[:operatingsystem] = 'Debian' }

it 'should fail' do
expect { should contain_class('ganglia::params') }.
to raise_error(Puppet::Error, /not supported on .*Debian\/Debian/)
end
end
end


describe 'unsupported osfamily' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:osfamily => 'Solaris',
:operatingsystem => 'Solaris',
}
end

it 'should fail' do
expect { should contain_class('ganglia::params') }.
to raise_error(Puppet::Error, /not supported on Debian/)
to raise_error(Puppet::Error, /not supported on Solaris/)
end
end

Expand Down
6 changes: 3 additions & 3 deletions templates/gmetad.conf.el6.erb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ gridname "<%= @gridname %>"
# setuid off
#
#-------------------------------------------------------------------------------
# User gmetad will setuid to (defaults to "ganglia")
# default: "ganglia"
# setuid_username "ganglia"
# User gmetad will setuid to (defaults to "<%= @gmetad_user %>")
# default: "<%= @gmetad_user %>"
# setuid_username "<%= @gmetad_user %>"
#
#-------------------------------------------------------------------------------
# The port gmetad will answer requests for XML
Expand Down
Loading

0 comments on commit 5791a6c

Please sign in to comment.