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

CentOS/RHEL-friendly additions #9

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fixtures:
repositories:
stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
symlinks:
graphite: "#{source_dir}"
Empty file added bb.files.txt
Empty file.
63 changes: 40 additions & 23 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$admin_password = $::graphite::admin_password
$port = $::graphite::port
$root_dir = $::graphite::root_dir
$gr_user = $::graphite::gr_user

if ($::graphite::storage_aggregation_source == undef and
$::graphite::storage_aggregation_content == undef) {
Expand Down Expand Up @@ -35,25 +36,41 @@
$carbon_content = $::graphite::carbon_content
}

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

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',
# service scripts
case $::osfamily {
'RedHat': {
file { '/etc/init.d/carbon-cache':
ensure => present,
content => template('graphite/rhel/carbon-cache.initd'),
mode => '0555',
}
file { '/etc/init.d/graphite-web':
ensure => present,
content => template('graphite/rhel/graphite-web.initd'),
mode => '0555',
}
}
# Ubuntu/other
default: {
file {
[
'/etc/init.d/carbon-cache',
'/etc/init.d/graphite-web'
]:
ensure => link,
target => '/lib/init/upstart-job',
}
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 All @@ -75,7 +92,7 @@
}

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

Expand All @@ -94,21 +111,21 @@
}

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

file { "${root_dir}/storage/log/webapp/":
ensure => 'directory',
owner => 'www-data',
owner => $gr_user,
mode => '0775',
subscribe => Exec['graphite/install graphite-web'],
}

file { "${root_dir}/webapp/graphite/local_settings.py":
ensure => present,
source => 'puppet:///modules/graphite/local_settings.py',
content => template('graphite/local_settings.py'),
require => File["${root_dir}/storage"]
}

Expand Down
31 changes: 25 additions & 6 deletions manifests/deps.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,37 @@
#
class graphite::deps {

# common packages
ensure_packages([
'python-ldap',
'python-cairo',
'python-django',
'python-twisted',
'python-django-tagging',
'python-simplejson',
'python-memcache',
'python-pysqlite2',
'python-support',
'python-pip',
'gunicorn',
])

# OS-specific packages
case $::osfamily {
'RedHat': {
ensure_packages([
'python-memcached',
'python-gunicorn',
'Django14',
'python-sqlite2',
'pycairo',
])
}
# Ubuntu/other
default: {
ensure_packages([
'python-memcache',
'gunicorn',
'python-django',
'python-pysqlite2',
'python-cairo',
'python-support',
])
}
}

}
53 changes: 50 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
# [*root_dir*]
# Where to install Graphite.
#
# [*gr_user*]
# User to use for owner of graphite and carbon files/directories.
#
# [*gr_group*]
# Group to use for owner of graphite and carbon files/directories.
#
# [*storage_aggregation_content*]
# Optional: the content of the storage-aggregation.conf file.
#
Expand All @@ -31,18 +37,59 @@
#
# [*carbon_conf_source*]
# Optional: the source of the carbon.conf file.


#
# [*django_secret_key*]
# Optional: SECRET_KEY setting in local_settings.py for graphite.
#
# [*django_timezone*]
# Optional: TIME_ZONE setting in local_settings.py for graphite.
#
# [*smtp_server*]
# Optional: SMTP_SERVER setting in local_settings.py for graphite.
#
# [*use_ldap_auth*]
# Optional: Enable LDAP authentication for graphite.
#
# [*ldap_server*]
# Optional: LDAP server for graphite LDAP authentication.
#
# [*ldap_port*]
# Optional: LDAP server port.
#
# [*ldap_search_base*]
# Optional: LDAP search base.
#
# [*ldap_base_user*]
# Optional: LDAP base user.
#
# [*ldap_base_pass*]
# Optional: LDAP base password.
#
# [*ldap_user_query*]
# Optional: LDAP user query.
# For Active Directory use "(sAMAccountName=%s)"
class graphite(
$admin_password = $graphite::params::admin_password,
$port = $graphite::params::port,
$root_dir = $graphite::params::root_dir,
$gr_user = www-data,
$gr_group = www-data,
$storage_aggregation_content = undef,
$storage_aggregation_source = undef,
$storage_schemas_content = undef,
$storage_schemas_source = undef,
$carbon_source = undef,
$carbon_content = undef
$carbon_content = undef,
$django_secret_key = undef,
$django_timezone = 'UTC',
$smtp_server = undef,
$use_ldap_auth = 'False',
$ldap_server = 'ldap.mycompany.com',
$ldap_port = 389,
$ldap_search_base = 'OU=users,DC=mycompany,DC=com',
$ldap_base_user = 'CN=some_readonly_account,DC=mycompany,DC=com',
$ldap_base_pass = 'readonly_account_password',
$ldap_user_query = '(username=%s)',
) inherits graphite::params {
class{'graphite::deps': } ->
class{'graphite::install': } ->
Expand Down
6 changes: 4 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
class graphite::install {
$root_dir = $::graphite::root_dir
$gr_user = $::graphite::gr_user
$gr_group = $::graphite::gr_group

package { 'whisper':
ensure => installed,
Expand Down Expand Up @@ -34,8 +36,8 @@

file { '/var/log/carbon':
ensure => directory,
owner => www-data,
group => www-data,
owner => $gr_user,
group => $gr_group,
}

}
10 changes: 8 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
# Class to start carbon-cache and graphite-web processes
#
class graphite::service {
if $::osfamily == 'RedHat' {
$provider = redhat
} else {
$provider = upstart
}

service { 'carbon-cache':
ensure => running,
hasstatus => true,
hasrestart => true,
provider => upstart,
provider => $provider,
}
service { 'graphite-web':
ensure => running,
hasstatus => true,
hasrestart => true,
provider => upstart,
provider => $provider,
}
}
2 changes: 1 addition & 1 deletion spec/classes/graphite/graphite__config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

it {
should contain_file('/opt/graphite/webapp/graphite/local_settings.py').
with_source('puppet:///modules/graphite/local_settings.py')
with_content(/SECRET_KEY/)
}

end
21 changes: 12 additions & 9 deletions files/local_settings.py → templates/local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#DEBUG = True

# Set your local timezone (django will try to figure this out automatically)
TIME_ZONE = 'UTC'
TIME_ZONE = '<%= @django_timezone %>'

# Setting MEMCACHE_HOSTS to be empty will turn off use of memcached entirely
#MEMCACHE_HOSTS = ['127.0.0.1:11211']
Expand All @@ -22,16 +22,18 @@
#DOCUMENTATION_URL = "http://wiki.mycompany.com/graphite"

# Enable email-related features
#SMTP_SERVER = "mail.mycompany.com"
SMTP_SERVER = "<%= @smtp_server %>"

# LDAP / ActiveDirectory authentication setup
#USE_LDAP_AUTH = True
#LDAP_SERVER = "ldap.mycompany.com"
#LDAP_PORT = 389
#LDAP_SEARCH_BASE = "OU=users,DC=mycompany,DC=com"
#LDAP_BASE_USER = "CN=some_readonly_account,DC=mycompany,DC=com"
#LDAP_BASE_PASS = "readonly_account_password"
#LDAP_USER_QUERY = "(username=%s)" #For Active Directory use "(sAMAccountName=%s)"
USE_LDAP_AUTH = <%= @use_ldap_auth %>
<% if @use_ldap_auth -%>
LDAP_SERVER = "<%= @ldap_server %>"
LDAP_PORT = <%= @ldap_port %>
LDAP_SEARCH_BASE = "<%= @ldap_search_base %>"
LDAP_BASE_USER = "<%= @ldap_base_user %>"
LDAP_BASE_PASS = "<%= @ldap_base_pass %>"
LDAP_USER_QUERY = "<%= @ldap_user_query %>"
<% end -%>

# If sqlite won't cut it, configure your real database here (don't forget to run manage.py syncdb!)
#DATABASE_ENGINE = 'mysql' # or 'postgres'
Expand All @@ -40,3 +42,4 @@
#DATABASE_PASSWORD = 'graphite-is-awesome'
#DATABASE_HOST = 'mysql.mycompany.com'
#DATABASE_PORT = '3306'
SECRET_KEY='<%= @django_secret_key -%>'
Loading