Skip to content
Open

Lab16 #4523

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7802d8e
chore: save current work before Java 21 upgrade
Ge-os Jan 28, 2026
6fa834b
add: lab01 sollution
Ge-os Jan 28, 2026
46977c8
add: lab solution and etc.
Ge-os Feb 4, 2026
2157f96
add: bonus task solution
Ge-os Feb 4, 2026
e6824d3
add: solution lab03
Ge-os Feb 12, 2026
813c5c7
Merge branch 'inno-devops-labs:master' into lab03
Ge-os Feb 12, 2026
2b0041d
fix: badge + other
Ge-os Feb 12, 2026
ce85924
Merge branch 'lab03' of https://github.com/Ge-os/DevOps-Core-Course i…
Ge-os Feb 12, 2026
30b769b
Merge pull request #3 from Ge-os/lab03
Ge-os Feb 19, 2026
afeb734
add: homework solution
Ge-os Feb 19, 2026
a9cbb54
fix: terraform and yandex config
Ge-os Feb 19, 2026
9879a0f
Merge branch 'inno-devops-labs:master' into master
Ge-os Feb 26, 2026
1233bdf
add: lab05 solution
Ge-os Feb 26, 2026
6f31f65
add: lab solution
Ge-os Mar 5, 2026
8c7ecf8
add: lab07 solution
Ge-os Mar 12, 2026
009405f
add: lab08 solution and report
Ge-os Mar 19, 2026
b94c930
Merge branch 'inno-devops-labs:master' into master
Ge-os Mar 26, 2026
12a1d13
Merge pull request #7 from Ge-os/lab08
Ge-os Mar 26, 2026
9c19530
add: lab9 solution
Ge-os Mar 26, 2026
0ab0fcd
Merge pull request #8 from Ge-os/lab09
Ge-os Mar 26, 2026
53f0cd9
add: lab10 solution
Ge-os Apr 2, 2026
67084b9
add: lab11 solution
Ge-os Apr 9, 2026
e3b6771
Merge branch 'inno-devops-labs:master' into master
Ge-os Apr 16, 2026
4f324be
Merge pull request #10 from Ge-os/lab11
Ge-os Apr 16, 2026
6f6bef4
add: lab12 solution
Ge-os Apr 16, 2026
ed47249
add: lab14 solution
Ge-os Apr 30, 2026
7b9c680
add: lab15 solution
Ge-os May 7, 2026
6ca7239
lab16 solution
Ge-os May 13, 2026
248cafa
lab16: fix init containers and volume mounts, add evidence
Ge-os 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
96 changes: 96 additions & 0 deletions .github/workflows/ansible-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Ansible Deployment

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

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 Ansible dependencies
run: |
python -m pip install --upgrade pip
pip install ansible ansible-lint
ansible-galaxy collection install community.docker community.general

- name: Run ansible-lint
working-directory: ./ansible
run: |
ansible-lint playbooks/provision.yml playbooks/deploy.yml playbooks/site.yml

deploy:
name: Deploy Application
needs: lint
runs-on: ubuntu-latest
if: github.event_name == 'push'

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 dependencies
run: |
python -m pip install --upgrade pip
pip install ansible
ansible-galaxy collection install community.docker community.general

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

- name: Deploy with Ansible
working-directory: ./ansible
env:
ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
VM_HOST: ${{ secrets.VM_HOST }}
VM_USER: ${{ secrets.VM_USER }}
run: |
echo "$ANSIBLE_VAULT_PASSWORD" > /tmp/vault_pass
ansible-playbook playbooks/deploy.yml \
-i "$VM_HOST," \
-u "$VM_USER" \
--private-key ~/.ssh/id_rsa \
--vault-password-file /tmp/vault_pass \
-e "ansible_python_interpreter=/usr/bin/python3"
rm -f /tmp/vault_pass

- name: Verify deployment
env:
VM_HOST: ${{ secrets.VM_HOST }}
APP_PORT: '5000'
run: |
sleep 10
curl -f "http://$VM_HOST:$APP_PORT" || exit 1
curl -f "http://$VM_HOST:$APP_PORT/health" || exit 1
122 changes: 122 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Python CI/CD

on:
push:
branches: [ main, master, lab03 ]
paths:
- 'app_python/**'
- '.github/workflows/python-ci.yml'
pull_request:
branches: [ main, master ]
paths:
- 'app_python/**'
- '.github/workflows/python-ci.yml'

env:
PYTHON_VERSION: '3.13'
DOCKER_IMAGE: ge0s1/devops-python-app

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

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

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: 'app_python/requirements.txt'

- name: Install dependencies
working-directory: ./app_python
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ruff

- name: Lint with Ruff
working-directory: ./app_python
run: |
# Stop the build if there are Python syntax errors or undefined names
ruff check . --select=E9,F63,F7,F82 --output-format=full
# Check for other issues (non-blocking for now)
ruff check . --exit-zero

- name: Run tests with pytest
working-directory: ./app_python
run: |
pytest --cov=. --cov-report=xml --cov-report=term-missing

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./app_python/coverage.xml
flags: python
name: python-coverage
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

security:
name: Security Scan
runs-on: ubuntu-latest

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

- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/python@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --file=app_python/requirements.txt --severity-threshold=high

docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: [test, security]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/lab03')

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

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

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=lab03,enable=${{ github.ref == 'refs/heads/lab03' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
type=raw,value={{date 'YYYY.MM.DD'}}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./app_python
file: ./app_python/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
97 changes: 97 additions & 0 deletions .github/workflows/terraform-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Terraform CI

on:
push:
branches:
- main
- master
- lab04
paths:
- 'terraform/**'
- '.github/workflows/terraform-ci.yml'
pull_request:
branches:
- main
- master
paths:
- 'terraform/**'
- '.github/workflows/terraform-ci.yml'

jobs:
terraform-validate:
name: Validate Terraform Configuration
runs-on: ubuntu-latest

defaults:
run:
working-directory: terraform

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

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ~1.9.0

- name: Terraform Format Check
id: fmt
run: terraform fmt -check -recursive
continue-on-error: true

- name: Terraform Init
id: init
run: terraform init -backend=false

- name: Terraform Validate
id: validate
run: terraform validate -no-color

- name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.55.1

- name: Initialize TFLint
run: tflint --init
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run TFLint
id: tflint
run: tflint --format compact
continue-on-error: true

- name: Comment PR (if applicable)
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
script: |
const output = `#### Terraform Format Check 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
#### TFLint 📋\`${{ steps.tflint.outcome }}\`

<details><summary>Show Validation Output</summary>

\`\`\`
${{ steps.validate.outputs.stdout }}
\`\`\`

</details>

*Workflow: \`${{ github.workflow }}\`, Action: \`${{ github.event_name }}\`, Working Directory: \`terraform/\`*`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})

- name: Check Results
if: steps.fmt.outcome == 'failure' || steps.validate.outcome == 'failure'
run: |
echo "::error::Terraform validation failed!"
exit 1
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
test
test
.example

# Ansible
*.retry
.vault_pass
ansible/inventory/*.pyc
ansible/__pycache__/
__pycache__/

# Environment secrets
.env
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Labs](https://img.shields.io/badge/Labs-18-blue)](#labs)
[![Exam](https://img.shields.io/badge/Exam-Optional-green)](#exam-alternative)
[![Duration](https://img.shields.io/badge/Duration-18%20Weeks-lightgrey)](#course-roadmap)
[![Ansible Deployment](https://github.com/ge-os/DevOps-Core-Course/actions/workflows/ansible-deploy.yml/badge.svg)](https://github.com/ge-os/DevOps-Core-Course/actions/workflows/ansible-deploy.yml)

Master **production-grade DevOps practices** through hands-on labs. Build, containerize, deploy, monitor, and scale applications using industry-standard tools.

Expand Down
1 change: 1 addition & 0 deletions ansible/.vault_pass.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
123456
11 changes: 11 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[defaults]
inventory = inventory/hosts.ini
roles_path = roles
host_key_checking = False
remote_user = root
retry_files_enabled = False

[privilege_escalation]
become = True
become_method = sudo
become_user = root
Loading
Loading