1
0
Fork 0
mirror of https://github.com/dawidd6/action-ansible-playbook.git synced 2024-11-22 15:32:18 +00:00
action-ansible-playbook/main.sh

30 lines
589 B
Bash
Raw Normal View History

2020-03-21 19:01:42 +00:00
#!/bin/sh
2020-03-21 16:06:40 +00:00
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
2020-03-21 19:54:44 +00:00
if test -z "$key"; then
echo "You need to specify 'key' input (SSH private key)"
exit 1
2020-03-21 16:06:40 +00:00
fi
2020-03-21 19:54:44 +00:00
mkdir -p "$HOME/.ssh"
echo "$key" > "$HOME/.ssh/id_rsa"
chmod 600 "$HOME/.ssh/id_rsa"
echo "$options"
echo "$playbook"
2020-03-21 16:06:40 +00:00
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_FORCE_COLOR=True
2020-03-21 19:54:44 +00:00
export ANSIBLE_PRIVATE_KEY_FILE="$HOME/.ssh/id_rsa"
2020-03-21 16:06:40 +00:00
ansible-playbook $options $playbook