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

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

Issue 29557718: #3927 - Clear Nginx cache when notifications are updated (Closed)
Patch Set: Address feedback from patch-set #1 Created Sept. 28, 2017, 11:59 a.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/notificationserver/manifests/init.pp
diff --git a/modules/notificationserver/manifests/init.pp b/modules/notificationserver/manifests/init.pp
index 1d7eaf21f3a8602783bf6a8078647c6cd5a6cfa6..0f380d5083488fc0f97c8f026b70da72e8c9a692 100644
--- a/modules/notificationserver/manifests/init.pp
+++ b/modules/notificationserver/manifests/init.pp
@@ -16,6 +16,32 @@ class notificationserver($is_default = false) {
onlyif => 'test ! -d /opt/notifications'
}
+ # http://hub.eyeo.com/issues/3927
+ $cache_flush = 'find /var/cache/nginx/notification -type f -exec rm -rf {} +'
+ $cache_user = 'www-data'
+
+ # https://linux.die.net/man/5/sudoers
+ file {'/etc/sudoers.d/notification-cache':
+ content => "nginx ALL=($cache_user) NOPASSWD:/usr/bin/$cache_flush\n",
+ ensure => 'present',
+ group => 'root',
+ mode => '0440',
+ owner => 'root',
+ }
+
+ # https://docs.puppet.com/puppet/latest/types/augeas.html
+ augeas {'files/opt/notifications/.hg/hgrc/hooks/cache':
+ changes => [
+ "set hooks/changegroup.cache 'sudo -u $cache_user $cache_flush'",
+ ],
+ incl => '/opt/notifications/.hg/hgrc',
+ lens => 'Puppet.lns',
+ require => [
+ Exec['fetch_notifications'],
+ File['/etc/sudoers.d/notification-cache'],
+ ],
+ }
+
cron {'update_notifications':
command => 'hg pull -q -u -R /opt/notifications',
environment => hiera('cron::environment', []),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld