action-ansible-playbook/.github/workflows/test.yml

139 lines
6.1 KiB
YAML
Raw Normal View History

2020-03-21 10:06:40 -06:00
name: Test Action
2020-08-30 04:06:25 -06:00
on:
push:
branches:
- master
pull_request:
2020-03-21 10:06:40 -06:00
jobs:
2021-02-11 09:24:38 -07:00
remote:
2020-03-21 10:06:40 -06:00
runs-on: ubuntu-latest
2021-02-11 09:24:38 -07:00
env:
SSH_PRIVATE_KEY: |
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAw1mPRVbmzA1LGWbk9rk9lNxC34M7ZlCHi/OAgglMtFfP6f95hoNA
mSggomlTgQNysk1/kTfhVuIvVDVroTV6iyxM6b0eBOwSMglZn60PPZCXzF+VstfrMUH5Vd
PbuahVTW453g1ZAhwA+EPDBMEp2VzzbZgX7dCO0WnYrIrXknfiJ+sNYErVm9WqY58a7aoi
Y4eCgRD/9FGMyGoQcrmuHPR6tKCN0zIoVKl/wjzWH2jRUhRbZbf7V72VN+lWwJyciH7V+S
l4YZiob/JmW0FIPcWckoO1+hLUAQ0LpSaoCyz7ua+G0wgRoeLH3c32yQVjAHFesYzQymhn
/KVZBRPfdI2Hjzqj+cnYvyfy0t3R8/K6rdutRSYaQoqfFaFxoWtl59B/v5/IEE7s0Zsy2B
5ZJ4SbdYs1lA74UUGn+XjXVor7TTxvDWBV83npHFGBOhn3gqSLRcZ8JLb7KY5CGhbpy3z7
y5JDY0lYiZaWXTUQmIOfX54csTu40+yCnlCjRHaDAAAFiAuND90LjQ/dAAAAB3NzaC1yc2
EAAAGBAMNZj0VW5swNSxlm5Pa5PZTcQt+DO2ZQh4vzgIIJTLRXz+n/eYaDQJkoIKJpU4ED
crJNf5E34VbiL1Q1a6E1eossTOm9HgTsEjIJWZ+tDz2Ql8xflbLX6zFB+VXT27moVU1uOd
4NWQIcAPhDwwTBKdlc822YF+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qP5ydi/J/LS3dHz8rqt261FJhpCip8VoXGha2Xn0H+/n8gQTuzRmzLYHlknhJt1izWUDvhRQaf5eNdWivtNPG8NYFXzeekcUYE6GfeCpItFxnwktvspjkIaFunLfPvLkkNjSViJlpZdNRCYg59fnhyxO7jT7IKeUKNEdoM=
2020-03-21 10:06:40 -06:00
steps:
2020-03-22 05:17:17 -06:00
- name: Checkout code
uses: actions/checkout@v4
2020-05-01 12:11:28 -06:00
- name: Setup remote
2020-03-22 05:17:17 -06:00
run: |
2021-02-11 09:24:38 -07:00
echo "$SSH_PUBLIC_KEY" | sudo tee /etc/ssh/authorized_keys
2020-05-01 12:11:28 -06:00
sudo tee /etc/ssh/sshd_config <<EOF
PasswordAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile /etc/ssh/authorized_keys
PermitRootLogin no
Subsystem sftp /usr/lib/openssh/sftp-server
EOF
sudo systemctl restart sshd
echo 'SSH_KNOWN_HOSTS<<EOF' >> $GITHUB_ENV
echo $(ssh-keyscan localhost) >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
2021-02-11 09:24:38 -07:00
- name: With everything
2020-05-01 12:11:28 -06:00
uses: ./
with:
playbook: playbook.yml
2021-02-11 09:24:38 -07:00
key: ${{env.SSH_PRIVATE_KEY}}
known_hosts: ${{env.SSH_KNOWN_HOSTS}}
2020-05-14 12:20:43 -06:00
directory: test
configuration: |
[defaults]
callbacks_enabled = ansible.posix.profile_tasks, ansible.posix.timer
stdout_callback = yaml
nocows = false
2021-02-11 09:24:38 -07:00
vault_password: test
requirements: requirements.yml
2020-05-01 12:11:28 -06:00
inventory: |
[all]
localhost
2020-05-03 04:45:56 -06:00
options: |
-e docker_image=docker_url
2020-09-04 02:16:36 -06:00
-e docker_username=user
-e docker_password=pass
2020-05-03 04:45:56 -06:00
-e db_name=db_name
-e db_user=db_user
-e db_pass=db_pass
2021-02-11 09:24:38 -07:00
local:
2020-04-06 15:45:33 -06:00
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: With custom ansible.cfg
uses: ./
with:
playbook: playbook.yml
directory: test
configuration: |
[defaults]
callbacks_enabled = ansible.posix.profile_tasks, ansible.posix.timer
stdout_callback = yaml
nocows = false
options: --inventory hosts
2021-02-11 09:24:38 -07:00
- name: With requirements
uses: ./
with:
playbook: playbook.yml
2021-02-11 09:28:23 -07:00
directory: test
2021-02-11 09:24:38 -07:00
requirements: requirements.yml
options: --inventory hosts
- name: With requirements bundle
2020-04-06 16:03:41 -06:00
uses: ./
with:
playbook: playbook.yml
2021-02-11 09:28:23 -07:00
directory: test
2021-02-11 09:24:38 -07:00
requirements: requirements-bundle.yml
options: --inventory hosts
- name: With vault password
uses: ./
with:
playbook: playbook.yml
2021-02-11 09:28:23 -07:00
directory: test
vault_password: test
2021-02-11 09:24:38 -07:00
options: --inventory hosts
2021-07-26 10:29:42 -06:00
- name: With sudo
uses: ./
with:
playbook: playbook.yml
directory: test
sudo: true
options: --inventory hosts