-
Notifications
You must be signed in to change notification settings - Fork 4
/
nginx.pp
92 lines (81 loc) · 2.38 KB
/
nginx.pp
1
2
3
4
5
6
7
8
9
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
class passenger::nginx($port = 80) inherits passenger {
$root = '/opt/nginx'
$init_script = '/etc/init.d/nginx'
$config_dir = "${root}/conf"
$log_dir = "${root}/logs"
$sites_dir = "${config_dir}/sites-enabled"
$config = "${config_dir}/nginx.conf"
$mime_types = "${config_dir}/mime.types"
$daemon = "${root}/sbin/nginx"
$listen = $port
exec { 'install-passenger-nginx':
command => "passenger-install-nginx-module --extra-configure-flags='--with-http_stub_status_module' --auto --auto-download --prefix ${root}",
creates => $root,
require => [Ruby::Gem['passenger'], Package['libcurl4-openssl-dev']],
timeout => 600
}
include nagios::base
file { "${nagios::base::checks_dir}/nginx":
ensure => present,
owner => $nagios::base::user,
group => $nagios::base::user,
mode => '0700',
source => 'puppet:///modules/passenger/nagioschecks/nginx'
}
file { $init_script:
ensure => file,
owner => root,
group => root,
mode => '0755',
content => template('passenger/nginx-init.sh.erb'),
require => Exec['install-passenger-nginx']
}
file { $config:
ensure => file,
owner => root,
group => root,
mode => '0644',
content => template('passenger/nginx.conf.erb'),
require => Exec['install-passenger-nginx'],
notify => Service['nginx']
}
file { $mime_types:
ensure => file,
owner => root,
group => root,
mode => '0644',
source => 'puppet:///modules/passenger/nginx/mime.types',
require => Exec['install-passenger-nginx'],
notify => Service['nginx']
}
file { $sites_dir:
ensure => directory,
owner => root,
group => root,
require => Exec['install-passenger-nginx']
}
service { 'nginx':
ensure => running,
enable => true,
hasrestart => true,
hasstatus => true,
require => File[$init_script],
}
logrotate::rule { 'nginx':
path => "${log_dir}/*.log",
compress => true,
copytruncate => true,
dateext => true,
ifempty => false,
missingok => true
}
file { "${sites_dir}/status.conf":
ensure => file,
owner => root,
group => root,
mode => '0644',
content => template('passenger/nginx-status-vhost.conf.erb'),
notify => Service['nginx']
}
class { 'munin::nginx': port => $listen }
}