2021-12-15 00:21:52 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
check=${PLUGIN_CHECK_SYNTAX:-false}
|
|
|
|
verbosity=${PLUGIN_VERBOSITY:-0}
|
|
|
|
|
|
|
|
if [[ -z "$PLUGIN_PLAYBOOK" ]]; then
|
|
|
|
echo -e "\e[31m'playbook' setting not defined, ABORT!\e[39m"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$PLUGIN_PRIVATE_KEY" ]]; then
|
2021-12-15 17:15:50 +01:00
|
|
|
echo -e "\e[31m[WARN] 'private_key' setting not defined !\e[39m"
|
|
|
|
else
|
|
|
|
echo "$PLUGIN_PRIVATE_KEY" > /root/.ssh/id_ed
|
|
|
|
chmod 400 /root/.ssh/id_ed
|
2021-12-15 00:21:52 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "$PLUGIN_VAULT_TOKEN" ]]; then
|
|
|
|
echo "Adding vault token to 'credentials/vault_token'"
|
|
|
|
mkdir credentials
|
|
|
|
echo $PLUGIN_VAULT_TOKEN > credentials/vault_token
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "$PLUGIN_GALAXY_FILE" ]]; then
|
|
|
|
echo "Installing Galaxy dependencies ($PLUGIN_GALAXY_FILE)"
|
|
|
|
echo "\$ ansible-galaxy install -r $PLUGIN_GALAXY_FILE --force"
|
|
|
|
ansible-galaxy install -r $PLUGIN_GALAXY_FILE --force
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
args="$PLUGIN_PLAYBOOK"
|
|
|
|
|
|
|
|
if [[ $check = true ]]; then
|
|
|
|
args="$args --syntax-check"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $verbosity != "0" ]]; then
|
|
|
|
args="${args} -"
|
|
|
|
for i in `seq 1 $verbosity`; do
|
|
|
|
args="${args}v"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "$PLUGIN_LIMIT" ]]; then
|
|
|
|
args="${args} --limit \"$PLUGIN_LIMIT\""
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "\$ ansible-playbook $args"
|
2021-12-15 17:15:50 +01:00
|
|
|
export ANSIBLE_HOST_KEY_CHECKING=False
|
2021-12-15 00:21:52 +01:00
|
|
|
ansible-playbook $args
|