diff options
| author | Martin Schwenke <martin@meltin.net> | 2014-06-30 16:39:15 +1000 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2014-07-02 20:26:52 +1000 |
| commit | fa26aa2e805ff739f3969892e7e302daa1eaef60 (patch) | |
| tree | 616e4ec9adb66acd6c526f918e1f218e8e0f1d88 | |
| parent | ec85e5975cba4ebf0db5906562cf0d8198dcd569 (diff) | |
Rework cluster_setup() to use node types instead of $CLUSTER_TYPE
* Remove configuration variable CLUSTER_TYPE
* Add "build" node type
* Rename setup scripts for "ad" and "build" node type
* Separate out some setup_node_nas.sh from setup_cluster_nas.sh
* Make install_packages.sh and cluster_setup.sh more verbose
* Separate out clusterfs_setup.sh
Signed-off-by: Martin Schwenke <martin@meltin.net>
| -rwxr-xr-x | autocluster | 81 | ||||
| -rwxr-xr-x | base/all/root/scripts/install_ad.sh (renamed from base/all/root/scripts/install_ad_server.sh) | 0 | ||||
| -rwxr-xr-x | base/all/root/scripts/install_packages.sh | 6 | ||||
| -rwxr-xr-x | base/all/root/scripts/setup_cluster.sh | 13 | ||||
| -rwxr-xr-x | base/all/root/scripts/setup_cluster_nas.sh | 80 | ||||
| -rwxr-xr-x | base/all/root/scripts/setup_clusterfs.sh | 19 | ||||
| -rwxr-xr-x | base/all/root/scripts/setup_node_ad.sh (renamed from base/all/root/scripts/setup_cluster_ad_server.sh) | 2 | ||||
| -rwxr-xr-x | base/all/root/scripts/setup_node_build.sh (renamed from base/all/root/scripts/setup_cluster_build.sh) | 2 | ||||
| -rwxr-xr-x | base/all/root/scripts/setup_node_nas.sh | 39 | ||||
| -rw-r--r-- | config.d/00base.defconf | 3 | ||||
| -rw-r--r-- | config.d/50node_nas.defconf | 10 | ||||
| -rw-r--r-- | config.d/52node_build.defconf | 22 | ||||
| -rw-r--r-- | config.d/55node_storage_gpfs.defconf | 10 | ||||
| -rw-r--r-- | config.d/57node_ad.defconf (renamed from config.d/70ad.defconf) | 10 |
14 files changed, 181 insertions, 116 deletions
diff --git a/autocluster b/autocluster index e885037..6793f8c 100755 --- a/autocluster +++ b/autocluster @@ -596,46 +596,67 @@ cluster_boot () echo "" } +cluster_setup_tasks_DEFAULT () +{ + local stage="$1" + + # By default nodes have no tasks + case "$stage" in + install_packages) echo "" ;; + setup_clusterfs) echo "" ;; + setup_node) echo "" ;; + setup_cluster) echo "" ;; + esac +} + cluster_setup () { announce "cluster setup \"${CLUSTER}\"" [ -n "$CLUSTER" ] || die "\$CLUSTER not set" - local install_tasks="" - local setup_tasks="" - - case "$CLUSTER_TYPE" in - "build") - install_tasks="clusterfs build" - setup_tasks="build" - ;; - "ad") - install_tasks="ad_server" - setup_tasks="ad_server" - ;; - "samba") - install_tasks="clusterfs nas" - setup_tasks="clusterfs nas" - ;; - esac - local ssh="ssh -o StrictHostKeyChecking=no" + local setup_clusterfs_done=false + local setup_cluster_done=false - if [ -n "$install_tasks" ] ; then - [ -n "$CLUSTER_PATTERN" ] || CLUSTER_PATTERN="$CLUSTER" + _cluster_setup_do_stage () + { + local stage="$1" + local type="$2" + local ip_offset="$3" + local name="$4" + local ctdb_node="$5" + + local tasks=$(call_func cluster_setup_tasks "$type" "$stage") + + if [ -n "$tasks" ] ; then + # These tasks are only done on 1 node + case "$stage" in + setup_clusterfs) + if $setup_clusterfs_done ; then + return + else + setup_clusterfs_done=true + fi + ;; + setup_cluster) + if $setup_cluster_done ; then + return + else + setup_cluster_done=true + fi + ;; + esac - local nodes=$(vircmd dominfo "$CLUSTER_PATTERN" 2>/dev/null | \ - sed -n -e 's/Name: *//p') + $ssh "$name" "./scripts/${stage}.sh" $tasks + fi - for i in $nodes ; do - $ssh "$i" ./scripts/install_packages.sh $install_tasks - done - fi + } - if [ -n "$setup_tasks" ] ; then - local n1="${CLUSTER}n1" - $ssh "$n1" ./scripts/setup_cluster.sh $setup_tasks - fi + local stages="install_packages setup_clusterfs setup_node setup_cluster" + local stage + for stage in $stages ; do + for_each_node _cluster_setup_do_stage "$stage" + done } create_one_node () diff --git a/base/all/root/scripts/install_ad_server.sh b/base/all/root/scripts/install_ad.sh index 75233c4..75233c4 100755 --- a/base/all/root/scripts/install_ad_server.sh +++ b/base/all/root/scripts/install_ad.sh diff --git a/base/all/root/scripts/install_packages.sh b/base/all/root/scripts/install_packages.sh index 9b023c0..2b6a04c 100755 --- a/base/all/root/scripts/install_packages.sh +++ b/base/all/root/scripts/install_packages.sh @@ -1,5 +1,8 @@ #!/bin/sh +echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" +printf "%% %-66s %%\n" "Install packages doing \"yum update\" on host ${HOSTNAME%%.*}" +echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" echo "Updating from YUM repositories" yum -y update @@ -27,5 +30,8 @@ for task ; do exit 1 fi + echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + printf "%% %-66s %%\n" "Install packages task \"${task}\" on host ${HOSTNAME%%.*}" + echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" "$path" done diff --git a/base/all/root/scripts/setup_cluster.sh b/base/all/root/scripts/setup_cluster.sh index 2e2d7ea..93aca59 100755 --- a/base/all/root/scripts/setup_cluster.sh +++ b/base/all/root/scripts/setup_cluster.sh @@ -3,15 +3,7 @@ dn=$(dirname $0) for task ; do - case "$task" in - clusterfs) - type="@@CLUSTERFS_TYPE@@" - file="setup_clusterfs_${type}.sh" - ;; - *) - file="setup_cluster_${task}.sh" - esac - + file="setup_cluster_${task}.sh" path="${dn}/${file}" if [ ! -x "$path" ] ; then @@ -19,5 +11,8 @@ for task ; do exit 1 fi + echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + printf "%% %-66s %%\n" "Setup cluster task \"${task}\"" + echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" "$path" || exit $? done diff --git a/base/all/root/scripts/setup_cluster_nas.sh b/base/all/root/scripts/setup_cluster_nas.sh index 8f01827..aa0da82 100755 --- a/base/all/root/scripts/setup_cluster_nas.sh +++ b/base/all/root/scripts/setup_cluster_nas.sh @@ -4,11 +4,11 @@ set -e +conf_file="/root/scripts/nas.conf" + 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}" @@ -30,84 +30,24 @@ wait_until_healthy () 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") - -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... +echo "Restarting ctdb (up to 5 times)" +# Just in case the cluster doesn't become healthy the first time, +# repeat a few times... for i in $(seq 1 5) ; do - wait_until_healthy 60 && break - echo "Nope, restart ctdb..." onnode -p all "service ctdb restart" + if wait_until_healthy ; then + echo "NAS cluster setup complete" + exit 0 + fi done -wait_until_healthy - -echo "Setup done" +exit 1 diff --git a/base/all/root/scripts/setup_clusterfs.sh b/base/all/root/scripts/setup_clusterfs.sh new file mode 100755 index 0000000..ec7c3e9 --- /dev/null +++ b/base/all/root/scripts/setup_clusterfs.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +dn=$(dirname $0) + +for task ; do + type="@@CLUSTERFS_TYPE@@" + file="setup_clusterfs_${type}.sh" + path="${dn}/${file}" + + if [ ! -x "$path" ] ; then + echo "Unable to find script \"${file}\" to setup task \"${task}\"" + exit 1 + fi + + echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + printf "%% %-66s %%\n" "Setup clusterfs task \"${task}\"" + echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" + "$path" || exit $? +done diff --git a/base/all/root/scripts/setup_cluster_ad_server.sh b/base/all/root/scripts/setup_node_ad.sh index da2cdc9..7714e8c 100755 --- a/base/all/root/scripts/setup_cluster_ad_server.sh +++ b/base/all/root/scripts/setup_node_ad.sh @@ -2,8 +2,6 @@ set -e -# 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_node_build.sh index 64ca1a2..04d18b6 100755 --- a/base/all/root/scripts/setup_cluster_build.sh +++ b/base/all/root/scripts/setup_node_build.sh @@ -1,7 +1,5 @@ #!/bin/sh -# Assume that a build cluster is always a single node :-) - echo "Running rpmdev-setuptree" rpmdev-setuptree diff --git a/base/all/root/scripts/setup_node_nas.sh b/base/all/root/scripts/setup_node_nas.sh new file mode 100755 index 0000000..65fd966 --- /dev/null +++ b/base/all/root/scripts/setup_node_nas.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Per-node NAS cluster configuration steps + +set -e + +conf_file="/root/scripts/nas.conf" + +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") + +case "$auth_type" in + winbind) + echo "Setting up NSS, PAM, KRB5..." + authconfig --update --nostart \ + --enablewinbindauth --enablewinbind \ + --disablekrb5 --krb5kdc=$kdc.$domain --krb5realm=$domain + ;; + files) + echo "Setting up NSS, PAM, KRB5..." + authconfig --update --nostart \ + --disablewinbindauth --disablewinbind \ + --disablekrb5 --krb5kdc=$kdc.$domain --krb5realm=$domain + ;; +esac + +echo "Configuring services..." +(cd scripts/cluster_configure && \ + ./cluster-configure.py -t "templates/rhel/" -vv "$conf_file") diff --git a/config.d/00base.defconf b/config.d/00base.defconf index 4f0440a..d750e33 100644 --- a/config.d/00base.defconf +++ b/config.d/00base.defconf @@ -4,9 +4,6 @@ # Cluster -defconf CLUSTER_TYPE "samba" \ - "samba|ad|build" "Type of cluster, for configuration stage" - defconf CLUSTERFS_TYPE "gpfs" \ "<gpfs|?>" "type of cluster filesystem to use" diff --git a/config.d/50node_nas.defconf b/config.d/50node_nas.defconf index a0ac0c1..794c42f 100644 --- a/config.d/50node_nas.defconf +++ b/config.d/50node_nas.defconf @@ -31,3 +31,13 @@ node_has_shared_disks_nas () { ! have_dedicated_storage_nodes } + +cluster_setup_tasks_nas () +{ + case "$1" in + install_packages) echo "clusterfs nas" ;; + setup_clusterfs) echo "clusterfs" ;; + setup_node) echo "nas" ;; + setup_cluster) echo "nas" ;; + esac +} diff --git a/config.d/52node_build.defconf b/config.d/52node_build.defconf new file mode 100644 index 0000000..b375e0c --- /dev/null +++ b/config.d/52node_build.defconf @@ -0,0 +1,22 @@ +# Hey Emacs, this is a -*- shell-script -*- !!! + +create_node_build () +{ + local ip_offset="$1" + local name="$2" + local ctdb_node="$3" + + echo "Creating build node $name" + + create_node_COMMON "$name" "$ip_offset" "$type" +} + +cluster_setup_tasks_build () +{ + case "$1" in + install_packages) echo "clusterfs build" ;; + setup_clusterfs) echo "" ;; + setup_node) echo "build" ;; + setup_cluster) echo "" ;; + esac +} diff --git a/config.d/55node_storage_gpfs.defconf b/config.d/55node_storage_gpfs.defconf index 4601714..4ed9ebd 100644 --- a/config.d/55node_storage_gpfs.defconf +++ b/config.d/55node_storage_gpfs.defconf @@ -40,3 +40,13 @@ is_dedicated_storage_node_storage_gpfs () { true } + +cluster_setup_tasks_storage_gpfs () +{ + case "$1" in + install_packages) echo "clusterfs" ;; + setup_clusterfs) echo "clusterfs" ;; + setup_node) echo "" ;; + setup_cluster) echo "" ;; + esac +} diff --git a/config.d/70ad.defconf b/config.d/57node_ad.defconf index 2915335..8abeade 100644 --- a/config.d/70ad.defconf +++ b/config.d/57node_ad.defconf @@ -8,3 +8,13 @@ defconf AD_FUNCTION_LEVEL "2008" \ defconf AD_NETBIOS_NAME "samba4" \ "<string>" "NetBIOS name to use for AD server" + +cluster_setup_tasks_ad () +{ + case "$1" in + install_packages) echo "ad" ;; + setup_clusterfs) echo "" ;; + setup_node) echo "ad" ;; + setup_cluster) echo "" ;; + esac +} |
