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
-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",
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,
+ }
+ }
}
}
# 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