44 lines
1.2 KiB
YAML
44 lines
1.2 KiB
YAML
name: Ansible Validate Playbook on Pull Request
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "ansible/playbook_*.yml"
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
- reopened
|
|
|
|
jobs:
|
|
ansible-apply:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup environment
|
|
uses: ./.github/actions/setup-env
|
|
|
|
- name: Setup Ansible environment
|
|
uses: ./.github/actions/setup-ansible-env
|
|
with:
|
|
vault_master_password: ${{ secrets.VAULT_MASTER_PASSWORD }}
|
|
ansible_user: ${{ secrets.ANSIBLE_USER }}
|
|
trusted_hosts: ${{ secrets.TRUSTED_HOSTS }}
|
|
|
|
- name: Apply the playbook that triggered the workflow
|
|
env:
|
|
VAULT_MASTER_PASSWORD: ${{ secrets.VAULT_MASTER_PASSWORD }}
|
|
ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }}
|
|
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
|
run: |
|
|
cd ansible
|
|
for PLAYBOOK in $(echo $CHANGED_FILES | grep -oP 'playbook_\K\w+'); do
|
|
sectool exec ansible-playbook -u $ANSIBLE_USER playbook_$PLAYBOOK.yml -CD
|
|
done
|