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: Approach using two execs and find Created July 6, 2015, 4:14 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
@@ -119,6 +119,29 @@
require => Package['nginx']
}
+ $log_path = '/var/log/nginx'
+
+ $user_quoted = shellquote($nginx::params::user)
+ $chown_find_cmd_base = "find ${log_path} -mindepth 1 -maxdepth 1 -type f \( \! -user ${user_quoted} -o \! -group adm \)"
+ $chown_cmd = "$chown_find_cmd_base -ls -exec chown ${user_quoted}.adm {} \;"
+ $chown_onlyif_cmd = "test $(${chown_find_cmd_base} -print |wc -l) -gt 0"
+ exec {"set_logfiles_owner":
+ command => $chown_cmd,
+ onlyif => $chown_onlyif_cmd,
+ path => '/bin:/usr/bin',
mathias 2015/07/09 14:28:47 Please use "/usr/bin:/bin".
+ require => Package['nginx'],
+ }
+
+ $chmod_find_cmd_base = "find ${log_path} -mindepth 1 -maxdepth 1 -type f \! -perm 0640"
+ $chmod_cmd = "$chmod_find_cmd_base -ls -exec chmod 0640 {} \;"
+ $chmod_onlyif_cmd = "test $(${chmod_find_cmd_base} -print |wc -l) -gt 0"
+ exec {"set_logfiles_permissions":
+ command => $chmod_cmd,
+ onlyif => $chmod_onlyif_cmd,
+ path => '/bin:/usr/bin',
mathias 2015/07/09 14:28:47 It may actually be easier to use a class-wide `Exe
+ require => Package['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