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 ()
#!/bin/sh
+echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+printf "%% %-66s %%\n" "Install packages doing \"yum update\" on host ${HOSTNAME%%.*}"
+echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
echo "Updating from YUM repositories"
yum -y update
exit 1
fi
+ echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+ printf "%% %-66s %%\n" "Install packages task \"${task}\" on host ${HOSTNAME%%.*}"
+ echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
"$path"
done
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
exit 1
fi
+ echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+ printf "%% %-66s %%\n" "Setup cluster task \"${task}\""
+ echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
"$path" || exit $?
done
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}"
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"
;;
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
--- /dev/null
+#!/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
set -e
-# Assume that an AD server cluster is always a single node :-)
-
# Remove samba3 configuration file
rm -f /etc/samba/smb.conf
#!/bin/sh
-# Assume that a build cluster is always a single node :-)
-
echo "Running rpmdev-setuptree"
rpmdev-setuptree
--- /dev/null
+#!/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")
# 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"
{
! 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
+}
--- /dev/null
+# 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
+}
{
true
}
+
+cluster_setup_tasks_storage_gpfs ()
+{
+ case "$1" in
+ install_packages) echo "clusterfs" ;;
+ setup_clusterfs) echo "clusterfs" ;;
+ setup_node) echo "" ;;
+ setup_cluster) echo "" ;;
+ esac
+}
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
+}