-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (48 loc) · 1.85 KB
/
ansible-monitoring.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Ansible Monitoring
on:
workflow_dispatch:
workflow_run:
workflows: ["Terraform Apply"]
types:
- completed
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_features&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
echo "${{ github.event.client_payload.run_id }}"
echo "${{ github.event.workflow_run.id }}"
- 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 }}"