From dd401e461e4a6e250300bede2d3ab65d1193fe62 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 19 Jun 2012 21:26:33 +0200 Subject: [PATCH] Add a couple of ganeti files --- modules/ganeti2/manifests/init.pp | 22 +++++++++ .../hooks/00-dsa-configure-networking.erb | 47 +++++++++++++++++++ .../hooks/10-dsa-install-extra-packages.erb | 17 +++++++ .../hooks/20-dsa-install-bootloader.erb | 35 ++++++++++++++ .../hooks/30-dsa-install-ssh-keys.erb | 16 +++++++ .../instance-debootstrap/variants.list.erb | 2 + .../variants/dsa.conf.erb | 3 ++ 7 files changed, 142 insertions(+) create mode 100755 modules/ganeti2/templates/instance-debootstrap/hooks/00-dsa-configure-networking.erb create mode 100755 modules/ganeti2/templates/instance-debootstrap/hooks/10-dsa-install-extra-packages.erb create mode 100755 modules/ganeti2/templates/instance-debootstrap/hooks/20-dsa-install-bootloader.erb create mode 100755 modules/ganeti2/templates/instance-debootstrap/hooks/30-dsa-install-ssh-keys.erb create mode 100644 modules/ganeti2/templates/instance-debootstrap/variants.list.erb create mode 100644 modules/ganeti2/templates/instance-debootstrap/variants/dsa.conf.erb diff --git a/modules/ganeti2/manifests/init.pp b/modules/ganeti2/manifests/init.pp index 7d44ee1d..3e017b39 100644 --- a/modules/ganeti2/manifests/init.pp +++ b/modules/ganeti2/manifests/init.pp @@ -51,4 +51,26 @@ class ganeti2 { rule => 'proto tcp dport ssh @subchain \'ganeti-ssh\' { saddr ( $HOST_GANETI_V4 $HOST_GANETI_BACKEND_V4) ACCEPT; }', notarule => true, } + + file { + '/etc/ganeti/instance-debootstrap/variants.list': + content => template('ganeti2/instance-debootstrap/variants.list.erb'), + ; + '/etc/ganeti/instance-debootstrap/variants/dsa.conf': + content => template('ganeti2/instance-debootstrap/variants/dsa.conf.erb'), + ; + '/etc/ganeti/instance-debootstrap/hooks/00-dsa-configure-networking': + content => template('ganeti2/instance-debootstrap/hooks/00-dsa-configure-networking.erb'), + ; + '/etc/ganeti/instance-debootstrap/hooks/10-dsa-install-extra-packages': + content => template('ganeti2/instance-debootstrap/hooks/10-dsa-install-extra-packages.erb'), + ; + '/etc/ganeti/instance-debootstrap/hooks/20-dsa-install-bootloader': + content => template('ganeti2/instance-debootstrap/hooks/20-dsa-install-bootloader.erb'), + ; + '/etc/ganeti/instance-debootstrap/hooks/30-dsa-install-ssh-keys': + content => template('ganeti2/instance-debootstrap/hooks/30-dsa-install-ssh-keys.erb'), + ; + } + } diff --git a/modules/ganeti2/templates/instance-debootstrap/hooks/00-dsa-configure-networking.erb b/modules/ganeti2/templates/instance-debootstrap/hooks/00-dsa-configure-networking.erb new file mode 100755 index 00000000..6878e131 --- /dev/null +++ b/modules/ganeti2/templates/instance-debootstrap/hooks/00-dsa-configure-networking.erb @@ -0,0 +1,47 @@ +#!/bin/bash + +set -e + +if [ -z "$TARGET" -o ! -d "$TARGET" ]; then + echo "Missing target directory" + exit 1 +fi + +if [ ! -d "$TARGET/etc/network" ]; then + echo "Missing target network directory" + exit 1 +fi + +if [ -z "$NIC_COUNT" ]; then + echo "Missing NIC COUNT" + exit 1 +fi + +rm -f $TARGET/etc/udev/rules.d/70-persistent-net.rules + +if [ "$NIC_COUNT" -gt 0 ]; then + + cat > $TARGET/etc/network/interfaces < $TARGET/etc/resolv.conf < $TARGET/etc/default/extlinux +chroot "$TARGET" extlinux-update + +# install extlinux +chroot "$TARGET" extlinux -i /boot/extlinux + +# install boot record +dd if="$TARGET/usr/lib/extlinux/mbr.bin" of=$BLOCKDEV + +cleanup +trap - EXIT + +exit 0 diff --git a/modules/ganeti2/templates/instance-debootstrap/hooks/30-dsa-install-ssh-keys.erb b/modules/ganeti2/templates/instance-debootstrap/hooks/30-dsa-install-ssh-keys.erb new file mode 100755 index 00000000..895d9d6b --- /dev/null +++ b/modules/ganeti2/templates/instance-debootstrap/hooks/30-dsa-install-ssh-keys.erb @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +. common.sh + +if [ -z "$TARGET" -o ! -d "$TARGET" ]; then + echo "Missing target directory" + exit 1 +fi + +mkdir $TARGET/etc/ssh/userkeys +cat /etc/ssh/userkeys/root > $TARGET/etc/ssh/userkeys/root +grep '^AuthorizedKeysFile /etc/ssh/userkeys' $TARGET/etc/ssh/sshd_config || echo 'AuthorizedKeysFile /etc/ssh/userkeys/%u' >> $TARGET/etc/ssh/sshd_config + +exit 0 diff --git a/modules/ganeti2/templates/instance-debootstrap/variants.list.erb b/modules/ganeti2/templates/instance-debootstrap/variants.list.erb new file mode 100644 index 00000000..58de0a21 --- /dev/null +++ b/modules/ganeti2/templates/instance-debootstrap/variants.list.erb @@ -0,0 +1,2 @@ +default +dsa diff --git a/modules/ganeti2/templates/instance-debootstrap/variants/dsa.conf.erb b/modules/ganeti2/templates/instance-debootstrap/variants/dsa.conf.erb new file mode 100644 index 00000000..c93a1a61 --- /dev/null +++ b/modules/ganeti2/templates/instance-debootstrap/variants/dsa.conf.erb @@ -0,0 +1,3 @@ +MIRROR="http://http.debian.net/debian" +ARCH="amd64" +SUITE="squeeze" -- 2.39.2