From: Faidon Liambotis Date: Wed, 20 Jun 2012 18:57:18 +0000 (+0300) Subject: Add molly-guard hook for kvm X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=2c8889fb72d9bfcc3cff5de485c927d64e7f78ed;p=mirror%2Fdsa-puppet.git Add molly-guard hook for kvm We don't really want to reboot virtualization hosts when there KVM processes running, so stop them with a molly-guard hook. --- 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 index dd41a4c19..000000000 --- a/modules/debian-org/files/molly-guard-acquire-reboot-lock +++ /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 index 000000000..e9ed39ca3 --- /dev/null +++ b/modules/debian-org/files/molly-guard/10-check-kvm @@ -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 index 000000000..dd41a4c19 --- /dev/null +++ b/modules/debian-org/files/molly-guard/15-acquire-reboot-lock @@ -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 diff --git a/modules/debian-org/manifests/init.pp b/modules/debian-org/manifests/init.pp index f0b70e43a..3d2fd217c 100644 --- a/modules/debian-org/manifests/init.pp +++ b/modules/debian-org/manifests/init.pp @@ -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',