Index: modules/nginx/manifests/init.pp |
=================================================================== |
--- a/modules/nginx/manifests/init.pp |
+++ b/modules/nginx/manifests/init.pp |
@@ -28,6 +28,12 @@ |
mode => 0644, |
} |
+ Exec { |
+ path => '/usr/bin:/bin', |
+ logoutput => 'on_failure', |
+ } |
+ |
+ |
file {'/etc/nginx/nginx.conf': |
content => template('nginx/nginx.conf.erb'), |
require => Package['nginx'], |
@@ -119,6 +125,31 @@ |
require => Package['nginx'] |
} |
+ $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.
|
+ $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.
|
+ $find_cmd_base = ['find', $log_path, '-mindepth', '1', '-maxdepth', '1', '-type', 'f'] |
+ $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.
|
+ |
+ $find_chown_base = [$find_cmd_base, '-not', '(', '-user', $user_quoted, '-and', '-group', 'adm', ')'] |
+ $find_chown_exec = ['-ls', '-exec', 'chown', "${user_quoted}.adm", '{}', ';'] |
+ |
+ exec {"set_logfiles_owner": |
+ command => shellquote($find_chown_base, $find_chown_exec), |
+ unless => shellquote($find_chown_base, $find_kill_exec), |
+ 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.
|
+ subscribe => Service['nginx'], |
+ } |
+ |
+ $find_chmod_base = [$find_cmd_base, '-not', '-perm', '0640'] |
+ $find_chmod_exec = ['-ls', '-exec', 'chmod', '0640', '{}', ';'] |
+ |
+ exec {"set_logfiles_permissions": |
+ command => shellquote($find_chmod_base, $find_chmod_exec), |
+ unless => shellquote($find_chmod_base, $find_kill_exec), |
+ require => Package['nginx'], |
+ subscribe => Service['nginx'], |
+ } |
+ |
service {'nginx': |
ensure => running, |
enable => true, |