Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/ansible-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Ansible Deployment

on:
push:
paths:
- 'ansible/**' # Ansible code
- '!ansible/docs/**' # Exclude docs
- '!ansible/README.md'
- '.github/workflows/ansible-deploy.yml' # Workflow changes
pull_request:
paths:
- 'ansible/**' # Ansible code
- '!ansible/docs/**' # Exclude docs
- '!ansible/README.md'
- '.github/workflows/ansible-deploy.yml' # Workflow changes

jobs:
lint:
name: Ansible Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'

- name: Install dependencies
run: |
pip install ansible ansible-lint

- name: Run ansible-lint
run: |
cd ansible
ansible-lint playbooks/*.yml

deploy:
name: Deploy Application
needs: lint
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'

- name: Install dependencies
run: |
pip install ansible

- name: Run playbook
run: |
cd ansible
touch /tmp/vaultpass.txt
chmod 600 /tmp/vaultpass.txt
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > /tmp/vaultpass.txt
ansible-playbook playbooks/deploy.yml -i inventory/hosts-runner.ini --vault-password-file /tmp/vaultpass.txt
rm /tmp/vaultpass.txt

- name: Verify deployment
run: |
sleep 10 # Wait for app to start
curl -f http://${{ secrets.VM_HOST }}:5000 || exit 1
curl -f http://${{ secrets.VM_HOST }}:5000/health || exit 1
2 changes: 2 additions & 0 deletions ansible/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
skip_list:
- no-handler
3 changes: 3 additions & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[![Ansible Deployment](https://github.com/Error10556/DevOps-Core-Course/actions/workflows/ansible-deploy.yml/badge.svg)](https://github.com/Error10556/DevOps-Core-Course/actions/workflows/ansible-deploy.yml)

# Ansible deployment
Loading
Loading