expand to multiple hosts starting with tp
authorIan Kelling <ian@iankelling.org>
Mon, 18 Jan 2016 02:59:51 +0000 (18:59 -0800)
committerIan Kelling <ian@iankelling.org>
Mon, 6 Feb 2017 06:21:40 +0000 (22:21 -0800)
fai-redep
fai-revm [new file with mode: 0755]
fai/config/class/50-host-classes
fai/config/hooks/extrbase.DEFAULT [new file with mode: 0755]
fai/config/hooks/extrbase.demohost [deleted file]
fai/config/hooks/instsoft.DEFAULT [moved from fai/config/hooks/instsoft.demohost with 63% similarity]
fai/config/hooks/partition.DEFAULT [moved from fai/config/hooks/partition.demohost with 91% similarity]

index d7ba0043f9979f1292f620168417974c9f41d0e3..1626272bfc16def6c077c88bf9ef5f6b14580e88 100755 (executable)
--- a/fai-redep
+++ b/fai-redep
@@ -24,12 +24,3 @@ scp ~/.ssh/id_rsa.pub \
 s scp -r /q/root/luks root@faiserver:/srv/fai/config/distro-install-common
 ssh root@faiserver chmod -R a+rX /srv/fai/config/distro-install-common
 
-s virshrm demohost ||:
-
-for f in /var/lib/libvirt/images/demohost{,b}; do
-    [[ -e $f ]] || s qemu-img create -o preallocation=metadata -f qcow2 $f 30G
-done
-# osinfo-query os | gr jessie
-s virt-install --os-variant debian8 --cpu host -n demohost --pxe -r 2048 --vcpus 1 \
-  --disk path=/var/lib/libvirt/images/demohost \
-  --disk path=/var/lib/libvirt/images/demohostb -w bridge=br0,mac=52:54:00:9c:ef:ad
diff --git a/fai-revm b/fai-revm
new file mode 100755 (executable)
index 0000000..3b3e003
--- /dev/null
+++ b/fai-revm
@@ -0,0 +1,21 @@
+#!/bin/bash -lx
+
+# Deploy fai configuration to faiserver,
+# then start a virtual machine to test the config.
+
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
+
+cd "${BASH_SOURCE%/*}"
+
+./fai-redep
+
+s virshrm demohost ||:
+
+for f in /var/lib/libvirt/images/demohost{,b}; do
+    [[ -e $f ]] || s qemu-img create -o preallocation=metadata -f qcow2 $f 30G
+done
+# osinfo-query os | gr jessie
+s virt-install --os-variant debian8 --cpu host -n demohost --pxe -r 2048 --vcpus 1 \
+  --disk path=/var/lib/libvirt/images/demohost \
+  --disk path=/var/lib/libvirt/images/demohostb -w bridge=br0,mac=52:54:00:9c:ef:ad
index f7bda8a1afeda876c5d3391733247cc22cb80bda..5b38bb60efbd95aaa3413ee971253795e064f4d0 100755 (executable)
@@ -7,27 +7,31 @@
 
 # use a list of classes for our demo machine
 case $HOSTNAME in
-    faiserver)
-        echo "FAIBASE DEBIAN DEMO FAISERVER" ;;
     demohost)
-        echo "FAIBASE DEBIAN" ;;
-    xfcehost)
-        echo "FAIBASE DEBIAN DEMO XORG XFCE LVM";;
-    gnomehost)
-        echo "FAIBASE DEBIAN DEMO XORG GNOME";;
-    centos)
-        echo "FAIBASE CENTOS"   # you may want to add class XORG here
-        ifclass I386 && echo CENTOS6_32  # AFAIK there's no 32bit C7
-        ifclass AMD64 && echo CENTOS7_64
-        exit 0 ;; # CentOS does not use the GRUB class
-    slchost)
-        # Scientific Linux Cern, is very similar to CentOS. SLC should alsways use the class CENTOS
-        echo "FAIBASE CENTOS SLC"  # you may want to add class XORG here
-        ifclass I386 && echo SLC7_32
-        ifclass AMD64 && echo SLC7_64
-        exit 0 ;; # CentOS/SLC does not use the GRUB class
+        echo "FAIBASE DEBIAN DESKTOP" ;;
+    x2)
+        echo "FAIBASE DEBIAN DESKTOP ONE_DISK" ;;
+    tp)
+        echo "FAIBASE DEBIAN DESKTOP TWO_DISK" ;;
+    # faiserver)
+    #     echo "FAIBASE DEBIAN DEMO FAISERVER" ;;
+    # xfcehost)
+    #     echo "FAIBASE DEBIAN DEMO XORG XFCE LVM";;
+    # gnomehost)
+    #     echo "FAIBASE DEBIAN DEMO XORG GNOME";;
+    # centos)
+    #     echo "FAIBASE CENTOS"   # you may want to add class XORG here
+    #     ifclass I386 && echo CENTOS6_32  # AFAIK there's no 32bit C7
+    #     ifclass AMD64 && echo CENTOS7_64
+    #     exit 0 ;; # CentOS does not use the GRUB class
+    # slchost)
+    #     # Scientific Linux Cern, is very similar to CentOS. SLC should alsways use the class CENTOS
+    #     echo "FAIBASE CENTOS SLC"  # you may want to add class XORG here
+    #     ifclass I386 && echo SLC7_32
+    #     ifclass AMD64 && echo SLC7_64
+    #     exit 0 ;; # CentOS/SLC does not use the GRUB class
     *)
-        echo "FAIBASE DEBIAN" ;;
+        echo "FAIBASE DEBIAN DESKTOP" ;;
 esac
 
 if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
diff --git a/fai/config/hooks/extrbase.DEFAULT b/fai/config/hooks/extrbase.DEFAULT
new file mode 100755 (executable)
index 0000000..fe3eda5
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# exit for any vm which is not our test vm
+if ifclass VM && ! ifclass demohost; then
+    exit 0
+fi
+
+chattr -Rf +C /target
diff --git a/fai/config/hooks/extrbase.demohost b/fai/config/hooks/extrbase.demohost
deleted file mode 100755 (executable)
index 3f5e25c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-chattr -Rf +C /target
similarity index 63%
rename from fai/config/hooks/instsoft.demohost
rename to fai/config/hooks/instsoft.DEFAULT
index fa93c6b2fe90984dd537cf9972d8b8ad697ea31f..d2a8f760244d1399caf0c662c858a71f26fa7e86 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/bash
 
+# exit for any vm which is not our test vm
+if ifclass VM && ! ifclass demohost; then
+    exit 0
+fi
+
 f=$target/root/keyscript
 cat > $f <<EOFOUTER
 #!/bin/sh
similarity index 91%
rename from fai/config/hooks/partition.demohost
rename to fai/config/hooks/partition.DEFAULT
index 2adaad9a48d41578f37df46c5365d8a945a57084..2632da4a990c4e6685a72a5afbe656ecc49bfc9c 100755 (executable)
@@ -5,9 +5,8 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
 
 # # fai's setup-storage won't do btrfs on luks,
 # # so we do it ourself :)
-skiptask partition
 
-repartition=false
+partition=false
 
 # keyfiles generated like:
 # head -c 2048 /dev/urandom | od | s dd of=/q/root/luks/host-demohost
@@ -17,13 +16,26 @@ letters=(a)
 
 if ifclass VM; then
     d=/dev/vd
-    letters=(a b)
 else
     d=/dev/sd
 fi
-devs=()
-for letter in ${letters[@]}; do
-    devs+=($d$letter)
+
+if ifclass TWO_DISK; then
+    skiptask partition
+    devs=(${d}{a,b})
+    [[ -e /dev/md127 ]] || partition=true
+elif ifclass ONE_DISK; then
+    skiptask partition
+    devs=(${d}a)
+else
+    exit
+fi
+
+# somewhat crude detection of wehter to partition
+for dev in ${devs[@]}; do
+    for part in ${dev}{1,2,3,4}; do
+        [[ -e $part ]] || partition=true
+    done
 done
 
 
@@ -47,7 +59,7 @@ fi
 swap_end=$(( $(grep ^MemTotal: /proc/meminfo| awk '{print $2}') * 3/(${#letters[@]} * 2 ) / 1000 + boot_end ))MiB
 
 shopt -s nullglob
-if $repartition; then
+if $partition; then
     mkdir -p /tmp/fai
     for dev in ${devs[@]}; do
         for x in /dev/md*; do [[ -d $x ]] || mdadm --stop $x; done