mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2024-11-22 15:32:18 +00:00
commit
f13d1bd963
4 changed files with 11 additions and 1 deletions
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
|
@ -21,7 +21,8 @@ jobs:
|
||||||
--link host \
|
--link host \
|
||||||
-v $PWD:/wd \
|
-v $PWD:/wd \
|
||||||
-w /wd \
|
-w /wd \
|
||||||
-e INPUT_PLAYBOOK=playbook.yml \
|
-e INPUT_PLAYBOOK="playbook.yml" \
|
||||||
|
-e INPUT_DIRECTORY="./" \
|
||||||
-e INPUT_KEY="${{secrets.SSH_PRIVATE_KEY}}" \
|
-e INPUT_KEY="${{secrets.SSH_PRIVATE_KEY}}" \
|
||||||
-e INPUT_OPTIONS="--inventory hosts --limit remote" \
|
-e INPUT_OPTIONS="--inventory hosts --limit remote" \
|
||||||
action
|
action
|
||||||
|
|
|
@ -9,6 +9,7 @@ An action that executes given Ansible playbook on selected hosts.
|
||||||
uses: dawidd6/action-ansible-playbook@master
|
uses: dawidd6/action-ansible-playbook@master
|
||||||
with:
|
with:
|
||||||
playbook: deploy.yml
|
playbook: deploy.yml
|
||||||
|
directory: ./
|
||||||
key: ${{secrets.SSH_PRIVATE_KEY}}
|
key: ${{secrets.SSH_PRIVATE_KEY}}
|
||||||
options: |
|
options: |
|
||||||
--inventory hosts
|
--inventory hosts
|
||||||
|
|
|
@ -7,6 +7,9 @@ inputs:
|
||||||
playbook:
|
playbook:
|
||||||
description: Ansible playbook filepath
|
description: Ansible playbook filepath
|
||||||
required: true
|
required: true
|
||||||
|
directory:
|
||||||
|
description: Root directory of Ansible project (defaults to current)
|
||||||
|
required: false
|
||||||
key:
|
key:
|
||||||
description: SSH private key used to connect to the host
|
description: SSH private key used to connect to the host
|
||||||
required: true
|
required: true
|
||||||
|
|
5
main.sh
5
main.sh
|
@ -3,6 +3,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
playbook="$INPUT_PLAYBOOK"
|
playbook="$INPUT_PLAYBOOK"
|
||||||
|
directory="$INPUT_DIRECTORY"
|
||||||
key="$INPUT_KEY"
|
key="$INPUT_KEY"
|
||||||
options="$INPUT_OPTIONS"
|
options="$INPUT_OPTIONS"
|
||||||
|
|
||||||
|
@ -16,6 +17,10 @@ if test -z "$key"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test -n "$directory"; then
|
||||||
|
cd "$directory"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$HOME/.ssh"
|
mkdir -p "$HOME/.ssh"
|
||||||
echo "$key" > "$HOME/.ssh/id_rsa"
|
echo "$key" > "$HOME/.ssh/id_rsa"
|
||||||
chmod 600 "$HOME/.ssh/id_rsa"
|
chmod 600 "$HOME/.ssh/id_rsa"
|
||||||
|
|
Loading…
Reference in a new issue