Ahmed Baha Eddine Alimi - B23-SD-01 [Lab06 + Bonus Task] #7
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: "Ansible - Deploy Python App" | |
| on: | |
| push: | |
| branches: [main, master, lab06] | |
| paths: | |
| - 'ansible/vars/app_python.yml' | |
| - 'ansible/playbooks/deploy_python.yml' | |
| - 'ansible/roles/web_app/**' | |
| - '.github/workflows/ansible-deploy.yml' | |
| pull_request: | |
| branches: [main, master] | |
| paths: | |
| - 'ansible/vars/app_python.yml' | |
| - 'ansible/playbooks/deploy_python.yml' | |
| - 'ansible/roles/web_app/**' | |
| jobs: | |
| lint: | |
| name: "Ansible Lint" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install ansible and ansible-lint | |
| run: pip install ansible ansible-lint | |
| - name: Run ansible-lint | |
| run: | | |
| cd ansible | |
| ansible-lint playbooks/deploy_python.yml | |
| deploy: | |
| name: "Deploy Python App" | |
| needs: lint | |
| runs-on: self-hosted | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run deploy playbook | |
| run: | | |
| cd ansible | |
| ansible-playbook playbooks/deploy_python.yml | |
| - name: Verify python app health | |
| run: | | |
| sleep 5 | |
| curl -f http://localhost:8000/health |