summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-01-24 15:36:21 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-01-24 15:36:21 -0200
commit51c9eb050833f6927988fcd9465dc67e4c2bd4cf (patch)
tree207718df87a90d6dd6f3c133d1a43bd0a679e6b7
parent45c99882a470b33edf4789e67aca610ecd3eeda7 (diff)
downloadpuppet-puppet-51c9eb050833f6927988fcd9465dc67e4c2bd4cf.tar.gz
puppet-puppet-51c9eb050833f6927988fcd9465dc67e4c2bd4cf.tar.bz2
Implementing post-update hook
-rw-r--r--files/post-update.sh3
-rw-r--r--manifests/master/update.pp45
-rw-r--r--manifests/puppetmasterd.pp2
3 files changed, 32 insertions, 18 deletions
diff --git a/files/post-update.sh b/files/post-update.sh
index 21030b1..2d266a3 100644
--- a/files/post-update.sh
+++ b/files/post-update.sh
@@ -13,8 +13,7 @@ cd $PUPPET_DIR
lockfile ~/puppet.lock
# call external SUID script that will update PUPPET_DIR
-sudo -u puppet /usr/local/sbin/update-puppet-conf.sh \
- || echo "Updating puppet failed. Fix it manually."
+/usr/local/sbin/update-puppet-conf.sh || echo "Updating puppet failed. Fix it manually."
# remove lock
rm -f ~/puppet.lock
diff --git a/manifests/master/update.pp b/manifests/master/update.pp
index 4d6925c..fc30166 100644
--- a/manifests/master/update.pp
+++ b/manifests/master/update.pp
@@ -1,14 +1,7 @@
-class puppet::master::update {
- # cron rule to update puppet config repository every 5 minutes
- cron { "puppet-update":
- command => "/usr/local/sbin/update-puppet-conf.sh > /dev/null 2>&1",
- user => puppet,
- minute => "*/5",
- ensure => present,
- require => [ File["/usr/local/sbin/update-puppet-conf.sh"], User["puppet"] ],
- }
-
- # and the script to the cron-job above
+class puppet::master::update(
+ $method = hiera('puppet::master::update::method', 'cron')
+) {
+ # puppet update script
file { "/usr/local/sbin/update-puppet-conf.sh":
source => "puppet:///modules/puppet/update-puppet-conf.sh",
owner => "puppet",
@@ -17,12 +10,34 @@ class puppet::master::update {
ensure => present,
}
- # TODO: use a post-update hook instead of the cronjob
+ # cron rule to update puppet config repository every 5 minutes
+ cron { "puppet-update":
+ command => "/usr/local/sbin/update-puppet-conf.sh > /dev/null 2>&1",
+ user => puppet,
+ minute => "*/5",
+ ensure => $method ? {
+ 'cron' => present,
+ default => absent,
+ },
+ require => [ File["/usr/local/sbin/update-puppet-conf.sh"], User["puppet"] ],
+ }
+
+ # use a post-update hook
file { '/var/git/repositories/puppet.git/hooks/post-update':
- ensure => absent,
- mode => 0755,
- owner => gitolite,
+ mode => 4750,
+ owner => puppet,
group => gitolite,
+ ensure => $method ? {
+ 'cron' => absent,
+ default => present,
+ },
source => "puppet:///modules/puppet/post-update.sh",
}
+
+ # needed by the post-update hook above
+ if !defined(Package['procmail']) {
+ package { 'procmail':
+ ensure => present,
+ }
+ }
}
diff --git a/manifests/puppetmasterd.pp b/manifests/puppetmasterd.pp
index 16a79dd..aa428d5 100644
--- a/manifests/puppetmasterd.pp
+++ b/manifests/puppetmasterd.pp
@@ -117,7 +117,7 @@ class puppetmasterd {
}
# update config
- include puppet::master::update
+ class { 'puppet::master::update': }
# custom puppetlast command, thanks to immerda module:
# http://git.puppet.immerda.ch/?p=module-puppet.git;a=summary