Skip to content

Instantly share code, notes, and snippets.

@serainville
Created June 13, 2018 18:21
Show Gist options
  • Save serainville/b36e99b6d26ee9f41f839b5006447f84 to your computer and use it in GitHub Desktop.
Save serainville/b36e99b6d26ee9f41f839b5006447f84 to your computer and use it in GitHub Desktop.
Masterless Puppet Cron Job
class puppet-cron (
String $git_repo = "git@github.com/serainville/example.git"
){
// Let's make sure the Puppet daemon isn't running.
service { "puppet":
ensure => stopped,
enable => false,
} ->
// Pull the latest commits to our Puppet module repository efvery 4 minutes.
cron { 'puppet-pull':
ensure => present,
command => "cd /etc/puppet ; /usr/bin/git fetch ${git_repo} ; /usr/bin/git checkout FETCH_HEAD -- environments/production/modules ; /usr/bin/git checkout FETCH_HEAD -- manifests/templates ; /usr/bin/git checkout FETCH_HEAD -- files",
user => 'root',
minute => '*/4',
} ~>
cron { 'puppet-apply':
ensure => present,
command => "/usr/bin/puppet apply /etc/puppet/site.pp"
user => 'root',
minute => '*/5',
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment