Repository navigation
Infrastructure: Ansible Rolling Update System for Dependency Patching (oVirt-style) #682
Copy link
Copy link
Closed
Description
Objective
Implement an Ansible-based rolling update system for non-disruptive dependency patching across AutoBot's 5-VM infrastructure, inspired by oVirt's cluster upgrade patterns.
Background
- Issue Security: Remediate 5 CVEs in Python Dependencies #544 identified CVEs requiring Python dependency updates
- Direct pip upgrades could disrupt running services
- Need a systematic approach for future patching
Architecture Reference
oVirt-Style Patterns to Adopt
Based on research from oVirt Ansible modules and cluster upgrade issues:
- Maintenance Mode - Put host in maintenance before updates
- Rolling Updates - One VM at a time with health verification
- Service Migration - Drain connections before updating
- Health Verification - Confirm service health after each update
- Rollback Capability - Automatic rollback on failure
AutoBot VM Infrastructure
| VM | IP | Services | Update Order |
|---|---|---|---|
| VM3 (Database) | 172.16.168.23 | Redis Stack | 1st (stateful, needs careful handling) |
| VM2 (Backend) | 172.16.168.20 | FastAPI | 2nd (depends on Redis) |
| VM4 (AI/ML) | 172.16.168.24 | AI Stack, NPU | 3rd (depends on Backend) |
| VM1 (Frontend) | 172.16.168.21 | Vue.js | 4th (depends on Backend API) |
| VM5 (Browser) | 172.16.168.25 | Playwright | 5th (isolated) |
Proposed Playbook Structure
infrastructure/shared/scripts/ansible/
├── playbooks/
│ ├── patch-dependencies.yml # Main orchestrator
│ ├── patch-python-deps.yml # Python venv updates
│ ├── patch-system-packages.yml # apt package updates
│ └── patch-node-deps.yml # npm package updates
├── roles/
│ └── dependency_patching/
│ ├── tasks/
│ │ ├── main.yml
│ │ ├── pre-update.yml # Backup, drain, maintenance mode
│ │ ├── update-venv.yml # pip install --upgrade
│ │ ├── post-update.yml # Health check, restore
│ │ └── rollback.yml # Restore from backup
│ ├── vars/
│ │ └── main.yml # Package versions, CVE mappings
│ ├── handlers/
│ │ └── main.yml # Service restart handlers
│ └── templates/
│ └── requirements-update.txt.j2
Key Features
1. Pre-Update Phase
- name: Create venv backup
archive:
path: /opt/autobot/venv
dest: /opt/autobot/backups/venv-{{ ansible_date_time.iso8601_basic }}.tar.gz
- name: Drain active connections
uri:
url: "http://localhost:{{ service_port }}/admin/drain"
method: POST
- name: Wait for connections to close
wait_for:
port: "{{ service_port }}"
state: drained
timeout: 602. Rolling Update Strategy
- name: Update VMs in sequence
hosts: "{{ item }}"
serial: 1 # One VM at a time
max_fail_percentage: 0 # Stop on any failure
vars:
update_order:
- database
- backend
- ai_stack
- frontend
- browser3. Health Verification
- name: Verify service health after update
uri:
url: "http://{{ ansible_host }}:{{ service_port }}/health"
return_content: yes
register: health_check
until: health_check.status == 200
retries: 10
delay: 54. Automatic Rollback
- name: Rollback on failure
block:
- name: Update dependencies
pip:
requirements: /tmp/requirements-update.txt
virtualenv: /opt/autobot/venv
rescue:
- name: Restore venv from backup
unarchive:
src: "{{ latest_backup }}"
dest: /opt/autobot/
remote_src: yes
- name: Restart service
systemd:
name: "{{ service_name }}"
state: restartedCVE-Specific Updates (Issue #544)
Package updates to implement:
filelock3.18.0 → 3.20.1+ (GHSA-w853-jp5j-5j7f)keras3.11.2 → 3.12.0+ (4 CVEs)langchain-core0.3.74 → 0.3.81+ (2 CVEs)markdownify0.11.6 → 0.14.1+ (GHSA-7mpr-5m44-h73r)marshmallow3.26.1 → 3.26.2+ (GHSA-428g-f7cq-pgp5)pypdf5.9.0 → 6.4.0+ (4 CVEs)starlette0.47.2 → 0.49.1+ (GHSA-7f5h-v6xp-fcq8)urllib32.5.0 → 2.6.0+ (2 CVEs)werkzeug3.1.3 → 3.1.4+ (GHSA-hgf8-39gv-g3f2)requests2.31.0 → 2.32.4+ (2 CVEs)
Usage
# Preview changes (dry run)
./deploy.sh --patch-dependencies --check
# Update all VMs with rolling updates
./deploy.sh --patch-dependencies
# Update specific VM group
ansible-playbook playbooks/patch-dependencies.yml --limit backend
# Emergency rollback
./deploy.sh --rollback-dependenciesTasks
Phase 1: Core Infrastructure
- Create
dependency_patchingrole - Implement pre-update backup and drain logic
- Implement venv update with pip
- Add health verification handlers
Phase 2: Rolling Update Orchestration
- Create
patch-dependencies.ymlmain playbook - Implement serial execution with proper ordering
- Add automatic rollback on failure
- Integrate with existing
health-check.yml
Phase 3: CLI Integration
- Add
--patch-dependenciestodeploy.sh - Add
--rollback-dependenciesoption - Add dry-run/check mode support
Phase 4: Testing & Documentation
- Test rolling update on staging
- Document usage in infrastructure/shared/scripts/ansible/README.md
- Add to maintenance procedures
Acceptance Criteria
- Can update Python dependencies on all VMs without service disruption
- Automatic rollback on failure
- Health checks pass before moving to next VM
- CLI integration with deploy.sh
- Works with existing Ansible infrastructure
Related
- Security: Remediate 5 CVEs in Python Dependencies #544 - CVE remediation (blocked by this)
- Existing Ansible infrastructure at
infrastructure/shared/scripts/ansible/
References
Labels
infrastructure, ansible, security, dependencies
Reactions are currently unavailable
Activity
mrveiss commentedon Dec 31, 2025
Implementation Complete ✅
The Ansible rolling update system has been implemented. Here's what was created:
New Role:
dependency_patchingLocation:
ansible/roles/dependency_patching/Structure:
New Playbook:
patch-dependencies.ymlLocation:
ansible/playbooks/patch-dependencies.ymlFeatures:
max_fail_percentage: 0(stops on any failure)Updated:
deploy.shNew CLI options:
--patch-dependencies- Live rolling update--patch-dependencies-check- Dry run (preview changes)--rollback-dependencies- Restore from backupKey oVirt-Style Patterns Implemented:
serial: 1block/rescuepattern restores on failureCVE Updates Configured:
Usage:
Files Changed:
ansible/roles/dependency_patching/(new role - 7 files)ansible/playbooks/patch-dependencies.yml(new playbook)ansible/deploy.sh(updated with 3 new options)Next Steps:
mrveiss commentedon Dec 31, 2025
Commit Complete ✅
All changes committed in
b80ff577:Critical Issues Fixed (from Code Review)
rollback-dependencies.ymlplaybook that targets only Python hostsCommit Details
Ready for Testing
The infrastructure is ready for testing. Use:
mrveiss commentedon Dec 31, 2025
Extending to System Package Updates
Now implementing the system (apt) package update capability as described in the issue's playbook structure:
patch-system-packages.yml- apt package updates with rolling deployment--patch-systemoptionThis complements the Python dependency patching already implemented.
mrveiss commentedon Dec 31, 2025
System Package Updates Implementation Complete ✅
Extended the rolling update infrastructure to support apt package updates.
New Files Created:
ansible/playbooks/patch-system-packages.yml- 6-phase rolling update for aptansible/playbooks/rollback-system-packages.yml- Emergency service restorationansible/roles/dependency_patching/tasks/update-system.yml- apt upgrade with backupansible/roles/dependency_patching/tasks/rollback-system.yml- Service restorationCLI Options Added to deploy.sh:
Features:
Code Review Fixes Applied:
ansible.builtin.copyinstead of shell)Commit:
Updated Checklist:
Phase 1: Core Infrastructure ✅
dependency_patchingrolePhase 2: Rolling Update Orchestration ✅
patch-dependencies.ymlmain playbookhealth-check.ymlPhase 3: CLI Integration ✅
--patch-dependenciestodeploy.sh--rollback-dependenciesoption--patch-systemoptions (NEW)Phase 4: System Package Updates ✅ (NEW)
patch-system-packages.ymlplaybookThe infrastructure is now complete for both Python dependency and system package patching.
feat(security): Ansible rolling update system for CVE remediation (#544…
feat(security): Add system package (apt) rolling updates (#682)
mrveiss commentedon Jan 6, 2026
Starting work on implementing the Ansible Rolling Update System for Dependency Patching.
Phase 1: Core Infrastructure - Beginning implementation of
dependency_patchingrole with:mrveiss commentedon Jan 6, 2026
Implementation Complete ✅
Changes Made:
1. Fixed host group name alignment across all files:
ansible/roles/dependency_patching/vars/main.yml- Changedai_stack→aiml,npu_workers→npuansible/playbooks/patch-dependencies.yml- Fixed host group referencesansible/playbooks/rollback-dependencies.yml- Fixed host group referencesansible/playbooks/patch-system-packages.yml- Fixed host group referencesansible/playbooks/rollback-system-packages.yml- Fixed host group references2. Fixed rollback order (from code review):
rollback-dependencies.ymlto use correct reverse order:npu → aiml → backend3. Improved rollback safety (from code review - HIGH priority):
ansible/roles/dependency_patching/tasks/rollback.ymlto use two-stage restore:Acceptance Criteria Verified:
dependency_patchingrole created with all required task filespatch-dependencies.ymlmain playbook created with serial executionhealth-check.yml--patch-dependenciesadded todeploy.sh--rollback-dependenciesoption addedCode Review Summary:
backend,frontend,database,aiml,npu,browserCLI Usage:
Files Modified:
ansible/roles/dependency_patching/vars/main.ymlansible/roles/dependency_patching/tasks/rollback.ymlansible/playbooks/patch-dependencies.ymlansible/playbooks/rollback-dependencies.ymlansible/playbooks/patch-system-packages.ymlansible/playbooks/rollback-system-packages.ymlNote:
The code review identified plaintext passwords in
inventory/production.ymlas a HIGH security concern. This is an existing infrastructure issue that should be addressed separately by migrating to Ansible Vault or SSH key-only authentication.mrveiss commentedon Jan 14, 2026
Related: GUI Foundation Implemented in #695
Issue #695 (Node Management UI) has been completed and provides the GUI infrastructure for this rolling update system:
Now Available via GUI
Per-Node Updates:
/api/infrastructure/nodes/{id}/check-updates)/api/infrastructure/nodes/{id}/update)system,security,dependencies,allDependency-Aware Ordering:
ROLE_DEPENDENCIESgraph implemented ininfrastructure_nodes.pyGET /api/infrastructure/nodes/update-ordercalculates proper update sequenceBatch Update Orchestration:
POST /api/infrastructure/nodes/update-batchruns updates across multiple nodesLifecycle Event Tracking:
UPDATE_STARTED,UPDATE_PROGRESS,UPDATE_COMPLETE,UPDATE_FAILEDWhat This Issue Still Covers
The Ansible playbook integration and CLI (
deploy.sh --patch-dependencies) aspects are still pending:dependency_patchingAnsible roledeploy.shThe GUI-based update system in #695 provides an alternative to the CLI approach, allowing ops to run updates per-node or in batches directly from the Infrastructure Settings UI.
fix(ansible): Align host groups and improve rollback safety (#682)
mrveiss commentedon Feb 10, 2026
Implementation: Fleet Overview Update Workflow
Starting work on the Fleet Overview integration for #682. The UI workflow will:
GET /api/updates/fleet-summaryendpoint returning per-node update countscode_statusandcode_versionfieldsChecklist
mrveiss commentedon Feb 10, 2026
Fleet Update Summary - Implementation Complete
What was implemented
Backend (SLM):
GET /api/updates/fleet-summaryendpoint — returns per-node update counts (system packages + code status)NodeUpdateSummaryandFleetUpdateSummaryResponseschemascode_version/code_statusadded toNodeResponseschema_build_node_summaries()extracted per Extract Method patternFrontend (SLM):
SLMNodetype extended withcode_status/code_versionNodeUpdateSummaryandFleetUpdateSummaryTypeScript interfacesX pkgs + codewhen updates availablefetchFleetUpdateSummary()action,nodesNeedingUpdatescomputed,getNodeUpdateSummary()getter'updates'action opens lifecycle panelCode review findings addressed
total_system_updatesdouble-counting global updates (was inflating by nodes × global_count)'updates'case with other lifecycle panel actionsFiles changed (8 files, +223/-9 lines)
autobot-slm-backend/api/updates.pyautobot-slm-backend/models/schemas.pyautobot-slm-frontend/src/types/slm.tsautobot-slm-frontend/src/composables/useSlmApi.tsautobot-slm-frontend/src/stores/fleet.tsautobot-slm-frontend/src/components/fleet/NodeCard.vueautobot-slm-frontend/src/components/fleet/FleetSummary.vueautobot-slm-frontend/src/views/FleetOverview.vueCommits
d911b5fefeat(slm): Add fleet update summary to Fleet Overview (Infrastructure: Ansible Rolling Update System for Dependency Patching (oVirt-style) #682)fac4c459fix(slm): Fix fleet total_system_updates double-counting (Infrastructure: Ansible Rolling Update System for Dependency Patching (oVirt-style) #682)feat(slm): Add fleet update summary to Fleet Overview (#682)
fix(slm): Fix fleet total_system_updates double-counting global updat…
fix: replace hardcoded /home/kali/Desktop/AutoBot in 20 runtime files (…