Add CUSTOMIZE_DIR to personalize the installation
authorGuido Trotter <ultrotter@google.com>
Fri, 13 Feb 2009 11:18:29 +0000 (11:18 +0000)
committerGuido Trotter <ultrotter@google.com>
Fri, 13 Feb 2009 11:18:29 +0000 (11:18 +0000)
The scripts in this directory, if defined, will be executed using
run-parts, allowing some customization of the instance after the
debootstrap OS has acted and before handing back the instance to ganeti.

Reviewed-by: iustinp

README
create.in
defaults

diff --git a/README b/README
index 271bdd7..99040bc 100644 (file)
--- a/README
+++ b/README
@@ -58,6 +58,9 @@ named 'defaults' in the source distribution for more details):
 - EXTRAPKGS: most OSes will need some extra packages installed to make
   them work nicely under Xen; the example file containts a few
   suggestions
+- CUSTOMIZE_DIR: a directory containing customization script for the instance.
+  (by default $sysconfdir/ganeti/instance-debootstrap.d) See "Customization of
+  the instance" below.
 - GENERATE_CACHE: if 'yes' (the default), the installation process will
   save and reuse a cache file to speed reinstalls (located under
   $localstatedir/cache/ganeti-instance-debootstrap)
@@ -75,6 +78,35 @@ is installed on, not the cluster master. This is indeed not a very good
 model of using this OS but currently the OS interface in ganeti is
 limiting.
 
+Customization of the instance
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If run-parts is in the os create script, and the CUSTOMIZE_DIR (by default
+$sysconfdir/ganeti/instance-debootstrap.d, /etc/ganeti/instance-debootstrap.d
+if you configured the os with --sysconfdir=/etc) directory exists any
+executable whose name matches the run-parts execution rules (quoting
+run-parts(8): the  names  must consist entirely of upper and lower case
+letters, digits, underscores, and hyphens) is executed to allow further
+personalization of the installation. The following environment variables are
+passed, in addition to the ones ganeti passes to the OS scripts:
+
+TARGET: directory in which the filesystem is mounted
+SUITE: suite installed by debootstrap (eg: lenny)
+ARCH: target architecture
+PARTITION_STYLE: style of the disk partitioning (see above)
+EXTRA_PKGS: extra packages installed by debootstrap
+BLOCKDEV: ganeti block device
+FSYSDEV: device in which the filesystem resides (the one mounted in TARGET)
+
+The scripts in CUSTOMIZE_DIR can exit with an error code to signal an error in
+the instance creation, should they fail.
+
+The scripts in CUSTOMIZE_DIR should not start any long-term processes or
+daemons using this directory, otherwise the installation will fail because it
+won't be able to umount the filesystem from the directory, and hand the
+instance back to Ganeti.
+
+
 Caching
 ~~~~~~~
 
index a32df5c..5f05c18 100755 (executable)
--- a/create.in
+++ b/create.in
@@ -48,6 +48,7 @@ fi
 : ${SUITE:="lenny"}
 : ${ARCH:=""}
 : ${EXTRA_PKGS:=""}
+: ${CUSTOMIZE_DIR:="@sysconfdir@/ganeti/instance-debootstrap.d"}
 : ${GENERATE_CACHE:="yes"}
 : ${CLEAN_CACHE:="14"} # number of days to keep a cache file
 : ${PARTITION_STYLE:="none"} # disk partition style
@@ -173,6 +174,16 @@ elif [ -e $TMPDIR/etc/event.d/tty1 ]; then
   rm $TMPDIR/etc/event.d/tty1
 fi
 
+RUN_PARTS=`which run-parts`
+
+if [ -n "$RUN_PARTS" -a -n "$CUSTOMIZE_DIR" -a -d "$CUSTOMIZE_DIR" ]; then
+  TARGET=$TMPDIR
+  BLOCKDEV=$blockdev
+  FSYSDEV=$filesystem_dev
+  export TARGET SUITE ARCH PARTITION_STYLE EXTRA_PKGS BLOCKDEV FSYSDEV
+  $RUN_PARTS $CUSTOMIZE_DIR
+fi
+
 # execute cleanups
 cleanup
 trap - EXIT
index e2c73ae..76b3643 100644 (file)
--- a/defaults
+++ b/defaults
 # EXTRA_PKGS="acpi-support-base,console-tools,udev,linux-image-amd64"
 #
 
+# CUSTOMIZE_DIR: a directory containing scripts to customize the installation.
+# The scripts are executed using run-parts
+# By default /etc/ganeti/instance-debootstrap.d
+# CUSTOMIZE_DIR="/etc/ganeti/instance-debootstrap.d"
+
 # GENERATE_CACHE: if set to yes (the default), create new cache files;
 # any other value will disable the generation of cache files (but they
 # will still be used if they exist)