James E. Blair 3cab5e4d84 Add graphite.
Change-Id: I276641d55e966cd76013cae847061c3ac7996864
Reviewed-on: https://review.openstack.org/17094
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
2012-12-02 20:28:38 +00:00

235 lines
6.3 KiB
Puppet

# == Class: graphite
#
class graphite(
$vhost_name = $::fqdn,
$graphite_admin_user = '',
$graphite_admin_email = '',
$graphite_admin_password = '',
) {
$packages = [ 'python-django',
'python-django-tagging',
'python-cairo',
'nodejs' ]
include apache
include pip
package { $packages:
ensure => present,
}
vcsrepo { '/opt/graphite-web':
ensure => latest,
provider => git,
revision => '0.9.x',
source => 'https://github.com/graphite-project/graphite-web.git',
}
exec { 'install_graphite_web' :
command => 'python setup.py install --install-scripts=/usr/local/bin --install-lib=/usr/local/lib/python2.7/dist-packages --install-data=/var/lib/graphite',
cwd => '/opt/graphite-web',
path => '/bin:/usr/bin',
refreshonly => true,
subscribe => Vcsrepo['/opt/graphite-web'],
require => Exec['install_carbon'],
}
vcsrepo { '/opt/carbon':
ensure => latest,
provider => git,
revision => '0.9.x',
source => 'https://github.com/graphite-project/carbon.git',
}
exec { 'install_carbon' :
command => 'python setup.py install --install-scripts=/usr/local/bin --install-lib=/usr/local/lib/python2.7/dist-packages --install-data=/var/lib/graphite',
cwd => '/opt/carbon',
path => '/bin:/usr/bin',
refreshonly => true,
subscribe => Vcsrepo['/opt/carbon'],
require => Exec['install_whisper'],
}
vcsrepo { '/opt/whisper':
ensure => latest,
provider => git,
revision => '0.9.x',
source => 'https://github.com/graphite-project/whisper.git',
}
exec { 'install_whisper' :
command => 'python setup.py install',
cwd => '/opt/whisper',
path => '/bin:/usr/bin',
refreshonly => true,
subscribe => Vcsrepo['/opt/whisper'],
}
user { 'statsd':
ensure => present,
home => '/home/statsd',
shell => '/bin/bash',
gid => 'statsd',
managehome => true,
require => Group['statsd'],
}
group { 'statsd':
ensure => present,
}
file { '/var/lib/graphite':
ensure => directory,
owner => 'www-data',
group => 'www-data',
require => Package['apache2'],
}
file { '/var/log/graphite':
ensure => directory,
owner => 'www-data',
group => 'www-data',
require => Package['apache2'],
}
file { '/etc/graphite':
ensure => directory,
}
exec { 'graphite_sync_db':
user => 'www-data',
command => 'python /usr/local/bin/graphite-init-db.py /etc/graphite/admin.ini',
cwd => '/usr/local/lib/python2.7/dist-packages/graphite',
path => '/bin:/usr/bin',
onlyif => 'test ! -f /var/lib/graphite/graphite.db',
require => [ Exec['install_graphite_web'],
File['/var/lib/graphite'],
Package['apache2'],
File['/usr/local/lib/python2.7/dist-packages/graphite/local_settings.py'],
File['/usr/local/bin/graphite-init-db.py'],
File['/etc/graphite/admin.ini']],
}
apache::vhost { $vhost_name:
port => 80,
priority => '50',
docroot => '/var/lib/graphite/webapp',
template => 'graphite/graphite.vhost.erb',
}
vcsrepo { '/opt/statsd':
ensure => latest,
provider => git,
source => 'https://github.com/etsy/statsd.git',
}
file { '/etc/statsd':
ensure => directory,
}
file { '/etc/statsd/config.js':
owner => 'statsd',
group => 'statsd',
mode => '0444',
content => template('graphite/config.js.erb'),
require => File['/etc/statsd'],
}
file { '/etc/graphite/carbon.conf':
mode => '0444',
content => template('graphite/carbon.conf.erb'),
require => File['/etc/graphite'],
}
file { '/etc/graphite/graphite.wsgi':
mode => '0444',
content => template('graphite/graphite.wsgi.erb'),
require => File['/etc/graphite'],
}
file { '/etc/graphite/storage-schemas.conf':
mode => '0444',
content => template('graphite/storage-schemas.conf.erb'),
require => File['/etc/graphite'],
}
file { '/usr/local/lib/python2.7/dist-packages/graphite/local_settings.py':
mode => '0444',
content => template('graphite/local_settings.py.erb'),
require => Exec['install_graphite_web'],
}
file { '/usr/local/bin/graphite-init-db.py':
mode => '0555',
source => 'puppet:///modules/graphite/graphite-init-db.py'
}
file { '/etc/graphite/admin.ini':
mode => '0400',
owner => 'www-data',
group => 'www-data',
content => template('graphite/admin.ini'),
require => [ File['/etc/graphite'],
Package['apache2']],
}
file { '/etc/init.d/carbon-cache':
mode => '0555',
source => 'puppet:///modules/graphite/carbon-cache.init'
}
file { '/etc/init.d/statsd':
mode => '0555',
source => 'puppet:///modules/graphite/statsd.init'
}
file { '/etc/default/statsd':
mode => '0444',
source => 'puppet:///modules/graphite/statsd.default'
}
file { ['/etc/rc0.d/K10carbon-cache',
'/etc/rc1.d/K10carbon-cache',
'/etc/rc2.d/S90carbon-cache',
'/etc/rc3.d/S90carbon-cache',
'/etc/rc4.d/S90carbon-cache',
'/etc/rc5.d/S90carbon-cache',
'/etc/rc6.d/K10carbon-cache']:
ensure => link,
target => '/etc/init.d/carbon-cache',
require => File['/etc/init.d/carbon-cache'],
}
exec { 'carbon-cache-start':
command => '/etc/init.d/carbon-cache start',
require => [File['/etc/init.d/carbon-cache'],
File['/etc/graphite/carbon.conf'],
Exec['install_carbon']],
subscribe => File['/etc/init.d/carbon-cache'],
refreshonly => true,
}
file { ['/etc/rc0.d/K10statsd',
'/etc/rc1.d/K10statsd',
'/etc/rc2.d/S90statsd',
'/etc/rc3.d/S90statsd',
'/etc/rc4.d/S90statsd',
'/etc/rc5.d/S90statsd',
'/etc/rc6.d/K10statsd']:
ensure => link,
target => '/etc/init.d/statsd',
require => File['/etc/init.d/statsd'],
}
exec { 'statsd-start':
command => '/etc/init.d/statsd start',
require => [File['/etc/init.d/statsd'],
File['/etc/statsd/config.js'],
Vcsrepo['/opt/statsd']],
subscribe => File['/etc/init.d/statsd'],
refreshonly => true,
}
}