Cleanup post-boot cluster configuration
authorMartin Schwenke <martin@meltin.net>
Tue, 24 Jun 2014 05:01:16 +0000 (15:01 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 2 Jul 2014 04:17:17 +0000 (14:17 +1000)
* Single entry point is now setup_cluster.sh.

* Rename old setup_cluster.sh to setup_cluster_nas.sh.

* Split setup_ad_server.sh into install_ad_server.sh and
  setup_cluster_ad_server.sh.

* Split setup_build.sh into install_build.sh and
  setup_cluster_build.sh.

* Rename setup_gpfs.sh to setup_clusterfs_gpfs.sh.

Signed-off-by: Martin Schwenke <martin@meltin.net>
autocluster
base/all/root/scripts/install_ad_server.sh [new file with mode: 0755]
base/all/root/scripts/install_build.sh [moved from base/all/root/scripts/setup_build.sh with 84% similarity]
base/all/root/scripts/setup_cluster.sh
base/all/root/scripts/setup_cluster_ad_server.sh [moved from base/all/root/scripts/setup_ad_server.sh with 71% similarity]
base/all/root/scripts/setup_cluster_build.sh [new file with mode: 0755]
base/all/root/scripts/setup_cluster_nas.sh [new file with mode: 0755]
base/all/root/scripts/setup_clusterfs_gpfs.sh [moved from base/all/root/scripts/setup_gpfs.sh with 100% similarity]

index efeca1232d0328150ddc2054dadc71b8bfb52201..ccbec87f21a54b30e6b92b39b452f1581a3791b0 100755 (executable)
@@ -581,14 +581,13 @@ cluster_configure ()
 
     case "$CLUSTER_TYPE" in
        "build")
-           # Build node doesn't really need CTDB/Samba to be
-           # installed, if the packages are not present in the repo,
-           # they're skipped.
-           $ssh "$n1" "./scripts/setup_build.sh || true"
+           $ssh "$n1" ./scripts/install_packages.sh clusterfs build
+           $ssh "$n1" ./scripts/setup_cluster.sh build
            ;;
 
        "ad")
-           $ssh "$n1" ./scripts/setup_ad_server.sh
+           $ssh "$n1" ./scripts/install_packages.sh ad_server
+           $ssh "$n1" ./scripts/configure_cluster.sh ad_server
            ;;
 
        "samba")
@@ -600,14 +599,8 @@ cluster_configure ()
            for i in $nodes ; do
                $ssh "$i" ./scripts/install_packages.sh clusterfs nas
            done
-           $ssh "$n1" ./scripts/setup_gpfs.sh
 
-           if [ "$AUTH_METHOD" = "winbind" ]; then
-               args="-UAdministrator%${AD_ADMIN_PASS}"
-           else
-               args=""
-           fi
-           $ssh "$n1" ./scripts/setup_cluster.sh "$args"
+           $ssh "$n1" ./scripts/setup_cluster.sh clusterfs nas
            ;;
     esac
 }
diff --git a/base/all/root/scripts/install_ad_server.sh b/base/all/root/scripts/install_ad_server.sh
new file mode 100755 (executable)
index 0000000..75233c4
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+set -e
+
+echo "Installing Samba4 packages"
+yum -y install samba4-dc samba4-python
similarity index 84%
rename from base/all/root/scripts/setup_build.sh
rename to base/all/root/scripts/install_build.sh
index 49819782e3682b9900957e27605cb5822ec9e090..9857e081e79223fb19aa7ca8a71cae6df233be73 100755 (executable)
@@ -1,15 +1,8 @@
 #!/bin/sh
 
-#
-# Setup build node                                                              
-#
-
-$(dirname $0)/install_gpfs.sh
-
 # Setup RPM development                                                         
 echo "Installing RPM developing and setting up rpm build"
 yum -y install rpmdevtools
-rpmdev-setuptree
 
 # Install the performance co-pilot packages to allow building of the
 # CTDB pmda code.  It is OK if this fails (these packages are only
@@ -21,3 +14,5 @@ yum -y install pcp-libs pcp-libs-devel
 echo "Installing Samba build dependencies"
 yum -y install readline-devel libacl-devel e2fsprogs-devel \
     libxslt docbook-utils docbook-style-xsl
+
+exit 0
index 66a27ca1f9efaff243f165c4d34da4742888cd96..2e2d7eab449b0ed3e5ff1efce98c9b9abd3ad7c4 100755 (executable)
-#!/bin/bash
-
-# Configure a simple NAS cluster as generated by autocluster..
-
-set -e
-
-domain_auth="administrator"
-auth_type="files"
-
-conf_file="/root/scripts/nas.conf"
-
-wait_until_healthy ()
-{
-    local timeout="${1:-120}"
-
-    echo -n "Wait until healthy [<${timeout}] "
-
-    local count=0
-    while [ $count -lt $timeout ] ; do
-       if ctdb nodestatus all >/dev/null ; then
-           echo "[${count}]"
-           return 0
-       fi
-       echo -n "."
-       count=$(($count + 1))
-       sleep 1
-    done
-
-    echo "[TIMEOUT]"
-    return 1
-}
-
-####################
-# show program usage
-usage ()
-{
-    cat >&2 <<EOF
-Usage: setup_samba.sh [OPTION] 
-  options:
-    -x                        enable script debugging
-    -c config_file            config file to load
-    -U username%password      domain authentication
-EOF
-    exit 1
-}
-
-
-############################
-# parse command line options
-temp=$(getopt -n "$prog" -o "axhU:c:" -l help -- "$@")
-[ $? != 0 ] && usage
-eval set -- "$temp"
-while true ; do
-    case "$1" in
-       -x) set -x; shift ;;
-       -c) conf_file="$2"   ; shift 2 ;;
-       -U) domain_auth="$2" ; shift 2 ;;
-       --) shift ; break ;;
-       -h|--help|*) usage ;;
+#!/bin/sh
+
+dn=$(dirname $0)
+
+for task ; do
+    case "$task" in
+       clusterfs)
+           type="@@CLUSTERFS_TYPE@@"
+           file="setup_clusterfs_${type}.sh"
+           ;;
+       *)
+           file="setup_cluster_${task}.sh"
     esac
-done
-
-auth_type=$(sed -r -n -e 's@^auth_method[[:space:]]*=[[:space:]]*(files|winbind)[[:space:]]*$@\1@p' "$conf_file")
-
-case "$auth_type" in
-    winbind|files) : ;;
-    *)
-       echo "Unsupported authentication type \"${auth_type}\""
-       usage
-esac
-
-domain=$(sed -r -n -e 's@^domain[[:space:]]*=[[:space:]]*([^ ]*)[[:space:]]*$@\1@p' "$conf_file" | tr '[a-z]' '[A-Z]')
-
-kdc=$(sed -r -n -e 's@^kdc[[:space:]]*=[[:space:]]*([^ ]*)[[:space:]]*$@\1@p' "$conf_file")
-
-mmgetstate | grep active > /dev/null || {
-    echo "GPFS must be running to setup Samba"
-    exit 1
-}
 
-echo "Enabling ctdb..."
-onnode -p all chkconfig ctdb on
+    path="${dn}/${file}"
 
-case "$auth_type" in
-    winbind)
-       echo "Setting up NSS, PAM, KRB5..."
-       onnode -p all authconfig --update --nostart \
-           --enablewinbindauth --enablewinbind \
-           --disablekrb5 --krb5kdc=$kdc.$domain  --krb5realm=$domain
-       ;;
-    files)
-       echo "Setting up NSS, PAM, KRB5..."
-       onnode -p all authconfig --update --nostart \
-           --disablewinbindauth --disablewinbind \
-           --disablekrb5 --krb5kdc=$kdc.$domain  --krb5realm=$domain
-       ;;
-esac
+    if [ ! -x "$path" ] ; then
+       echo "Unable to find script \"${file}\" to setup task \"${task}\""
+       exit 1
+    fi
 
-echo "Configuring services..."
-onnode -p all "(cd scripts/cluster_configure && \
-    ./cluster-configure.py -t 'templates/rhel/' -vv '$conf_file')"
-
-case "$auth_type" in
-    winbind)
-       echo "Joining domain"
-       net ads join -U"$domain_auth"
-       ;;
-esac
-
-echo "Restarting ctdb"
-onnode -p all "service ctdb restart"
-
-# let's hit this with a big hammer...
-for i in $(seq 1 5) ; do
-    wait_until_healthy 60 && break
-    echo "Nope, restart ctdb..."
-    onnode -p all "service ctdb restart"
+    "$path" || exit $?
 done
-
-wait_until_healthy
-
-echo "Setup done"
similarity index 71%
rename from base/all/root/scripts/setup_ad_server.sh
rename to base/all/root/scripts/setup_cluster_ad_server.sh
index 511c1a4cd2236cc9b8716f8f1683e4f66bd2f615..da2cdc99a4eecd48d623e656dfd6ec482f044dea 100755 (executable)
@@ -1,22 +1,8 @@
-#!/bin/bash
+#!/bin/sh
 
-# catch errors
 set -e
-set -E
-trap 'es=$?; 
-      echo ERROR: failed in function \"${FUNCNAME}\" at line ${LINENO} of ${BASH_SOURCE[0]} with code $es; 
-      exit $es' ERR
 
-# Make this explicit so we only get RHEL updates to make things nice
-# and clear.  This duplicates what happens in basic-postinstall.sh but
-# we may have just rewound the cluster, so we might be running this on
-# the node install of from kickstart.
-echo "Updating from YUM repositories"
-yum -y update
-
-# Install samba4 packages
-echo "Installing Samba4 packages"
-yum -y install samba4-dc samba4-python
+# Assume that an AD server cluster is always a single node :-)
 
 # Remove samba3 configuration file
 rm -f /etc/samba/smb.conf
diff --git a/base/all/root/scripts/setup_cluster_build.sh b/base/all/root/scripts/setup_cluster_build.sh
new file mode 100755 (executable)
index 0000000..64ca1a2
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Assume that a build cluster is always a single node :-)
+
+echo "Running rpmdev-setuptree"
+rpmdev-setuptree
+
+echo "Removing .rpmmacros"
+rm -vf /root/.rpmmacros
diff --git a/base/all/root/scripts/setup_cluster_nas.sh b/base/all/root/scripts/setup_cluster_nas.sh
new file mode 100755 (executable)
index 0000000..e350761
--- /dev/null
@@ -0,0 +1,116 @@
+#!/bin/bash
+
+# Configure a simple NAS cluster as generated by autocluster..
+
+set -e
+
+ad_admin_pass="@@AD_ADMIN_PASS@@"
+domain_auth="administrator${ad_admin_pass:+%}${ad_admin_pass}"
+
+conf_file="/root/scripts/nas.conf"
+
+wait_until_healthy ()
+{
+    local timeout="${1:-120}"
+
+    echo -n "Wait until healthy [<${timeout}] "
+
+    local count=0
+    while [ $count -lt $timeout ] ; do
+       if ctdb nodestatus all >/dev/null ; then
+           echo "[${count}]"
+           return 0
+       fi
+       echo -n "."
+       count=$(($count + 1))
+       sleep 1
+    done
+
+    echo "[TIMEOUT]"
+    return 1
+}
+
+####################
+# show program usage
+usage ()
+{
+    cat >&2 <<EOF
+Usage: setup_samba.sh [OPTION] 
+  options:
+    -x                        enable script debugging
+    -c config_file            config file to load
+    -U username%password      domain authentication
+EOF
+    exit 1
+}
+
+
+############################
+# parse command line options
+temp=$(getopt -n "$prog" -o "axhU:c:" -l help -- "$@")
+[ $? != 0 ] && usage
+eval set -- "$temp"
+while true ; do
+    case "$1" in
+       -x) set -x; shift ;;
+       -c) conf_file="$2"   ; shift 2 ;;
+       --) shift ; break ;;
+       -h|--help|*) usage ;;
+    esac
+done
+
+auth_type=$(sed -r -n -e 's@^auth_method[[:space:]]*=[[:space:]]*(files|winbind)[[:space:]]*$@\1@p' "$conf_file")
+
+case "$auth_type" in
+    winbind|files) : ;;
+    *)
+       echo "Unsupported authentication type \"${auth_type}\""
+       usage
+esac
+
+domain=$(sed -r -n -e 's@^domain[[:space:]]*=[[:space:]]*([^ ]*)[[:space:]]*$@\1@p' "$conf_file" | tr '[a-z]' '[A-Z]')
+
+kdc=$(sed -r -n -e 's@^kdc[[:space:]]*=[[:space:]]*([^ ]*)[[:space:]]*$@\1@p' "$conf_file")
+
+echo "Enabling ctdb..."
+onnode -p all chkconfig ctdb on
+
+case "$auth_type" in
+    winbind)
+       echo "Setting up NSS, PAM, KRB5..."
+       onnode -p all authconfig --update --nostart \
+           --enablewinbindauth --enablewinbind \
+           --disablekrb5 --krb5kdc=$kdc.$domain  --krb5realm=$domain
+       ;;
+    files)
+       echo "Setting up NSS, PAM, KRB5..."
+       onnode -p all authconfig --update --nostart \
+           --disablewinbindauth --disablewinbind \
+           --disablekrb5 --krb5kdc=$kdc.$domain  --krb5realm=$domain
+       ;;
+esac
+
+echo "Configuring services..."
+onnode -p all "(cd scripts/cluster_configure && \
+    ./cluster-configure.py -t 'templates/rhel/' -vv '$conf_file')"
+
+case "$auth_type" in
+    winbind)
+       echo "Joining domain"
+       net ads join -U"$domain_auth"
+       ;;
+esac
+
+echo "Restarting ctdb"
+onnode -p all "service ctdb restart"
+
+# let's hit this with a big hammer...
+for i in $(seq 1 5) ; do
+    wait_until_healthy 60 && break
+    echo "Nope, restart ctdb..."
+    onnode -p all "service ctdb restart"
+done
+
+wait_until_healthy
+
+echo "Setup done"