kolla/ansible/roles/mariadb/templates/wsrep-notify.sh.j2
Michal (inc0) Jastrzebski 5838bd0b3c Enable kolla k8s to override bind api bind address in genconfig
It's good if k8s reuses ansible templates, but we need to abstract all
ansible specific variables to achieve that.

- Implements ansible override variable api_interface_address.
- Adds api_interface_address setting and comments to globals.yml
- Makes changes to mariadb templates to accept this new setting.
- Disabled Galera when api_interface_address==0.0.0.0 in the
  case of Kubernetes.  Otherwise, mariadb fails to start.
- Tested with and without setting to ensure kolla genconfig output
  does not change when setting is disabled or undefined.

Change-Id: Ia0e4951c327be01b717aebb86ef4c3a4e7ed170e
Partially-implements: blueprint api-interface-bind-address-override
Co-authored-by: David Wang <dcwangmit01@gmail.com>
Co-authored-by: Ryan Hallisey <rhallise@redhat.com>
Co-authored-by: Kevin Fox <kevin@efox.cc>
2016-07-28 11:59:28 -04:00

76 lines
1.4 KiB
Django/Jinja

#!/bin/bash -e
# Edit parameters below to specify the address and login to server.
USER={{ database_user }}
PSWD={{ database_password }}
HOST={{ api_interface_address }}
PORT={{ mariadb_port }}
LB_USER=haproxy
ENABLE_LB="UPDATE mysql.user SET User='${LB_USER}' WHERE User='${LB_USER}_blocked';"
DISABLE_LB="UPDATE mysql.user SET User='${LB_USER}_blocked' WHERE User='${LB_USER}';"
MYSQL_CMD="`type -p mysql` -B -u$USER -p$PSWD -h$HOST -P$PORT"
status_update()
{
echo "SET SESSION wsrep_on=off;"
echo "$@"
echo "FLUSH PRIVILEGES;"
}
get_sst_method()
{
$MYSQL_CMD -s -N -e "SHOW VARIABLES LIKE 'wsrep_sst_method';" | awk '{ print $2 }'
}
while [ $# -gt 0 ]
do
case $1 in
--status)
STATUS=$2
shift
;;
--uuid)
CLUSTER_UUID=$2
shift
;;
--primary)
[ "$2" = "yes" ] && PRIMARY="1" || PRIMARY="0"
shift
;;
--index)
INDEX=$2
shift
;;
--members)
MEMBERS=$2
shift
;;
esac
shift
done
case $STATUS in
Synced)
CMD=$ENABLE_LB
;;
Donor)
# enabling donor only if xtrabackup configured
SST_METHOD=`get_sst_method`
[[ $SST_METHOD =~ 'xtrabackup' ]] && CMD=$ENABLE_LB || CMD=$DISABLE_LB
;;
Undefined)
# shutting down database: do nothing
;;
*)
CMD=$DISABLE_LB
;;
esac
if [ -n "$CMD" ]
then
status_update "$CMD" | $MYSQL_CMD
fi
exit 0