aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-17 12:46:37 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-19 16:19:17 +0100
commitcfa8eb925ff0115d5d4b2298f7d9a054b869fa75 (patch)
tree7ec29ae80af561a848a9c9da7f01731345afe587 /modules
parent82caf31189f11a9bca4836260e8ee8ba954690f2 (diff)
downloadPuppet-cfa8eb925ff0115d5d4b2298f7d9a054b869fa75.tar.gz
Puppet-cfa8eb925ff0115d5d4b2298f7d9a054b869fa75.tar.zst
Puppet-cfa8eb925ff0115d5d4b2298f7d9a054b869fa75.zip
Add puppet_apply script with lockfile
Diffstat (limited to 'modules')
-rw-r--r--modules/base_installation/files/cronie/puppet-post-merge4
-rw-r--r--modules/base_installation/files/scripts/puppet_apply23
-rw-r--r--modules/base_installation/files/scripts/puppet_reset_and_apply2
-rw-r--r--modules/base_installation/manifests/cronie.pp4
-rw-r--r--modules/base_installation/manifests/puppet.pp6
5 files changed, 34 insertions, 5 deletions
diff --git a/modules/base_installation/files/cronie/puppet-post-merge b/modules/base_installation/files/cronie/puppet-post-merge
index ac5e3ff..f5c21a7 100644
--- a/modules/base_installation/files/cronie/puppet-post-merge
+++ b/modules/base_installation/files/cronie/puppet-post-merge
@@ -1,7 +1,7 @@
1#!/bin/bash 1#!/bin/bash
2## Run Puppet locally using puppet apply 2## Run Puppet locally using puppet_apply
3git submodule update --init 3git submodule update --init
4/usr/bin/puppet apply `pwd`/manifests/site.pp 4/usr/local/sbin/puppet_apply `pwd`/manifests/site.pp
5 5
6## Log status of the Puppet run 6## Log status of the Puppet run
7if [ $? -eq 0 ] 7if [ $? -eq 0 ]
diff --git a/modules/base_installation/files/scripts/puppet_apply b/modules/base_installation/files/scripts/puppet_apply
new file mode 100644
index 0000000..69673cc
--- /dev/null
+++ b/modules/base_installation/files/scripts/puppet_apply
@@ -0,0 +1,23 @@
1#!/bin/bash
2
3lockfile=/var/run/puppet-apply.lock
4path=`dirname $0`
5path=`cd $path/..; pwd`
6
7if [ $(id -u) -gt 0 ]; then
8 echo "You must be root to run this script." >&2
9 exit 2
10fi
11
12if (set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null; then
13 trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT
14
15 puppet apply "$@"
16
17 rm -f "$lockfile"
18 trap - INT TERM EXIT
19else
20 echo "Failed to acquire lockfile: $lockfile." >&2
21 echo "Held by $(cat $lockfile 2>/dev/null)" >&2
22 exit 1
23fi
diff --git a/modules/base_installation/files/scripts/puppet_reset_and_apply b/modules/base_installation/files/scripts/puppet_reset_and_apply
index 6743044..0350e6e 100644
--- a/modules/base_installation/files/scripts/puppet_reset_and_apply
+++ b/modules/base_installation/files/scripts/puppet_reset_and_apply
@@ -11,4 +11,4 @@ fi
11git reset --hard origin/$branch 11git reset --hard origin/$branch
12 12
13git submodule update --init 13git submodule update --init
14puppet apply --test manifests/site.pp 14puppet_apply --test manifests/site.pp
diff --git a/modules/base_installation/manifests/cronie.pp b/modules/base_installation/manifests/cronie.pp
index e8d5dfd..e8f3e20 100644
--- a/modules/base_installation/manifests/cronie.pp
+++ b/modules/base_installation/manifests/cronie.pp
@@ -19,13 +19,13 @@ class base_installation::cronie inherits base_installation {
19 } 19 }
20 cron { 'puppet-apply': 20 cron { 'puppet-apply':
21 ensure => present, 21 ensure => present,
22 command => "cd $base_installation::puppet_code_path ; puppet apply $base_installation::puppet_code_path/manifests/site.pp", 22 command => "cd $base_installation::puppet_code_path ; puppet_apply $base_installation::puppet_code_path/manifests/site.pp",
23 user => root, 23 user => root,
24 minute => '*/20' 24 minute => '*/20'
25 } 25 }
26 cron { 'puppet-apply-reboot': 26 cron { 'puppet-apply-reboot':
27 ensure => present, 27 ensure => present,
28 command => "cd $base_installation::puppet_code_path ; puppet apply $base_installation::puppet_code_path/manifests/site.pp", 28 command => "cd $base_installation::puppet_code_path ; puppet_apply $base_installation::puppet_code_path/manifests/site.pp",
29 user => root, 29 user => root,
30 special => "reboot" 30 special => "reboot"
31 } 31 }
diff --git a/modules/base_installation/manifests/puppet.pp b/modules/base_installation/manifests/puppet.pp
index 6f7732d..0cb43bc 100644
--- a/modules/base_installation/manifests/puppet.pp
+++ b/modules/base_installation/manifests/puppet.pp
@@ -39,6 +39,12 @@ class base_installation::puppet (
39 source => "puppet:///modules/base_installation/scripts/report_print.rb" 39 source => "puppet:///modules/base_installation/scripts/report_print.rb"
40 } 40 }
41 41
42 file { '/usr/local/sbin/puppet_apply':
43 mode => "0755",
44 ensure => present,
45 source => "puppet:///modules/base_installation/scripts/puppet_apply",
46 }
47
42 unless empty(find_file($password_seed)) { 48 unless empty(find_file($password_seed)) {
43 $ldap_password = generate_password(24, $password_seed, "ldap") 49 $ldap_password = generate_password(24, $password_seed, "ldap")
44 $ssha_ldap_seed = generate_password(5, $password_seed, "ldap_seed") 50 $ssha_ldap_seed = generate_password(5, $password_seed, "ldap_seed")