Puppet Class: graphite::config_gunicorn
- Inherits:
- graphite::params
- Defined in:
- manifests/config_gunicorn.pp
Overview
Class: graphite::config_gunicorn
This class configures graphite/carbon/whisper and SHOULD NOT be called directly.
Parameters
None.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'manifests/config_gunicorn.pp', line 10
class graphite::config_gunicorn inherits graphite::params {
Exec { path => '/bin:/usr/bin:/usr/sbin' }
case $::osfamily {
'Debian': {
$package_name = 'gunicorn'
# Debian has a wrapper script called `gunicorn-debian` for multiple gunicorn
# configs. Each config is stored as a separate file in /etc/gunicorn.d/.
# On debian 8 and Ubuntu 15.10, which use systemd, the gunicorn-debian
# config file has to be installed before the gunicorn package.
# TODO: special cases for deb 8 and ubuntu 15.10
file { '/etc/gunicorn.d':
ensure => directory,
}
file { '/etc/gunicorn.d/graphite':
ensure => file,
content => template('graphite/etc/gunicorn.d/graphite.erb'),
mode => '0644',
before => Package[$package_name],
require => File['/etc/gunicorn.d'],
}
}
'RedHat': {
$package_name = 'python-gunicorn'
# RedHat package is missing initscript
# RedHat 7+ uses systemd
if $::graphite::gr_service_provider == 'systemd' {
file { '/etc/systemd/system/gunicorn.service':
ensure => file,
content => template('graphite/etc/systemd/gunicorn.service.erb'),
mode => '0644',
}
file { '/etc/systemd/system/gunicorn.socket':
ensure => file,
content => template('graphite/etc/systemd/gunicorn.socket.erb'),
mode => '0755',
}
file { '/etc/tmpfiles.d/gunicorn.conf':
ensure => file,
content => template('graphite/etc/tmpfiles.d/gunicorn.conf.erb'),
mode => '0644',
}
# TODO: we should use the exec graphite-reload-systemd from config class
exec { 'gunicorn-reload-systemd':
command => 'systemctl daemon-reload',
path => ['/usr/bin', '/usr/sbin', '/bin', '/sbin'],
refreshonly => true,
subscribe => [
File['/etc/systemd/system/gunicorn.service'],
File['/etc/systemd/system/gunicorn.socket'],
File['/etc/tmpfiles.d/gunicorn.conf'],
],
before => Service['gunicorn']
}
} else {
file { '/etc/init.d/gunicorn':
ensure => file,
content => template('graphite/etc/init.d/RedHat/gunicorn.erb'),
mode => '0755',
before => Service['gunicorn'],
}
}
}
default: {
fail("wsgi/gunicorn-based graphite is not supported on ${::operatingsystem} (only supported on Debian & RedHat)")
}
}
# fix graphite's race condition on start
# if the exec fails, assume we're using a version of graphite that doesn't need it
if $graphite::gunicorn_workers > 1 {
file { '/tmp/fix-graphite-race-condition.py':
ensure => file,
source => 'puppet:///modules/graphite/fix-graphite-race-condition.py',
mode => '0755',
}
exec { 'fix graphite race condition':
command => "${::graphite::gr_python_binary} /tmp/fix-graphite-race-condition.py",
cwd => $graphite::graphiteweb_webapp_dir_REAL,
environment => 'DJANGO_SETTINGS_MODULE=graphite.settings',
user => $graphite::config::gr_web_user_REAL,
logoutput => true,
group => $graphite::config::gr_web_group_REAL,
returns => [0, 1],
refreshonly => true,
require => [
File['/tmp/fix-graphite-race-condition.py'],
File[$::graphite::storage_dir_REAL],
File[$::graphite::graphiteweb_log_dir_REAL],
File[$::graphite::graphiteweb_storage_dir_REAL],
],
before => Package[$package_name],
subscribe => Exec['Initial django db creation'],
}
}
# Only install gunicorn after graphite is ready to go
package {
$package_name:
ensure => installed,
require => [
File[$graphite::storage_dir_REAL],
File[$graphite::graphiteweb_log_dir_REAL],
Exec['Initial django db creation'],
];
}
service { 'gunicorn':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => false,
provider => $::graphite::gr_service_provider,
require => [
Package[$package_name],
File["${::graphite::graphiteweb_conf_dir_REAL}/graphite_wsgi.py"]
],
}
}
|