Skip to content
Open

Lab14 #4528

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7bbe6b2
feat: implement lab01 devops info service
Jan 28, 2026
f85babf
delete venv
Jan 28, 2026
ed30f42
Egor Belozerov lab2
Feb 9, 2026
c2513dc
Egor Belozerov lab2
Feb 9, 2026
772b669
feat: add pipelines, tests, docs
Feb 12, 2026
e545e3b
feat: add pipelines, tests, docs
Feb 12, 2026
ee13324
fix: pipe
Feb 12, 2026
9ff03f8
fix: pipe
Feb 12, 2026
31c0804
fix: pipe
Feb 12, 2026
77245bb
fix: pipe
Feb 12, 2026
67a1525
fix: pipe
Feb 12, 2026
09647c6
fix: pipe
Feb 12, 2026
a38ce22
fix: percentage of coverage
Feb 12, 2026
7fcae2c
fix: percentage of coverage
Feb 12, 2026
c593ada
fix: bandit
Feb 12, 2026
174a9a0
fix: docs
Feb 12, 2026
0a2c25e
fix: yaml -> yml
Feb 12, 2026
f84fe75
chore: change docs add docker image link
Feb 12, 2026
03fd27c
terraform part
Feb 19, 2026
ca6abd1
terraform part
Feb 19, 2026
eac0e75
Egor Belozerov lab5
Feb 26, 2026
ba736e5
test
essence-666 Mar 5, 2026
eba4017
fix linter
essence-666 Mar 5, 2026
4e86d3d
add vault password for linter
essence-666 Mar 5, 2026
8f8ec17
linter only on roles and playbooks
essence-666 Mar 5, 2026
3dd0679
uncomment paths
essence-666 Mar 5, 2026
71776f2
uncomment paths
essence-666 Mar 5, 2026
628736c
Lab07
Mar 12, 2026
fb0390c
Merge pull request #7 from essence-666/lab07
essence-666 Mar 17, 2026
39a1a95
lab8
essence-666 Mar 18, 2026
9a79d76
Merge pull request #8 from essence-666/lab08
essence-666 Mar 25, 2026
2616dcd
lab 9
essence-666 Mar 25, 2026
0a52bcf
Merge pull request #9 from essence-666/lab09
essence-666 Apr 1, 2026
1f5e4c3
Lab 10
essence-666 Apr 2, 2026
3dcf26b
Merge pull request #10 from essence-666/lab10
essence-666 Apr 9, 2026
d9d1a5c
lab11
essence-666 Apr 16, 2026
05d8345
Merge pull request #11 from essence-666/lab11
essence-666 Apr 16, 2026
a55ddce
lab12
essence-666 Apr 16, 2026
40eacab
Merge pull request #12 from essence-666/lab12
essence-666 Apr 16, 2026
b20aba6
lab13
essence-666 Apr 23, 2026
5731359
Merge pull request #13 from essence-666/lab13
essence-666 Apr 23, 2026
05111f1
lab14
May 14, 2026
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
75 changes: 75 additions & 0 deletions .github/workflows/ansible-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Ansible Deployment

on:
push:
branches: [ main, master, lab06 ]
paths:
- "ansible/**"
- ".github/workflows/ansible-deploy.yml"
pull_request:
branches: [ main, master, lab06 ]
paths:
- "ansible/**"

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.12"

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

- name: Run ansible-lint

run: |
ansible-lint playbooks/*.yml roles/**/*.yml

deploy:
name: Deploy Application
needs: 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.12"

- name: Install Ansible
run: pip install ansible

- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.VM_HOST }} >> ~/.ssh/known_hosts

- name: Deploy with Ansible
env:
ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
run: |
cd ansible
echo "$ANSIBLE_VAULT_PASSWORD" > /tmp/vault_pass
ansible-playbook playbooks/deploy.yml \
-i inventory/hosts.ini \
--vault-password-file /tmp/vault_pass \
--tags "app_deploy"
rm /tmp/vault_pass

- name: Verify Deployment
run: |
sleep 10
curl -f http://${{ secrets.VM_HOST }}:8000 || exit 1
curl -f http://${{ secrets.VM_HOST }}:8000/health || exit 1
86 changes: 86 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Python CI - DevOps Info Service

on:
push:
branches: [ "**" ]
tags:
- "v*.*.*"
paths:
- "app_python/**"
- ".github/workflows/python-ci.yml"

pull_request:
branches: [ "main" ]
paths:
- "app_python/**"

jobs:
test:
name: Lint & Test
runs-on: ubuntu-latest

defaults:
run:
working-directory: app_python

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: |
app_python/requirements.txt
app_python/requirements-dev.txt

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt

- name: Run linter (ruff)
run: |
pip install ruff
ruff check .

- name: Run tests with coverage
run: |
pytest --cov=. --cov-report=term-missing --cov-fail-under=60

- name: Install Bandit
run: pip install bandit

- name: Run Bandit security scan
run: bandit -r . -ll -s B101,B104

docker:
name: Build & Push Docker Image
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Extract version
id: vars
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v5
with:
context: ./app_python
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-service:${{ steps.vars.outputs.VERSION }}
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-service:latest
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
test
test
key.json
.terraform/
*.tfstate
*.tfstate.*
terraform.tfvars
.history/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
![CI](https://github.com/essence-666/DevOps-Core-Course/actions/workflows/python-ci.yml/badge.svg)


# DevOps Engineering: Core Practices

[![Labs](https://img.shields.io/badge/Labs-18-blue)](#labs)
Expand Down
1 change: 1 addition & 0 deletions ansible/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vault_pass
1 change: 1 addition & 0 deletions ansible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[![Ansible Deployment](https://github.com/essence-666/DevOps-Core-Course/actions/workflows/ansible-deploy.yml/badge.svg)](https://github.com/essence-666/DevOps-Core-Course/actions/workflows/ansible-deploy.yml)
6 changes: 6 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[defaults]
roles_path = ./roles:./playbooks/roles
inventory = ./inventory/hosts.ini
private_key_file = ~/.ssh/id_ed25519
remote_user = ubuntu
host_key_checking = False
Loading