Workflow for setting up monitoring with ansible #2
This file contains hidden or 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: 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 |