]> gitweb.fluxo.info Git - puppet-puppet.git/commitdiff
Implementing post-update hook
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 24 Jan 2013 17:36:21 +0000 (15:36 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 24 Jan 2013 17:36:21 +0000 (15:36 -0200)
files/post-update.sh
manifests/master/update.pp
manifests/puppetmasterd.pp

index 21030b13eec1b698b5d2372a93328b10f7604717..2d266a398119cfdac36a2cefa4d8818445501596 100644 (file)
@@ -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
index 4d6925c0e5ecc0b997da4149db93a124f516b4e7..fc301662073ba2b5d80e53c5b06c755fdbcf85a3 100644 (file)
@@ -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,
+    }
+  }
 }
index 16a79dd014441cf9e9c575e12f68becbeb992a85..aa428d56cdd3f927eac1df5254f4f75ec7adff7a 100644 (file)
@@ -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