Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:nhuff/puppet-graphite into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nhuff committed Sep 18, 2012
2 parents 4b164a9 + b25ed5f commit 45ade24
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Modulefile
@@ -1,10 +1,10 @@
name 'KrisBuytaert-graphite'
version '0.98.14'
version '0.98.15'
source 'github'
author 'Kris Buytaert'
license 'GPL'
summary 'This module installs and configures graphite'
project_page ''

## Add dependencies, if any:
# dependency 'username/name', '>= 1.2.0'
dependency 'ripienaar/concat', '>= 0.1.0'
29 changes: 29 additions & 0 deletions README
Expand Up @@ -3,6 +3,32 @@ graphite
This is a puppet-graphite module.
All bugs procduced by Kris.Buytaert@gmail.com

This module depends on

https://github.com/ripienaar/puppet-concat


I've made the packaged versions of graphite-web, carbon and whisper.
available on



yumrepo { 'monitoringsucks':
baseurl => 'http://pulp.inuits.eu/pulp/repos/monitoring',
descr => 'MonitoringSuck at Inuits',
gpgcheck => '0',
}
You also use your own repo
And you also need to have EPEL available e.g from

yumrepo {'epel':
baseurl => 'http://pulp.inuits.eu/pulp/repos/epel/6/x86_64/',
descr => 'Epel Repo at Inuits',
gpgcheck => '0',
}




Usage :

Expand All @@ -16,4 +42,7 @@ graphite::carbon::storage {"default_1min_for_1day":

Note that without this define you won't have the default behaviour.

More Detailed Examples on how to use this module including a fully functional
Vagrant box can be found on
https://github.com/KrisBuytaert/vagrant-graphite.git

6 changes: 2 additions & 4 deletions manifests/carbon/config.pp
Expand Up @@ -13,17 +13,15 @@
# [Remember: No empty lines between comments and class definition]
class graphite::carbon::config {
include concat::setup
concat { '/etc/carbon/storage-schemas.conf':
concat { $graphite::r_schema_file:
group => '0',
mode => '0644',
owner => '0',
notify => Service['carbon'];
}
concat::fragment { 'header':
target => '/etc/carbon/storage-schemas.conf',
target => $graphite::r_schema_file,
order => 0,
source => 'puppet:///modules/graphite/storage-schemas.conf'
}


}
23 changes: 19 additions & 4 deletions manifests/carbon/storage.pp
@@ -1,9 +1,24 @@
define graphite::carbon::storage ( $pattern,$retentions){
# Define: graphite::carbon::storage
#
# Add a storage schema entry to carbon
#
# Parameters:
# pattern : Metric pattern to match (required)
# retentions: Retention rules for the metric as a string (required)
# order : Order the rules appear in the schema file (default=10)
#
# Example:
#
# graphite::carbon::storage{'default_1min_for_1day':
# pattern => '.*',
# retentions => '60s:1d',
# }
#
define graphite::carbon::storage ( $pattern,$retentions,$order=10){
concat::fragment {$name:
target => '/etc/carbon/storage-schemas.conf',
order => 10,
target => $graphite::r_schema_file,
order => $order,
content => template('graphite/storage-schemas.erb'),
notify => Service['carbon']
}

}
27 changes: 26 additions & 1 deletion manifests/init.pp
Expand Up @@ -2,6 +2,10 @@
#
# This module manages graphite
#
# == Parameters
# local_settings_file: path to the graphite web local_settings.py file
# schema_file: path to the storage-schemas.conf file
# time_zone: time zone to set in local_settings.py file
# == Sample Usage:
#
# include graphite
Expand All @@ -10,7 +14,28 @@
#
# * Implement user creation.
#
class graphite{
class graphite(
$local_settings_file = 'UNSET',
$schema_file = 'UNSET',
$time_zone = 'UNSET'
){

include graphite::params

$r_local_settings_file = $local_settings_file ? {
'UNSET' => $graphite::params::local_settings_file,
default => $local_settings_file
}

$r_schema_file = $schema_file ? {
'UNSET' => $graphite::params::schema_file,
default => $schema_file,
}

$r_time_zone = $time_zone ? {
'UNSET' => $graphite::params::time_zone,
default => $time_zone,
}

include graphite::carbon
include graphite::whisper
Expand Down
7 changes: 4 additions & 3 deletions manifests/params.pp
Expand Up @@ -10,8 +10,9 @@
#
# * Implement user creation.
#
class graphite::params ($time_zone = undef) {


class graphite::params {
$time_zone = undef
$schema_file = '/etc/carbon/storage-schemas.conf'
$local_settings_file = '/etc/graphite-web/local_settings.py'
}

6 changes: 2 additions & 4 deletions manifests/web.pp
Expand Up @@ -14,13 +14,11 @@
#
# * Update documentation
#
class graphite::web ($time_zone = $::graphite::params::time_zone) {
class graphite::web {

require graphite::params
include graphite::web::package
class {'graphite::web::config':
time_zone => $time_zone,
}
include graphite::web::config
include graphite::web::service
}

Expand Down
5 changes: 3 additions & 2 deletions manifests/web/config.pp
Expand Up @@ -11,11 +11,12 @@
# Sample Usage:
#
# [Remember: No empty lines between comments and class definition]
class graphite::web::config ($time_zone = undef){
class graphite::web::config {

$time_zone = $graphite::r_time_zone
file {'local_settings.py':
ensure => file,
path => '/etc/graphite-web/local_settings.py',
path => $graphite::r_local_settings_file,
owner => 'root',
group => 'root',
mode => '0644',
Expand Down
42 changes: 42 additions & 0 deletions spec/classes/graphite_spec.rb
@@ -0,0 +1,42 @@
require 'spec_helper'

describe 'graphite' do
let(:facts) {{:concat_basedir => '/var/lib/puppet/concat'}}
context 'Default' do
it {
should contain_package('carbon')
should contain_package('whisper')
should contain_package('graphite-web')
should contain_file('local_settings.py').
with_content(/#TIME_ZONE = 'America\/Los_Angeles'/).
with_path('/etc/graphite-web/local_settings.py')
should contain_concat('/etc/carbon/storage-schemas.conf')
}
end

context 'With local_settings_file =>' do
let(:params) {{
:local_settings_file => '/opt/graphite/webapp/graphite/local_settings.py'
}}
it {
should contain_file('local_settings.py').
with_path('/opt/graphite/webapp/graphite/local_settings.py')
}
end
context 'with schema_file =>' do
let(:params) {{
:schema_file => '/opt/graphite/conf/storage-schemas.conf'
}}
it {
should contain_concat('/opt/graphite/conf/storage-schemas.conf')
}
end
context 'with time_zone =>' do
let (:params) {{ :time_zone => 'America/Chicago' }}

it {
should contain_file('local_settings.py').
with_content(/TIME_ZONE = 'America\/Chicago/)
}
end
end
52 changes: 52 additions & 0 deletions spec/defines/graphite__carbon__storage_spec.rb
@@ -0,0 +1,52 @@
require 'spec_helper'

describe 'graphite::carbon::storage' do
let (:facts) {{ :concat_basedir => '/var/lib/puppet/concat' }}
context 'Default' do
let (:pre_condition) {'include graphite'}
let (:title) {'graphite-default'}
let (:params) {{
:pattern => '.*',
:retentions => '60s:1d'
}}

it {
should contain_concat__fragment('graphite-default').with(
'target' => '/etc/carbon/storage-schemas.conf',
'content' => /\[graphite-default\]\s+pattern = \.\*\s+retentions = 60s:1d/m,
'order' => 10
)
}
end
context 'with schema_file =>' do
let (:pre_condition) {"class {'graphite': schema_file => '/storage-schemas.conf'}"}
let (:title) {'graphite-default'}
let (:params) {{
:pattern => '.*',
:retentions => '60s:1d'
}}

it {
should contain_concat__fragment('graphite-default').with(
'target' => '/storage-schemas.conf',
'content' => /\[graphite-default\]\s+pattern = \.\*\s+retentions = 60s:1d/m
)
}
end
context 'with order =>' do
let (:pre_condition) {'include graphite'}
let (:title) {'graphite-default'}
let (:params) {{
:pattern => '.*',
:retentions => '60s:1d',
:order => 99,
}}

it {
should contain_concat__fragment('graphite-default').with(
'order' => 99
)
}
end

end

0 comments on commit 45ade24

Please sign in to comment.