1
0
Fork 0
mirror of https://github.com/dawidd6/action-ansible-playbook.git synced 2024-11-25 18:07:47 +00:00
action-ansible-playbook/main.sh
2020-03-21 20:54:44 +01:00

30 lines
No EOL
589 B
Bash
Executable file

#!/bin/sh
set -e
playbook="$INPUT_PLAYBOOK"
key="$INPUT_KEY"
options="$INPUT_OPTIONS"
if test -z "$playbook"; then
echo "You need to specify 'playbook' input (Ansible playbook filepath)"
exit 1
fi
if test -z "$key"; then
echo "You need to specify 'key' input (SSH private key)"
exit 1
fi
mkdir -p "$HOME/.ssh"
echo "$key" > "$HOME/.ssh/id_rsa"
chmod 600 "$HOME/.ssh/id_rsa"
echo "$options"
echo "$playbook"
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_FORCE_COLOR=True
export ANSIBLE_PRIVATE_KEY_FILE="$HOME/.ssh/id_rsa"
ansible-playbook $options $playbook