Files
dc-deployments-automation/bin/ansible-with-atl-env
2019-11-28 14:35:41 +11:00

28 lines
716 B
Bash
Executable File

#!/bin/bash
set -e
# Optionally take an environment file on the command-line for testing.
INV=${1:?"Inventory file must be specified"}
PLAYBOOK=${2:?"Playbook must be specified"}
LOG_FILE=${3:-"/dev/null"}
ENV_FILE=${4:-"/etc/atl"}
export PATH=/usr/local/bin:$PATH
# get /etc/atl into usable vars which can be included in ansible playbooks
grep -v PASSWORD /etc/atl | sed -r -e 's/(^.+)(=)(.*$)/\L\1:\ \3/g' > /etc/atl_vars.yml
# Set the environment with default exports
set -a
source $ENV_FILE
set +a
# Use Ansible from virtualenv if provided
pipenv run \
ansible-playbook -v \
$ATL_DEPLOYMENT_REPOSITORY_CUSTOM_PARAMS \
-i $INV \
$PLAYBOOK \
2>&1 | tee --append $LOG_FILE