Skip to content

Workflow for setting up monitoring with ansible #2

Workflow for setting up monitoring with ansible

Workflow for setting up monitoring with ansible #2

name: Workflow for setting up monitoring with ansible
on:
workflow_run:
workflows: ["Deploy infrastructure"]
types: [completed]
jobs:
deploy:
name: Deploy monitoring stack
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Ansible
shell: bash
run: |
sudo apt update
sudo apt install -y ansible
- name: create ansible config file
run: |
touch infrastructure/ansible/ansible.cfg
echo "[defaults]" > infrastructure/ansible/ansible.cfg
echo "inventory = inventory.ini" >> infrastructure/ansible/ansible.cfg
echo "private_key_file = /home/runner/.ssh/id_rsa" >> infrastructure/ansible/ansible.cfg
echo "remote_user = ${{ secrets.REMOTE_USER }}" >> infrastructure/ansible/ansible.cfg
- name: Run Ansible playbook
run: |
cd infrastructure/ansible
ansible-playbook playbook.yaml