mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2026-01-10 21:41:42 -07:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f13d1bd963 | ||
|
|
c94ab57c30 | ||
|
|
7294666400 | ||
|
|
6bf8287520 | ||
|
|
bf72c8dfa3 | ||
|
|
5f9b0124a8 | ||
|
|
05885e8435 | ||
|
|
6125b23431 | ||
|
|
106317ddaa | ||
|
|
13970a992f | ||
|
|
ca781d9ed5 | ||
|
|
2f1261582a |
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -21,7 +21,8 @@ jobs:
|
||||
--link host \
|
||||
-v $PWD:/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_OPTIONS="--inventory hosts --limit remote" \
|
||||
action
|
||||
|
||||
@@ -3,13 +3,12 @@ FROM alpine
|
||||
RUN apk -U add openssh-server openssh-sftp-server sudo python3
|
||||
RUN adduser -D user
|
||||
RUN passwd -u user
|
||||
RUN passwd -u root
|
||||
RUN echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
|
||||
RUN echo "PasswordAuthentication no" > /etc/ssh/sshd_config
|
||||
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
|
||||
RUN echo "AuthorizedKeysFile /etc/ssh/authorized_keys" >> /etc/ssh/sshd_config
|
||||
RUN echo "PermitRootLogin no" >> /etc/ssh/sshd_config
|
||||
RUN echo "Subsystem sftp /usr/lib/ssh/sftp-server" >> /etc/ssh/sshd_config
|
||||
RUN echo "Subsystem sftp /usr/lib/ssh/sftp-server" >> /etc/ssh/sshd_config
|
||||
|
||||
RUN ssh-keygen -A
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@ An action that executes given Ansible playbook on selected hosts.
|
||||
|
||||
```yaml
|
||||
- name: Run playbook
|
||||
uses: dawidd6/action-ansible-playbook
|
||||
uses: dawidd6/action-ansible-playbook@master
|
||||
with:
|
||||
playbook: deploy.yml
|
||||
directory: ./
|
||||
key: ${{secrets.SSH_PRIVATE_KEY}}
|
||||
options: |
|
||||
--inventory hosts
|
||||
|
||||
@@ -7,6 +7,9 @@ inputs:
|
||||
playbook:
|
||||
description: Ansible playbook filepath
|
||||
required: true
|
||||
directory:
|
||||
description: Root directory of Ansible project (defaults to current)
|
||||
required: false
|
||||
key:
|
||||
description: SSH private key used to connect to the host
|
||||
required: true
|
||||
|
||||
5
main.sh
5
main.sh
@@ -3,6 +3,7 @@
|
||||
set -e
|
||||
|
||||
playbook="$INPUT_PLAYBOOK"
|
||||
directory="$INPUT_DIRECTORY"
|
||||
key="$INPUT_KEY"
|
||||
options="$INPUT_OPTIONS"
|
||||
|
||||
@@ -16,6 +17,10 @@ if test -z "$key"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -n "$directory"; then
|
||||
cd "$directory"
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME/.ssh"
|
||||
echo "$key" > "$HOME/.ssh/id_rsa"
|
||||
chmod 600 "$HOME/.ssh/id_rsa"
|
||||
|
||||
Reference in New Issue
Block a user