mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2024-11-22 07:26:25 +00:00
init
This commit is contained in:
parent
afff5c9738
commit
71c08da46c
8 changed files with 71 additions and 23 deletions
18
.github/workflows/test.yml
vendored
Normal file
18
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
name: Test Action
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Run
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
playbook: playbook.yml
|
||||||
|
options: |
|
||||||
|
--inventory=localhost,
|
||||||
|
--connection=local
|
||||||
|
--verbose
|
|
@ -1,7 +1,7 @@
|
||||||
FROM alpine:3.10
|
FROM alpine
|
||||||
|
|
||||||
COPY LICENSE README.md /
|
RUN apk -U add ansible bash
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY main.sh /
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/main.sh"]
|
||||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2018 GitHub, Inc. and contributors
|
Copyright (c) 2020 Dawid Dziurla
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -1,5 +1,2 @@
|
||||||
# Container Action Template
|
# Run Ansible playbook Github Action
|
||||||
|
|
||||||
To get started, click the `Use this template` button on this repository [which will create a new repository based on this template](https://github.blog/2019-06-06-generate-new-repositories-with-repository-templates/).
|
|
||||||
|
|
||||||
For info on how to build your first Container action, see the [toolkit docs folder](https://github.com/actions/toolkit/blob/master/docs/container-action.md).
|
|
||||||
|
|
26
action.yml
26
action.yml
|
@ -1,12 +1,18 @@
|
||||||
name: 'Container Action Template'
|
name: Run Ansible playbook
|
||||||
description: 'Get started with Container actions'
|
description: Execute Ansible playbook on selected hosts
|
||||||
author: 'GitHub'
|
branding:
|
||||||
|
color: red
|
||||||
|
icon: play
|
||||||
inputs:
|
inputs:
|
||||||
myInput:
|
playbook:
|
||||||
description: 'Input to use'
|
description: Ansible playbook filepath
|
||||||
default: 'world'
|
required: true
|
||||||
|
key:
|
||||||
|
description: SSH private key used to connect to the host
|
||||||
|
required: false
|
||||||
|
options:
|
||||||
|
description: Extra options that should be passed to ansible-playbook command
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: docker
|
||||||
image: 'Dockerfile'
|
image: Dockerfile
|
||||||
args:
|
|
||||||
- ${{ inputs.myInput }}
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh -l
|
|
||||||
|
|
||||||
echo "hello $1"
|
|
23
main.sh
Executable file
23
main.sh
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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 -n "$key"; then
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "$key" > ~/.ssh/id_rsa
|
||||||
|
chmod 400 ~/.ssh/id_rsa
|
||||||
|
fi
|
||||||
|
|
||||||
|
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||||
|
export ANSIBLE_FORCE_COLOR=True
|
||||||
|
|
||||||
|
ansible-playbook "$options" "$playbook"
|
7
playbook.yml
Normal file
7
playbook.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
- name: Test Action
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: Copy action.yml
|
||||||
|
copy:
|
||||||
|
src: action.yml
|
||||||
|
dest: /tmp/action.yml
|
Loading…
Reference in a new issue