67 lines
1.5 KiB
Bash
Executable File
67 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
check=${PLUGIN_CHECK_SYNTAX:-false}
|
|
verbosity=${PLUGIN_VERBOSITY:-0}
|
|
|
|
run_command(){
|
|
echo "\$ $@"
|
|
$@
|
|
}
|
|
|
|
|
|
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
|
|
echo -e "\e[31m[WARN] 'private_key' setting not defined !\e[39m"
|
|
else
|
|
|
|
run_command "mkdir /root/.ssh"
|
|
echo "$PLUGIN_PRIVATE_KEY" > /root/.ssh/id_ed25519
|
|
run_command chmod 400 /root/.ssh/id_ed25519
|
|
fi
|
|
|
|
args="$PLUGIN_PLAYBOOK"
|
|
|
|
if [[ -n "$PLUGIN_VAULT_TOKEN" ]]; then
|
|
echo "Adding vault token to 'credentials/vault_token'"
|
|
run_command "mkdir credentials"
|
|
echo "$PLUGIN_VAULT_TOKEN" > credentials/vault_token
|
|
args="$args --vault-password-file credentials/vault_token"
|
|
echo ""
|
|
fi
|
|
|
|
if [[ -f "ansible-ci.cfg" ]]; then
|
|
rm ansible.cfg
|
|
mv ansible-ci.cfg ansible.cfg
|
|
fi
|
|
|
|
if [[ -n "$PLUGIN_GALAXY_FILE" ]]; then
|
|
echo "Installing Galaxy dependencies ($PLUGIN_GALAXY_FILE)"
|
|
run_command "ansible-galaxy install -r $PLUGIN_GALAXY_FILE --force"
|
|
echo ""
|
|
fi
|
|
|
|
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
|
|
|
|
if [[ -n "$PLUGIN_TAGS" ]]; then
|
|
args="${args} --tags \"$PLUGIN_TAGS\""
|
|
fi
|
|
|
|
run_command "export ANSIBLE_HOST_KEY_CHECKING=False"
|
|
run_command "ansible-playbook $args" |