Left: | ||
Right: |
OLD | NEW |
---|---|
1 class nginx ( | 1 class nginx ( |
2 $worker_processes = $nginx::params::worker_processes, | 2 $worker_processes = $nginx::params::worker_processes, |
3 $worker_connections = $nginx::params::worker_connections, | 3 $worker_connections = $nginx::params::worker_connections, |
4 $ssl_session_cache = $nginx::params::ssl_session_cache | 4 $ssl_session_cache = $nginx::params::ssl_session_cache |
5 ) inherits nginx::params { | 5 ) inherits nginx::params { |
6 | 6 |
7 apt::source {'nginx': | 7 apt::source {'nginx': |
8 location => "http://nginx.org/packages/ubuntu", | 8 location => "http://nginx.org/packages/ubuntu", |
9 repos => "nginx", | 9 repos => "nginx", |
10 key => "7BD9BF62", | 10 key => "7BD9BF62", |
(...skipping 10 matching lines...) Expand all Loading... | |
21 ensure => '1.8.0-1~precise', | 21 ensure => '1.8.0-1~precise', |
22 require => Apt::Source['nginx'] | 22 require => Apt::Source['nginx'] |
23 } | 23 } |
24 | 24 |
25 File { | 25 File { |
26 owner => root, | 26 owner => root, |
27 group => root, | 27 group => root, |
28 mode => 0644, | 28 mode => 0644, |
29 } | 29 } |
30 | 30 |
31 Exec { | |
32 path => '/usr/bin:/bin', | |
33 logoutput => 'on_failure', | |
34 } | |
35 | |
36 | |
31 file {'/etc/nginx/nginx.conf': | 37 file {'/etc/nginx/nginx.conf': |
32 content => template('nginx/nginx.conf.erb'), | 38 content => template('nginx/nginx.conf.erb'), |
33 require => Package['nginx'], | 39 require => Package['nginx'], |
34 notify => Service['nginx'] | 40 notify => Service['nginx'] |
35 } | 41 } |
36 | 42 |
37 file {'/etc/nginx/sites-available': | 43 file {'/etc/nginx/sites-available': |
38 ensure => directory, | 44 ensure => directory, |
39 require => Package['nginx'] | 45 require => Package['nginx'] |
40 } | 46 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 require => File["/etc/nginx/sites-available/${domain}"], | 118 require => File["/etc/nginx/sites-available/${domain}"], |
113 content => template('nginx/logrotate.erb') | 119 content => template('nginx/logrotate.erb') |
114 } | 120 } |
115 } | 121 } |
116 | 122 |
117 file {'/etc/logrotate.d/nginx': | 123 file {'/etc/logrotate.d/nginx': |
118 source => 'puppet:///modules/nginx/logrotate', | 124 source => 'puppet:///modules/nginx/logrotate', |
119 require => Package['nginx'] | 125 require => Package['nginx'] |
120 } | 126 } |
121 | 127 |
128 $log_path = '/var/log/nginx' | |
mathias
2015/07/10 10:57:46
Just used once and not an nginx::param anyway? The
Fred
2015/07/13 12:53:01
Done.
| |
129 $user_quoted = shellquote($nginx::params::user) | |
mathias
2015/07/10 10:57:46
As far as I can see, there is no need to explicitl
Fred
2015/07/13 12:53:00
Done.
| |
130 $find_cmd_base = ['find', $log_path, '-mindepth', '1', '-maxdepth', '1', '-typ e', 'f'] | |
131 $find_kill_exec = ['-exec', 'sh', '-c', 'ps -p $$ -o ppid= | xargs kill -TERM' , ';'] | |
mathias
2015/07/10 10:57:46
This definitely needs an explaining comment! ;-)
Fred
2015/07/13 12:53:00
Done.
| |
132 | |
133 $find_chown_base = [$find_cmd_base, '-not', '(', '-user', $user_quoted, '-and' , '-group', 'adm', ')'] | |
134 $find_chown_exec = ['-ls', '-exec', 'chown', "${user_quoted}.adm", '{}', ';'] | |
135 | |
136 exec {"set_logfiles_owner": | |
137 command => shellquote($find_chown_base, $find_chown_exec), | |
138 unless => shellquote($find_chown_base, $find_kill_exec), | |
139 require => Package['nginx'], | |
mathias
2015/07/10 10:57:46
With the subscription to Service['nginx'] the requ
Fred
2015/07/13 12:53:01
Done.
| |
140 subscribe => Service['nginx'], | |
141 } | |
142 | |
143 $find_chmod_base = [$find_cmd_base, '-not', '-perm', '0640'] | |
144 $find_chmod_exec = ['-ls', '-exec', 'chmod', '0640', '{}', ';'] | |
145 | |
146 exec {"set_logfiles_permissions": | |
147 command => shellquote($find_chmod_base, $find_chmod_exec), | |
148 unless => shellquote($find_chmod_base, $find_kill_exec), | |
149 require => Package['nginx'], | |
150 subscribe => Service['nginx'], | |
151 } | |
152 | |
122 service {'nginx': | 153 service {'nginx': |
123 ensure => running, | 154 ensure => running, |
124 enable => true, | 155 enable => true, |
125 restart => '/etc/init.d/nginx reload', | 156 restart => '/etc/init.d/nginx reload', |
126 hasstatus => true, | 157 hasstatus => true, |
127 require => File['/etc/nginx/nginx.conf'] | 158 require => File['/etc/nginx/nginx.conf'] |
128 } | 159 } |
129 } | 160 } |
OLD | NEW |