#!/bin/bash if [ -z "$PCS_USER" -o -z "$PCS_PASSWD" ]; then echo "FATAL: Pacemaker cluster credentials should be configured in /etc/sysconfig/pcs-nodeadd" exit 1 fi [ -z "$IPMI_LOGIN" ] && IPMI_LOGIN="ADMIN" [ -z "$IPMI_PASSWD" ] && IPMI_PASSWD="ADMIN" read node_name shared_secret dummy if [ -n "$PCS_NODEADD_SECRET" ]; then if [ "$PCS_NODEADD_SECRET" != "$shared_secret" ]; then echo "FATAL: Wrong secret. Access is denied." exit 1 fi fi # auth new node pcs cluster auth ${node_name} a1 a2 -u $PCS_USER -p $PCS_PASSWD --force # remove node from the cluster to start from scratch pcs cluster node remove ${node_name} # auth once againg pcs cluster auth ${node_name} a1 a2 -u $PCS_USER -p $PCS_PASSWD --force # add node to the cluster pcs cluster node add ${node_name} # enable and start corosync/pacemaker on new node pcs cluster enable ${node_name} pcs cluster start ${node_name} # cross-auth all nodes in the cluster pcs cluster auth -u $PCS_USER -p $PCS_PASSWD # add fence configuration for the new node if [ "${node_name:0:1}" = "s" ]; then pcs stonith create ipmi_${node_name} fence_ipmilan ipaddr=10.25.255.${node_name:1} login=$IPMI_LOGIN passwd=$IPMI_PASSWD pcmk_host_list=${node_name} op monitor interval=60s pcs constraint location ipmi_${node_name} avoids ${node_name}=INFINITY pcs stonith level add 1 ${node_name} ipmi_${node_name} pcs stonith level add 2 ${node_name} pn7320 else pcs stonith level add 1 ${node_name} pn7320 fi # add constraints to prevent a-nodes services even trying to run on WNs for resource in drbd-opt-clone \ a-nodes-IP-clone \ a-nodes-nfs-IP \ a-nodes-nfs-export \ a-nodes-home-export \ a-nodes-home-dmz-export \ a-fhgfs-lxc; do pcs constraint location add location-${resource}-avoids-${node_name} ${resource} ${node_name} -INFINITY resource-discovery=never done exit 0