2016-08-10 14:57:07 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
VALIDATION_FILE=$1
|
|
|
|
IDENTITY_FILE=$2
|
2016-08-11 10:12:54 +02:00
|
|
|
PLAN_NAME=$3
|
2016-08-10 14:57:07 +02:00
|
|
|
|
|
|
|
if [[ -z "$VALIDATION_FILE" ]]; then
|
|
|
|
echo "Missing required validation file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -r "$VALIDATION_FILE" ]]; then
|
|
|
|
echo "Can not find validation at $VALIDATION_FILE"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$IDENTITY_FILE" ]]; then
|
|
|
|
echo "Missing required identity file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure ssh is not asking interactively for hosts it can't check the key
|
|
|
|
# authenticity
|
|
|
|
export ANSIBLE_HOST_KEY_CHECKING=False
|
2016-06-10 17:34:17 +02:00
|
|
|
# Disable retry files until we find a good use and location for them
|
|
|
|
export ANSIBLE_RETRY_FILES_ENABLED=False
|
2016-09-06 11:10:21 +02:00
|
|
|
# Add `-E` to the sudo flags to preserve the shell environment. The `-H -S -n`
|
|
|
|
# options are Ansible's default values.
|
|
|
|
export ANSIBLE_SUDO_FLAGS="-H -S -n -E"
|
2016-08-10 14:57:07 +02:00
|
|
|
|
|
|
|
export ANSIBLE_PRIVATE_KEY_FILE=$IDENTITY_FILE
|
|
|
|
|
|
|
|
export ANSIBLE_INVENTORY=$(which tripleo-ansible-inventory)
|
|
|
|
|
2016-09-29 12:21:40 +02:00
|
|
|
# Use the custom validation-specific formatter
|
|
|
|
export ANSIBLE_STDOUT_CALLBACK=validation_output
|
|
|
|
|
2016-08-11 10:12:54 +02:00
|
|
|
# Environment variable is the easiest way to pass variables to an Ansible
|
|
|
|
# dynamic inventory script
|
|
|
|
export TRIPLEO_PLAN_NAME=${PLAN_NAME}
|
|
|
|
|
2016-09-06 16:46:40 +02:00
|
|
|
# NOTE(shadower): set up token-based environment for the openstack
|
|
|
|
# client when the password doesn't exist. This happens when called
|
|
|
|
# from mistral:
|
|
|
|
if [ -z "${OS_PASSWORD:-}" ]; then
|
|
|
|
# The auth type must be explicitly set to token
|
|
|
|
export OS_AUTH_TYPE=token
|
|
|
|
# The openstack client expects the token as OS_TOKEN
|
|
|
|
export OS_TOKEN=$OS_AUTH_TOKEN
|
|
|
|
# TODO(shadower): I could not get the token auth working with v3:
|
|
|
|
export OS_AUTH_URL=${OS_AUTH_URL/%v3/v2.0}
|
|
|
|
fi
|
|
|
|
|
2016-08-10 14:57:07 +02:00
|
|
|
ansible-playbook $VALIDATION_FILE
|