diff options
-rw-r--r-- | manifests/site.pp | 3 | ||||
-rw-r--r-- | modules/cron-puppet/files/post-merge | 14 | ||||
-rw-r--r-- | modules/cron-puppet/manifests/init.pp | 17 |
3 files changed, 34 insertions, 0 deletions
diff --git a/manifests/site.pp b/manifests/site.pp new file mode 100644 index 0000000..1464586 --- /dev/null +++ b/manifests/site.pp | |||
@@ -0,0 +1,3 @@ | |||
1 | node default { | ||
2 | include cron-puppet | ||
3 | } | ||
diff --git a/modules/cron-puppet/files/post-merge b/modules/cron-puppet/files/post-merge new file mode 100644 index 0000000..b8dc266 --- /dev/null +++ b/modules/cron-puppet/files/post-merge | |||
@@ -0,0 +1,14 @@ | |||
1 | #!/bin/bash -e | ||
2 | ## Run Puppet locally using puppet apply | ||
3 | /usr/bin/puppet apply /etc/puppetlabs/puppet/manifests/site.pp | ||
4 | |||
5 | ## Log status of the Puppet run | ||
6 | if [ $? -eq 0 ] | ||
7 | then | ||
8 | /usr/bin/logger -i "Puppet has run successfully" -t "puppet-run" | ||
9 | exit 0 | ||
10 | else | ||
11 | /usr/bin/logger -i "Puppet has ran into an error, please run Puppet manually" -t "puppet-run" | ||
12 | exit 1 | ||
13 | fi | ||
14 | |||
diff --git a/modules/cron-puppet/manifests/init.pp b/modules/cron-puppet/manifests/init.pp new file mode 100644 index 0000000..4ce0be4 --- /dev/null +++ b/modules/cron-puppet/manifests/init.pp | |||
@@ -0,0 +1,17 @@ | |||
1 | class cron-puppet { | ||
2 | file { 'post-hook': | ||
3 | ensure => file, | ||
4 | path => '/etc/puppetlabs/puppet/.git/hooks/post-merge', | ||
5 | source => 'puppet:///modules/cron-puppet/post-merge', | ||
6 | mode => 0755, | ||
7 | owner => root, | ||
8 | group => root, | ||
9 | } | ||
10 | cron { 'puppet-apply': | ||
11 | ensure => present, | ||
12 | command => "cd /etc/puppetlabs/puppet ; /usr/bin/git pull", | ||
13 | user => root, | ||
14 | minute => '*/30', | ||
15 | require => File['post-hook'], | ||
16 | } | ||
17 | } | ||