summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sitemodules/profiles/files/base/etckeeper_post_command.sh8
-rw-r--r--sitemodules/profiles/manifests/base.pp23
2 files changed, 31 insertions, 0 deletions
diff --git a/sitemodules/profiles/files/base/etckeeper_post_command.sh b/sitemodules/profiles/files/base/etckeeper_post_command.sh
new file mode 100644
index 0000000..ec10155
--- /dev/null
+++ b/sitemodules/profiles/files/base/etckeeper_post_command.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if etckeeper unclean; then
+ if ! etckeeper commit "saving uncommitted changes in /etc after puppet run"; then
+ echo "warning: etckeeper failed to commit changes in /etc using $VCS" >&2
+ fi
+fi
diff --git a/sitemodules/profiles/manifests/base.pp b/sitemodules/profiles/manifests/base.pp
index 69e369f..2a7aad2 100644
--- a/sitemodules/profiles/manifests/base.pp
+++ b/sitemodules/profiles/manifests/base.pp
@@ -237,4 +237,27 @@ class profiles::base (
ensure => absent,
}
}
+
+ package { 'etckeeper':
+ ensure => installed,
+ }
+ file { '/etc/etckeeper/post-puppet.d':
+ ensure => directory,
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ require => Package['etckeeper'],
+ }
+ file { '/etc/etckeeper/post-puppet.d/50uncommitted-changes':
+ ensure => file,
+ owner => 'root',
+ group => 'root',
+ mode => '0755',
+ source => 'puppet://modules/profiles/base/etckeeper_post_command.sh',
+ }
+
+ augeas { 'set_puppet_postrun_command':
+ context => '/etc/puppetlabs/puppet/puppet.conf',
+ changes => 'set main/postrun_command "etckeeper post-puppet"',
+ }
}