tripleo-common/scripts/run-validation
Gael Chamoulaud 2a785095ac Use ANSIBLE_BECOME_FLAGS instead of ANSIBLE_SUDO_FLAGS
'ANSIBLE_SUDO_FLAGS' is now deprecated and will be removed in Ansible 2.8
in favor of become. We now have to use 'ANSIBLE_BECOME_FLAGS' to pass
flags to the privilege escalation executable, 'sudo'.

Change-Id: I1747b7505dfce848902d171b1db6ad3c4c3c81e4
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-02-28 18:18:58 +00:00

59 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -e
set -o pipefail
VALIDATION_FILE=$1
IDENTITY_FILE=$2
PLAN_NAME=$3
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
# Disable retry files until we find a good use and location for them
export ANSIBLE_RETRY_FILES_ENABLED=False
# ANSIBLE_SUDO_FLAGS is deprecated in favor of become and will be removed in
# version 2.8. We now have to use ANSIBLE_BECOME_FLAGS to pass Flags to the
# privilege escalation sudo executable.
export ANSIBLE_BECOME_FLAGS="-H -S -n -E"
export ANSIBLE_PRIVATE_KEY_FILE=$IDENTITY_FILE
export ANSIBLE_INVENTORY=$(which tripleo-ansible-inventory)
# Use the custom validation-specific formatter
export ANSIBLE_STDOUT_CALLBACK=validation_output
# Environment variable is the easiest way to pass variables to an Ansible
# dynamic inventory script
export TRIPLEO_PLAN_NAME=${PLAN_NAME}
# 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
ansible-playbook $VALIDATION_FILE