12 Commits

Author SHA1 Message Date
Dawid Dziurla
f13d1bd963 Merge pull request #3 from dawidd6/directory
Directory
2020-03-24 23:40:03 +01:00
Dawid Dziurla
c94ab57c30 main: don't require directory input to be set 2020-03-24 22:44:07 +01:00
Dawid Dziurla
7294666400 action: remove default value for directory input 2020-03-24 22:43:22 +01:00
Dawid Dziurla
6bf8287520 workflows: change default directory to ./ 2020-03-24 22:32:24 +01:00
Dawid Dziurla
bf72c8dfa3 README: change default directory to ./ 2020-03-24 22:30:07 +01:00
Dawid Dziurla
5f9b0124a8 action: change default directory to ./
github.workspace directory is not available in container
2020-03-24 22:29:40 +01:00
Dawid Dziurla
05885e8435 workflows: add directory input 2020-03-24 22:26:46 +01:00
Dawid Dziurla
6125b23431 main: add directory input 2020-03-24 22:23:41 +01:00
Dawid Dziurla
106317ddaa README: add directory input 2020-03-24 22:23:30 +01:00
Dawid Dziurla
13970a992f action: add directory input 2020-03-24 22:23:19 +01:00
Dawid Dziurla
ca781d9ed5 Dockerfile.test: don't unlock root account 2020-03-23 23:15:41 +01:00
Dawid Dziurla
2f1261582a README: fix usage 2020-03-23 23:12:27 +01:00
5 changed files with 13 additions and 4 deletions

View File

@@ -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

View File

@@ -3,7 +3,6 @@ FROM alpine
RUN apk -U add openssh-server openssh-sftp-server sudo python3 RUN apk -U add openssh-server openssh-sftp-server sudo python3
RUN adduser -D user RUN adduser -D user
RUN passwd -u user RUN passwd -u user
RUN passwd -u root
RUN echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers RUN echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
RUN echo "PasswordAuthentication no" > /etc/ssh/sshd_config RUN echo "PasswordAuthentication no" > /etc/ssh/sshd_config
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config

View File

@@ -6,9 +6,10 @@ An action that executes given Ansible playbook on selected hosts.
```yaml ```yaml
- name: Run playbook - name: Run playbook
uses: dawidd6/action-ansible-playbook 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

View File

@@ -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

View File

@@ -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"