]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add etckeeper
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 10 Aug 2016 23:13:22 +0000 (01:13 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 11 Aug 2016 00:53:50 +0000 (02:53 +0200)
manifests/install_ovh.pp
modules/etckeeper/files/additional_gitignore [new file with mode: 0644]
modules/etckeeper/manifests/init.pp [new file with mode: 0644]
modules/etckeeper/manifests/run.pp [new file with mode: 0644]

index d1e109f4a17dd421b8de096406513f57d191fc33..581e289affe811ecaa46b71a33be516e9040b57c 100644 (file)
@@ -1,13 +1,50 @@
 node default {
     include stdlib
 
-    class { 'ovh_cleanup': }
-    class { 'base_packages': }
-    class { 'locales': }
-    class { 'cron_puppet': }
+    stage { 'base_configuration':
+      before => Stage['main']
+    }
+    stage { 'base_installation':
+      before => Stage['base_configuration']
+    }
+    stage { 'preparation':
+      before => Stage['base_installation']
+    }
+
+    class { 'etckeeper':
+      stage => 'preparation'
+    }
+    class { 'ovh_cleanup':
+      stage => 'preparation'
+    }
+    etckeeper::run { 'post_preparation_stage':
+      reason => "Post puppet preparation stage",
+      stages => [Stage['preparation']]
+    }
+
+    class { 'base_packages':
+      stage => "base_installation"
+    }
+    etckeeper::run { 'post_base_installation_stage':
+      reason => "Post puppet base installation stage",
+      stages => [Stage['base_installation']]
+    }
+
+    class { 'locales':
+      stage => "base_configuration"
+    }
+    class { 'cron_puppet':
+      stage => "base_configuration"
+    }
     class { 'base_configuration':
+      stage => "base_configuration",
       hostname => 'new.immae.eu'
     }
+    etckeeper::run { 'post_base_configuration_stage':
+      reason => "Post puppet base configuration stage",
+      stages => [Stage['base_configuration']]
+    }
+
     class { 'aur': }
 
     reboot { 'after_run':
diff --git a/modules/etckeeper/files/additional_gitignore b/modules/etckeeper/files/additional_gitignore
new file mode 100644 (file)
index 0000000..5c6a485
--- /dev/null
@@ -0,0 +1,11 @@
+/ca-certificates/extracted/*
+/puppetlabs/*
+/pacman.d/gnupg/*
+!/pacman.d/gnupg/gpg.conf
+/ssl/certs/*
+/postfix/aliases.db
+/udev/hwdb.bin
+passwd-
+group-
+shadow-
+gshadow-
diff --git a/modules/etckeeper/manifests/init.pp b/modules/etckeeper/manifests/init.pp
new file mode 100644 (file)
index 0000000..d7039a2
--- /dev/null
@@ -0,0 +1,31 @@
+class etckeeper {
+  ensure_packages('etckeeper')
+
+  exec { 'etckeeper-gitignore':
+    environment => ['VCS=git', 'LOWLEVEL_PACKAGE_MANAGER=pacman'],
+    path        => '/usr/bin',
+    command     => 'mkdir -p /tmp/etckeeper/.git && cd /tmp/etckeeper && /etc/etckeeper/update-ignore.d/01update-ignore && cp /tmp/etckeeper/.gitignore /etc/.gitignore_etckeeper && rm -r /tmp/etckeeper/',
+    cwd         => '/tmp',
+    creates     => '/etc/.gitignore_etckeeper'
+  }
+
+  file { 'etckeeper-additional_gitignore':
+    source  => 'puppet:///modules/etckeeper/additional_gitignore',
+    path    => '/etc/.gitignore_additional'
+  }
+
+  exec { 'etckeeper-concat_files':
+    path        => '/usr/bin',
+    command     => 'cat /etc/.gitignore_etckeeper /etc/.gitignore_additional > /etc/.gitignore',
+    refreshonly => true,
+    subscribe   => [Exec['etckeeper-gitignore'], File['etckeeper-additional_gitignore']]
+  }
+
+  exec { 'etckeeper-init':
+    command => 'etckeeper init',
+    path    => '/usr/bin',
+    cwd     => '/etc',
+    creates => '/etc/.git'
+  }
+
+}
diff --git a/modules/etckeeper/manifests/run.pp b/modules/etckeeper/manifests/run.pp
new file mode 100644 (file)
index 0000000..ddbb4e1
--- /dev/null
@@ -0,0 +1,7 @@
+define etckeeper::run ($stages = [Stage['main']], $refreshonly = true, $reason = 'puppet run') {
+  exec { "etckeeper::run::${name}":
+    refreshonly => $refreshonly,
+    command     => "/usr/bin/etckeeper commit '${reason}' || true",
+    subscribe   => $stages
+  }
+}