]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
storage_deploy.sh: now functional
authorThilo Fromm <thilo.fromm@profitbricks.com>
Wed, 24 Apr 2013 14:02:04 +0000 (16:02 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Tue, 30 Apr 2013 13:18:06 +0000 (15:18 +0200)
Signed-off-by: Thilo Fromm <thilo.fromm@profitbricks.com>
id_rsa.storage-auto-deploy [new file with mode: 0644]
id_rsa.storage-auto-deploy.pub [new file with mode: 0644]
storage_deploy.sh

diff --git a/id_rsa.storage-auto-deploy b/id_rsa.storage-auto-deploy
new file mode 100644 (file)
index 0000000..936a66e
--- /dev/null
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEA0eNnqeHTiG0vYxf09JMs0AIMNXdGJC/Vsl/2z3W71QJGv28S
+AWi2sa7PdsODEXcagfb3RmsGdccjBFnkbt0r2OU6Cj/DyuNT8tAhZHwjiCKpgIdc
+1QdmefrRjx2E7C+z0/JlKer8e3soI2z9eBb0JjK8ponVEy1VEcD63UKOpmMbxLJg
+AT009Svn6Qh5htVgiJU2WxBU7JLMybFc2mmqdGlbEZmANfOZO+M+Bz4yMjrbuQkP
+KCU0gJtDoKaRz0SgPeAAtnTg48inN9EMeAh539e9WuFA2Ug+IX4UgdLl01MYZSfB
+OVNyv26diGU7lcBJPzro70QxoGNp4I+m7du2dwIDAQABAoIBAQDCdvEILIziPU+H
+f53csTP28b7AFuetBYj4gQNbSlkizb4hBlbnaU7EKBRelF0u5Gxx+BE5dFYC7+OY
+13TX5yIGDrSM5HGS3LdeJMqboI0HSB5GUKSJWBbxc5uP/yi18Kir+k0S3n7aJcyV
+rhjWmGXTsnSp1NDPuNO15FhKgq1KqKFXTDzRUIIhU/TEH01J6EnRM8I4En9IvXZ6
+JVWY387VcMeXHRIJEUKbJwx37Fq+BiutDTAbkrCOY+RChScJ7Dpdg+x7AIfAH2Pr
+KqidFH6OSUMg20bDTf/4osUE2LMGYjtsZ100MNgviaaXL/4gaLTZ0devdyaA+6vC
+3TKtqey5AoGBAO3BbU9nbkYFwmLI3L0QszKxulLzCsxqHpeKeQSJCX4NRNPeSU6Z
+oLFlYxbXhZY41JRvZoNA1HVthoz8aZUa43+JFfBbNw4gMd0wr4e1c5xjSHhVanbB
+jicz7g+O+RO06+hYy8uG6Xfc06QCA7bgnGyj+znZQ5JsLofkFZBi4HvdAoGBAOH+
+ioxfN5btQvw/oExsqojDhsTQ0wHUDTKL0CObxyvyT3a6nVzneiMMyHnbsEAWyicU
+pQIKjs9Eky2dju96iwrEZ3frLQPfnc3vCcq2j6wvfv58sfRHoD11pu44xkR6P2XZ
+qaQrcmOtM7HYWJVWiJ1eTbIf1+Do6HKbB0I4phBjAoGAaSFVp33Ryg6z5KBy0vs2
+cd0ayaEEjl0CR/oIBxRdaSqO26x399SAtNBjH2+Pd1yLy1LzHmilSYNzspXOTgtE
+u1kvpUeAMbPUuLzVcQmwJF/WZLdIS1jM9dLFmoWa57bhda0F+GoghErWHrhxUgVB
+xdxAs1S5x14kuRwG2QCPyNUCgYBPKegEhfImF1SIog0X2FTgdYWG+hOAJ3S8CQfP
+AWmCdm3pjDNFcPxyvK6ZKSCTQqhriirHDUW7Sy03JGMGdmmwSt5nvmTVX4aatao7
+bTnkufqFUM7RYCm8fbMM7axeHmiI1/c5v9JhIjHikYNuRJK0dW1IASmQ6mVKiA3B
+37AkOwKBgQDcJz6106qMN+/EoAIetCSgneqKVN2IECLHge1Ldy8A3tpvC4V9rNr2
+RI/9QEqDD4UehAFrSa8zTAUuWYvgFA8iOkTonlMimzXBtamWzRC1SjDHY+vdhd9q
+NsjUIKs/FDpgIoUgc+YJaFViz4KbNoHGAo5q5dDINGhFlB+jK8wg1g==
+-----END RSA PRIVATE KEY-----
diff --git a/id_rsa.storage-auto-deploy.pub b/id_rsa.storage-auto-deploy.pub
new file mode 100644 (file)
index 0000000..16570c9
--- /dev/null
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDR42ep4dOIbS9jF/T0kyzQAgw1d0YkL9WyX/bPdbvVAka/bxIBaLaxrs92w4MRdxqB9vdGawZ1xyMEWeRu3SvY5ToKP8PK41Py0CFkfCOIIqmAh1zVB2Z5+tGPHYTsL7PT8mUp6vx7eygjbP14FvQmMrymidUTLVURwPrdQo6mYxvEsmABPTT1K+fpCHmG1WCIlTZbEFTskszJsVzaaap0aVsRmYA185k74z4HPjIyOtu5CQ8oJTSAm0OgppHPRKA94AC2dODjyKc30Qx4CHnf171a4UDZSD4hfhSB0uXTUxhlJ8E5U3K/bp2IZTuVwEk/OujvRDGgY2ngj6bt27Z3 storageautoinstaller@host
index 972e49990b21b88435bb2277f398189b21506d2b..2de46e41b5b49978673f51edece4497a2b8cea19 100755 (executable)
@@ -4,18 +4,22 @@
 # Storage server auto-deploy script
 #
 
+log() {
+    echo -n "###### `date --rfc-3339=seconds`  STORAGE AUTO-DEPLOY "
+    echo $@
+}
+
 rexec() {
     local srv="$1" ; shift
 
-    ssh -o UserKnownHostsFile=/dev/null     \
+    ssh -i id_rsa.storage-auto-deploy       \
+        -o UserKnownHostsFile=/dev/null     \
         -o StrictHostKeyChecking=no         \
         -o PasswordAuthentication=no        \
         -o ConnectTimeout=1                 \
-        -q root@$srv "$@" || {
-        echo
-        echo "    FAILED. Aborting."
-        echo "     Failed command was '$@'"
-        echo
+        -q root@$srv "$@" 2>&1 || {
+        log "    FAILED. Aborting."
+        log "    Failed command was '$@'"
         return 1; }
 }
 # ----
@@ -47,36 +51,40 @@ while_with_timeout() {
 }
 # ----
 
-wait_for_reboot() {
+wait_until_online() {
     local timeout="$1"
     local srv="$2"
 
-    echo -n "       Waiting for '$srv' to shut down:"
-    while_with_timeout $timeout "ping -c1 -w1 $srv" "echo -n ." || {
-        echo
-        echo "    ERROR: Server did not shut down after 100 seconds."
-        echo
+    log -n "       Waiting for '$srv' to get on-line:"
+    while_with_timeout $timeout "not" "ping -c1 -w1 $srv" "echo -n ." || {
+        log "    ERROR: Server did not come back after 100 seconds."
         return 1
     }
     echo
 
-    echo -n "       Waiting for '$srv' to come back:"
-    while_with_timeout $timeout "not" "ping -c1 -w1 $srv" "echo -n ." || {
-        echo
-        echo "    ERROR: Server did not come back after 100 seconds."
-        echo
+    log -n "       Waiting for '$srv' to start its SSH service:"
+    while_with_timeout $timeout "not" "rexec $srv true" "echo -n ." || {
+        log "    ERROR: Server did not start ssh after 100 seconds."
         return 1
     }
     echo
+}
 
-    echo -n "       Waiting for '$srv' to start its SSH service:"
-    while_with_timeout $timeout "rexec $srv true" "echo -n ." || {
-        echo
-        echo "    ERROR: Server did not start ssh after 100 seconds."
-        echo
+# ----
+
+wait_for_reboot() {
+    local timeout="$1"
+    local srv="$2"
+
+    log -n "       Waiting for '$srv' to shut down:"
+    while_with_timeout $timeout "ping -c1 -w1 $srv" "echo -n ." || {
+        log "    ERROR: Server did not shut down after 100 seconds."
         return 1
     }
     echo
+
+    # last call in this function; will generate this function's return value
+    wait_until_online "$timeout" "$srv"
 }
 # ----
 
@@ -98,44 +106,44 @@ main() {
 
     local storage_ip="$1"
 
-    echo "    Cloning pb-overlay in initial bootstrap system"
+    wait_until_online 100 "$storage_ip" || return 1
+
+    log "    Cloning pb-overlay in initial bootstrap system"
     rexec "$storage_ip" "cd /tmp && git clone git://git/so/pb-overlay.git" \
         || return 1
 
-    echo "    Creating Storage root FS partitions and disk array"
+    log "    Creating Storage root FS partitions and disk array"
     rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./storage-create-root sda sdb" \
         || return 1
 
-    echo "    Installing root system (gentoo) from tarball"
+    log "    Installing root system (gentoo) from tarball"
+    rexec "$storage_ip" "\
+     cd /tmp/pb-overlay/scripts && \
+     sed -i 's:{INSTANCE_NAME}\.last\.tar\.xz:{INSTANCE_NAME}.auto-deploy.last.tar.xz:' install-gentoo-storage" \
+        || return 1
     rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./install-gentoo-storage" \
         || return 1
 
-    echo "    Rebooting"
+    log "    Rebooting"
     rexec "$storage_ip" "reboot" || return 1
-    wait_for_reboot 100 $storage_ip || { echo "    ABORT"; return 1; }
+    wait_for_reboot 100 $storage_ip || { log "    ABORT"; return 1; }
 
-    echo "    Cloning pb-overlay in storage root FS"
+    log "    Cloning pb-overlay in storage root FS"
     rexec "$storage_ip" "cd /tmp && git clone git://git/so/pb-overlay.git" \
         || return 1
 
-    echo "    Creating storage disk array"
-    rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./storage-create-storage sdc sdd sde sdf" \
+    log "    Creating storage disk array"
+    rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./storage-create-storage 'sdc sdd sde sdf' /storage/mdraid.start" \
         || return 1
 
-    echo "    Rebooting"
+    log "    Rebooting"
     rexec "$storage_ip" "reboot" ||  return 1
-    wait_for_reboot 100 $storage_ip || { echo "    ABORT"; return 1; }
-}
-
-
-
+    wait_for_reboot 100 $storage_ip || { log "    ABORT"; return 1; }
 
+    log "                     S U C C E S S"
+    log "   Your storage server is now available at $storage_ip."
+}
 
-#
-# DEBUG DEBUG DEBUG
-#
-ssh-keygen -f "/home/thilo/.ssh/known_hosts" -R 192.168.49.78
-cat /home/thilo/.ssh/id_rsa.pub | ssh root@192.168.49.78 'mkdir .ssh; cat >.ssh/authorized_keys'
 
 #
 # Be nice and enable sourcing of this script w/o side effects