Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/nginx/manifests/init.pp

Issue 29321355: Issue 2600 - Normalize ownership and priviliges for Nginx logs (Closed)
Patch Set: Apply 80 character line length formatting Created July 13, 2015, 1:23 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,43 @@
require => Package['nginx']
}
+ $find_cmd_base = [
+ 'find', '/var/log/nginx',
+ '-mindepth', '1', '-maxdepth', '1', '-type', 'f',
+ ]
+
+ # Kill the find process to force an exit status != 0 by finding the parent pid
+ # of the exec's sh process
+ $find_kill_exec = [
+ '-exec', 'sh', '-c',
+ 'ps -p $$ -o ppid= | xargs kill -TERM',
+ ';',
+ ]
+
+ $find_chown_base = [
+ $find_cmd_base,
+ '-not', '(', '-user', $nginx::params::user, '-and', '-group', 'adm', ')',
+ ]
+ $find_chown_exec = [
+ '-ls', '-exec', 'chown',
+ "${nginx::params::user}.adm", '{}', ';',
+ ]
+
+ exec {"set_logfiles_owner":
+ command => shellquote($find_chown_base, $find_chown_exec),
+ unless => shellquote($find_chown_base, $find_kill_exec),
+ 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),
+ subscribe => Service['nginx'],
+ }
+
service {'nginx':
ensure => running,
enable => true,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld