Ansible Monitoring #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ansible Monitoring | |
on: | |
workflow_dispatch: | |
jobs: | |
monitoring-stack-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get Workflow Run ID | |
id: get-run-id | |
run: | | |
RUN_ID=$(curl -s \ | |
-H "Authorization: Bearer ${{ secrets.TOKEN }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/terraform-apply.yml/runs?branch=infra_main&per_page=1" \ | |
| jq -r '.workflow_runs[0].id') | |
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT | |
echo "$RUN_ID" | |
- name: Write Private Key to File | |
run: | | |
echo "${{ secrets.PRIVATE_KEY }}" > ${{ vars.TF_KEY_PAIR_NAME }}.pem | |
chmod 600 ${{ vars.TF_KEY_PAIR_NAME }}.pem | |
- name: Download Ansible Inventory | |
uses: actions/download-artifact@v4 | |
with: | |
name: ansible_inventory | |
github-token: ${{ secrets.TOKEN }} | |
run-id: ${{ steps.get-run-id.outputs.run_id }} | |
- name: Verify Ansible Inventory | |
run: | | |
cat inventory.ini | |
- name: "Install Ansible" | |
uses: alex-oleshkevich/[email protected] | |
with: | |
version: "9.3.0" | |
- name: Run Ansible Playbook | |
run: | | |
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventory.ini ./ansible/playbook.yml \ | |
--extra-vars "frontend_domain=${{ vars.TF_FRONTEND_DOMAIN }} \ | |
traefik_domain=${{ vars.TF_TRAEFIK_DOMAIN }} \ | |
cert_email=${{ secrets.TF_CERT_EMAIL }}" |