Lowercase any hostname comparisons in bootstrap_* scripts

If you deploy a stack with mixed-case hostnames things will break
because no task that is supposed to run on boostrap nodes will run
due to the following code:
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml
"${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "$HOSTNAME" == "$SERVICE_NODEID" ]]; then
...

The hiera key might contain mixed-case letters whereas the hostname
won't and the end result is going to be that no bootstrap tasks
will run on any nodes and, amongst other things, no database tables
will be created, making all services unusable.

Since we use bash explicitely we can leverage the ${var,,} expression
for this.

Change-Id: Ie240b8a4217827dd8ade82479a828817d63143ba
Related-Bug: #1773219
(cherry picked from commit 3345557d7b)
This commit is contained in:
Michele Baldessari 2018-05-25 01:56:32 +02:00
parent 101d4c2248
commit 57dea6a3c7
3 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ if [ -z "$*" ]; then
fi
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "$HOSTNAME" == "$SERVICE_NODEID" ]]; then
if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then
eval $*
else
echo "Skipping execution since this is not the bootstrap node for this service."

View File

@ -12,7 +12,7 @@ if [ -z "$*" ]; then
fi
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "$HOSTNAME" == "$SERVICE_NODEID" ]]; then
if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then
eval $*
else
echo "Skipping execution since this is not the bootstrap node for this service."

View File

@ -12,7 +12,7 @@ if [ -z "$*" ]; then
fi
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "$HOSTNAME" == "$SERVICE_NODEID" ]]; then
if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then
exec "$@"
else
echo "Skipping execution since this is not the bootstrap node for this service."