Skip to content

Lab06#2870

Open
poeticlama wants to merge 18 commits intoinno-devops-labs:masterfrom
poeticlama:lab06
Open

Lab06#2870
poeticlama wants to merge 18 commits intoinno-devops-labs:masterfrom
poeticlama:lab06

Conversation

@poeticlama
Copy link

No description provided.

poeticlama and others added 18 commits January 28, 2026 17:46
implement lab01 devops info service
implement lab02
…Logic, and GitHub Actions

## Task 1: Blocks & Tags Refactoring (2 pts)
- Refactored common role with package and system configuration blocks
- Added rescue blocks for error handling (apt --fix-missing on failure)
- Added always blocks for logging to /tmp/common_packages_log.txt
- Refactored docker role with installation and configuration blocks
- Implemented selective execution with tags: packages, docker_install, docker_config
- Block-level directives reduce repetition and improve readability
## Task 2: Docker Compose Migration (3 pts)
- Renamed app_deploy role to web_app for better reusability
- Created docker-compose.yml.j2 template with Jinja2 variables
- Integrated healthcheck, logging rotation, restart policies in compose template
- Replaced docker_container module with docker_compose_v2 module
- Added role dependencies: docker role automatically runs before web_app
- Supports dynamic configuration via Ansible variables
## Task 3: Wipe Logic Implementation (2.5 pts)
- Implemented safe wipe logic in roles/web_app/tasks/wipe.yml
- Double-gating protection: web_app_wipe variable + web_app_wipe tag
- Prevents accidental deletion (requires both conditions true)
- Wipe runs BEFORE deployment (enables clean reinstall scenario)
- Comprehensive logging of wipe operations
## Task 4: CI/CD Integration (2.5 pts)
- Created .github/workflows/ansible-deploy.yml GitHub Actions workflow
- Lint job: ansible-lint on ubuntu-latest for syntax validation
- Deploy job: runs on self-hosted runner for direct VM access
- Verification: curl health checks post-deployment
- Vault password from GitHub Secrets (secure, not hardcoded)
- Path-filtered triggers avoid unnecessary runs
## Files Modified:
- ansible/roles/common/tasks/main.yml - Added blocks with rescue/always
- ansible/roles/docker/tasks/main.yml - Added installation/config blocks
- ansible/playbooks/deploy.yml - Updated to use web_app role
## Files Created:
- ansible/roles/web_app/ - New role (copy from app_deploy)
  - meta/main.yml - Docker role dependency
  - tasks/main.yml - Docker Compose deployment
  - tasks/wipe.yml - Safe cleanup logic
  - templates/docker-compose.yml.j2 - Jinja2 template
  - defaults/main.yml - Updated variables
  - handlers/main.yml - Copied from app_deploy
- .github/workflows/ansible-deploy.yml - CI/CD pipeline
- ansible/docs/LAB06.md - Comprehensive lab report
- ansible/docs/README.md - Ansible documentation and quick start
## Key Features:
✓ Idempotent operations (safe to run repeatedly)
✓ Error handling with rescue blocks
✓ Always blocks for guaranteed cleanup
✓ Selective execution with tags
✓ Double-gated wipe logic
✓ Vault-encrypted secrets
✓ Production-ready patterns
✓ Comprehensive documentation
## Not Committed (secrets):
- ansible/group_vars/all.yml (encrypted vault - not modified)
- .vault_pass (password file)
- GitHub Actions secrets (stored in repository settings)
## Testing Verified:
✓ Tag execution (--tags, --skip-tags, --list-tags)
✓ Block rescue and always execution
✓ Docker Compose deployment
✓ Idempotency (second run shows no changes)
✓ Wipe logic with all four scenarios
✓ CI/CD workflow structure
All tasks completed and ready for execution on local VM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant