Puppet Class: graphite::config_nginx
- Inherits:
- graphite::params
- Defined in:
- manifests/config_nginx.pp
Overview
Class: graphite::config_nginx
This class configures nginx to talk to 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 144 145 146 147 148 149 |
# File 'manifests/config_nginx.pp', line 10
class graphite::config_nginx inherits graphite::params {
Exec { path => '/bin:/usr/bin:/usr/sbin' }
# we need a nginx with gunicorn for python support
package {
'nginx':
ensure => installed;
}
# Ensure that some directories exist first. This is normally handled by the
# package, but if we uninstall and reinstall nginx and delete /etc/nginx.
# By default the package manager won't replace the directory.
file {
'/etc/nginx':
ensure => directory,
mode => '0755',
require => Package['nginx'];
}
# Remove default config file, but only when it makes sense
case $::osfamily {
'Debian': {
# Ensure that some directories exist first. This is normally handled by the
# package, but if we uninstall and reinstall nginx and delete /etc/nginx.
# By default the package manager won't replace the directory.
file {
'/etc/nginx/sites-available':
ensure => directory,
mode => '0755',
require => File['/etc/nginx'];
'/etc/nginx/sites-enabled':
ensure => directory,
mode => '0755',
require => File['/etc/nginx'];
}
# Deploy configfiles
file {
'/etc/nginx/sites-available/graphite':
ensure => file,
mode => '0644',
content => template('graphite/etc/nginx/sites-available/graphite.erb'),
require => [
File['/etc/nginx/sites-available'],
Exec['Initial django db creation']
],
notify => Service['nginx'];
'/etc/nginx/sites-enabled/graphite':
ensure => link,
target => '/etc/nginx/sites-available/graphite',
require => [
File['/etc/nginx/sites-available/graphite'],
File['/etc/nginx/sites-enabled']
],
notify => Service['nginx'];
}
# Remove default config file, but only when it makes sense
if ($::graphite::gr_web_server_port == 80 and $::graphite::gr_web_server_remove_default == undef) or ($::graphite::gr_web_server_remove_default == true) {
file { '/etc/nginx/sites-enabled/default':
ensure => absent,
require => Package['nginx'],
notify => Service['nginx'];
}
}
} # Finish Debian config
# Config for RedHat
'RedHat': {
# Ensure that some directories exist first. This is normally handled by the
# package, but if we uninstall and reinstall nginx and delete /etc/nginx.
# By default the package manager won't replace the directory.
file {
'/etc/nginx/conf.d':
ensure => directory,
mode => '0755',
require => File['/etc/nginx'];
}
# Deploy config file for site
file {
'/etc/nginx/conf.d/graphite.conf':
ensure => file,
mode => '0644',
content => template('graphite/etc/nginx/sites-available/graphite.erb'),
require => [
File['/etc/nginx/conf.d'],
Exec['Initial django db creation']
],
notify => Service['nginx'];
}
# Remove default config file, but only when it makes sense
if ($::graphite::gr_web_server_port == 80 and $::graphite::gr_web_server_remove_default == undef) or ($::graphite::gr_web_server_remove_default == true) {
file { '/etc/nginx/conf.d/default.conf':
ensure => absent,
require => Package['nginx'],
notify => Service['nginx'],
}
}
}
default: {
fail('Only Debian and RedHat-like systems are supported.')
}
}
service {
'nginx':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true;
}
# HTTP basic authentication
$nginx_htpasswd_file_presence = $::graphite::nginx_htpasswd ? {
undef => absent,
default => file,
}
file {
'/etc/nginx/graphite-htpasswd':
ensure => $nginx_htpasswd_file_presence,
mode => '0400',
owner => $::graphite::config::gr_web_user_REAL,
content => $::graphite::nginx_htpasswd,
require => Package['nginx'],
notify => Service['nginx'];
}
}
|