Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

RHEL Support #25

Closed
wants to merge 10 commits into from
Closed
12 changes: 12 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Gareth Rushgrove <gareth@morethanseven.net>
Philip Potter <philip.potter@digital.cabinet-office.gov.uk>
Nick Stenning <nick.stenning@digital.cabinet-office.gov.uk>
Bob Walker <bob.walker@digital.cabinet-office.gov.uk>
Garima Singh <igarimasingh@gmail.com>
Dan Carley <dan.carley+github@gmail.com>
Neil Houston <neil.a.houston@gmail.com>
Nick Osborn <nick.osborn@digital.cabinet-office.gov.uk>
Sam J Sharpe <sam.sharpe@digital.cabinet-office.gov.uk>
Kushal Pisavadia <kushal.pisavadia@digital.cabinet-office.gov.uk>
Matt Bostock <matt@mattbostock.com>
Simon Croome <simon@croome.org>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ the other puppet modules I found either lacked support for
Ubuntu/Debian, relied on an undocumented package or did a lot of
wgetting.

Although I've only tested this module on Ubuntu it should work on other
distros too, maybe with minor tweaks.
Tested on Ubuntu and CentOS 7, though other RHEL variants including < 7.x
and Fedora should work (bug reports welcome).
123 changes: 95 additions & 28 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
$bind_address = $::graphite::bind_address
$port = $::graphite::port
$root_dir = $::graphite::root_dir
$user = $graphite::user
$init_style = $graphite::params::init_style
$sysconfig = $graphite::params::sysconfig

if ($::graphite::aggregation_rules_source == undef and
$::graphite::aggregation_rules_content == undef) {
Expand Down Expand Up @@ -43,32 +46,96 @@
$carbon_content = $::graphite::carbon_content
}

file {
[
'/etc/init.d/carbon-aggregator',
'/etc/init.d/carbon-cache',
'/etc/init.d/graphite-web'
]:
ensure => link,
target => '/lib/init/upstart-job',
}

file { '/etc/init/carbon-aggregator.conf':
ensure => present,
content => template('graphite/upstart/carbon-aggregator.conf'),
mode => '0555',
}
# Environment variables kept centrally, will also work for Debian
# by reworking upstart scripts to remove 'env' entries and add:
# pre-start script
# [ -f <%= @sysconfig %>/carbon-aggregator ] && \
# . <%= @sysconfig %>/carbon-aggregator
# end script
if $::osfamily == 'RedHat' {
file { "${sysconfig}/carbon-aggregator":
ensure => present,
content => template('graphite/sysconfig/carbon-aggregator'),
mode => '0644',
}
file { "${sysconfig}/carbon-cache":
ensure => present,
content => template('graphite/sysconfig/carbon-cache'),
mode => '0644',
}
file { "${sysconfig}/graphite-web":
ensure => present,
content => template('graphite/sysconfig/graphite-web'),
mode => '0644',
}
}

case $init_style {

'upstart': {
file {
[
'/etc/init.d/carbon-aggregator',
'/etc/init.d/carbon-cache',
'/etc/init.d/graphite-web'
]:
ensure => link,
target => '/lib/init/upstart-job',
}

file { '/etc/init/carbon-aggregator.conf':
ensure => present,
content => template('graphite/upstart/carbon-aggregator.conf'),
mode => '0555',
}

file { '/etc/init/carbon-cache.conf':
ensure => present,
content => template('graphite/upstart/carbon-cache.conf'),
mode => '0555',
}

file { '/etc/init/graphite-web.conf':
ensure => present,
content => template('graphite/upstart/graphite-web.conf'),
mode => '0555',
}
}
'systemd' : {
file { '/lib/systemd/system/carbon-aggregator.service':
ensure => present,
content => template('graphite/systemd/carbon-aggregator.service'),
mode => '0644',
}
file { '/lib/systemd/system/carbon-cache.service':
ensure => present,
content => template('graphite/systemd/carbon-cache.service'),
mode => '0644',
}
file { '/lib/systemd/system/graphite-web.service':
ensure => present,
content => template('graphite/systemd/graphite-web.service'),
mode => '0644',
}
}
'init', default : {
file { '/etc/init.d/carbon-aggregator':
ensure => present,
content => template('graphite/init/carbon-aggregator'),
mode => '0755',
}
file { '/etc/init.d/carbon-cache':
ensure => present,
content => template('graphite/init/carbon-cache'),
mode => '0755',
}
file { '/etc/init.d/graphite-web':
ensure => present,
content => template('graphite/init/graphite-web'),
mode => '0755',
}
}

file { '/etc/init/carbon-cache.conf':
ensure => present,
content => template('graphite/upstart/carbon-cache.conf'),
mode => '0555',
}

file { '/etc/init/graphite-web.conf':
ensure => present,
content => template('graphite/upstart/graphite-web.conf'),
mode => '0555',
}

file { "${root_dir}/conf/carbon.conf":
Expand Down Expand Up @@ -96,7 +163,7 @@
}

file { ["${root_dir}/storage", "${root_dir}/storage/whisper"]:
owner => 'www-data',
owner => $user,
mode => '0775',
}

Expand All @@ -115,14 +182,14 @@
}

file { "${root_dir}/storage/graphite.db":
owner => 'www-data',
owner => $user,
mode => '0664',
subscribe => Exec['init-db'],
}

file { "${root_dir}/storage/log/webapp/":
ensure => 'directory',
owner => 'www-data',
owner => $user,
mode => '0775',
}

Expand Down
10 changes: 6 additions & 4 deletions manifests/deps.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
# with Graphite's other dependencies.
#
class graphite::deps {
$root_dir = $::graphite::root_dir
$root_dir = $::graphite::root_dir
$packages = $::graphite::packages
$cairo_target = $::graphite::cairo_target

python::virtualenv { $root_dir: } ->
python::pip { [
Expand All @@ -23,14 +25,14 @@
virtualenv => $root_dir,
}

ensure_packages(['python-cairo'])
ensure_packages($packages)

file { "${root_dir}/lib/python2.7/site-packages/cairo":
ensure => link,
target => '/usr/lib/python2.7/dist-packages/cairo',
target => $cairo_target,
require => [
Python::Virtualenv[$root_dir],
Package['python-cairo'],
Package[$packages],
],
}
}
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
# Where to install Graphite.
# Default: /opt/graphite
#
# [*user*]
# User the graphite-web user interface runs as.
# Default: www-data for Debian-based, root for RedHat-based systems.
#
# [*carbon_aggregator*]
# Optional: Boolean, whether to run carbon-aggregator. You will need to
# provide an appropriate `carbon_content` or `carbon_source` config.
Expand Down Expand Up @@ -53,6 +57,7 @@
$bind_address = $graphite::params::bind_address,
$port = $graphite::params::port,
$root_dir = $graphite::params::root_dir,
$user = $graphite::params::user,
$carbon_aggregator = false,
$aggregation_rules_content = undef,
$aggregation_rules_source = undef,
Expand Down
38 changes: 34 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,38 @@
#
class graphite::params {
$admin_password = 'sha1$1b11b$edeb0a67a9622f1f2cfeabf9188a711f5ac7d236'
$bind_address = '127.0.0.1'
$port = 8000
$root_dir = '/opt/graphite'
$version = '0.9.12'
$bind_address = '127.0.0.1'
$port = 8000
$root_dir = '/opt/graphite'
$version = '0.9.12'

case $::osfamily {
'Debian': {
$user = 'www-data'
$sysconfig = '/etc/default'
$packages = ['python-cairo']
$cairo_target = '/usr/lib/python2.7/dist-packages/cairo'
$init_style = 'upstart'
}
'RedHat': {
$user = 'root'
$sysconfig = '/etc/sysconfig'
$packages = ['pycairo']
$cairo_target = '/usr/lib64/python2.7/site-packages/cairo'

if ($::operatingsystem != 'Fedora'
and versioncmp($::operatingsystemrelease, '7') >= 0)
or ($::operatingsystem == 'Fedora'
and versioncmp($::operatingsystemrelease, '15') >= 0) {
$init_style = 'systemd'
}
else {
$init_style = 'init'
}
}
default: {
fail("${module_name} not supported on an ${::osfamily} based system.")
}
}

}
6 changes: 3 additions & 3 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
ensure => $aggregator_ensure,
hasstatus => true,
hasrestart => true,
provider => upstart,
provider => $::graphite::params::init_style,
} ->
service { 'carbon-cache':
ensure => running,
hasstatus => true,
hasrestart => true,
provider => upstart,
provider => $::graphite::params::init_style,
}

service { 'graphite-web':
ensure => running,
hasstatus => true,
hasrestart => true,
provider => upstart,
provider => $::graphite::params::init_style,
}
}
Loading