]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Add molly-guard hook for kvm
authorFaidon Liambotis <paravoid@debian.org>
Wed, 20 Jun 2012 18:57:18 +0000 (21:57 +0300)
committerFaidon Liambotis <paravoid@debian.org>
Wed, 20 Jun 2012 18:57:18 +0000 (21:57 +0300)
We don't really want to reboot virtualization hosts when there KVM
processes running, so stop them with a molly-guard hook.

modules/debian-org/files/molly-guard-acquire-reboot-lock [deleted file]
modules/debian-org/files/molly-guard/10-check-kvm [new file with mode: 0644]
modules/debian-org/files/molly-guard/15-acquire-reboot-lock [new file with mode: 0644]
modules/debian-org/manifests/init.pp

diff --git a/modules/debian-org/files/molly-guard-acquire-reboot-lock b/modules/debian-org/files/molly-guard-acquire-reboot-lock
deleted file mode 100755 (executable)
index dd41a4c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-# Copyright 2012 Peter Palfrader
-
-l=/var/run/reboot-lock
-exec 3> $l
-
-if ! flock --exclusive -w 0  3; then
-       echo 2>&1 "Cannot acquire reboot lock."
-       exit 1
-fi
-echo "Reboot lock acquired."
-
-ppid="$PPID"
-(
-       while kill -0 "$ppid" 2>/dev/null; do
-               sleep 1
-       done
-) &
-disown
-exit 0
diff --git a/modules/debian-org/files/molly-guard/10-check-kvm b/modules/debian-org/files/molly-guard/10-check-kvm
new file mode 100644 (file)
index 0000000..e9ed39c
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+KVMCOUNT=`pgrep -cx '^(qemu-)?kvm$'`
+if [ $KVMCOUNT != 0 ]; then
+       echo "Found $KVMCOUNT qemu-kvm instances running, aborting $MOLLYGUARD_CMD!"
+       exit 1
+fi
diff --git a/modules/debian-org/files/molly-guard/15-acquire-reboot-lock b/modules/debian-org/files/molly-guard/15-acquire-reboot-lock
new file mode 100644 (file)
index 0000000..dd41a4c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Copyright 2012 Peter Palfrader
+
+l=/var/run/reboot-lock
+exec 3> $l
+
+if ! flock --exclusive -w 0  3; then
+       echo 2>&1 "Cannot acquire reboot lock."
+       exit 1
+fi
+echo "Reboot lock acquired."
+
+ppid="$PPID"
+(
+       while kill -0 "$ppid" 2>/dev/null; do
+               sleep 1
+       done
+) &
+disown
+exit 0
index f0b70e43a5c7ae057ab7555eefb28db91e2e2bec..3d2fd217cbeb9b7c06953e482ab9439299c7a5c9 100644 (file)
@@ -32,7 +32,6 @@ class debian-org {
                        'less',
                        'lsb-release',
                        'libfilesystem-ruby1.8',
-                       'molly-guard',
                        'mtr-tiny',
                        'nload',
                        'pciutils',
@@ -70,6 +69,21 @@ class debian-org {
                }
        }
 
+
+       package { 'molly-guard':
+               ensure => installed,
+       }
+       file { '/etc/molly-guard/run.d/10-check-kvm':
+               mode    => '0755',
+               source  => 'puppet:///modules/debian-org/molly-guard/10-check-kvm',
+               require => Package['molly-guard'],
+       }
+       file { '/etc/molly-guard/run.d/15-acquire-reboot-lock':
+               mode    => '0755',
+               source  => 'puppet:///modules/debian-org/molly-guard/15-acquire-reboot-lock',
+               require => Package['molly-guard'],
+       }
+
        # This really means 'not wheezy'
 
        if $::debarchitecture != 'armhf' {
@@ -168,11 +182,6 @@ class debian-org {
                source => 'puppet:///modules/debian-org/rc.local',
                notify => Exec['rc.local start'],
        }
-       file { '/etc/molly-guard/run.d/15-acquire-reboot-lock':
-               mode    => '0755',
-               source  => 'puppet:///modules/debian-org/molly-guard-acquire-reboot-lock',
-               require => Package['molly-guard'],
-       }
        file { '/etc/dsa':
                ensure => directory,
                mode   => '0755',