Collection Architecture OverviewΒΆ
This document explains the high-level architecture of the Qubinode KVM Host Setup Collection, the design principles that guide its structure, and how the various components work together to provide a comprehensive KVM host management solution.
ποΈ Architectural PhilosophyΒΆ
The collection is built on several key architectural principles:
1. Modular Design (ADR-0002)ΒΆ
The collection follows a modular architecture where each role has a specific, well-defined responsibility. This approach provides:
Separation of Concerns: Each role focuses on one aspect of KVM host setup
Reusability: Roles can be used independently or in combination
Maintainability: Changes to one component donβt affect others
Testability: Each role can be tested in isolation
2. Layered ArchitectureΒΆ
The collection implements a layered architecture with clear dependencies:
βββββββββββββββββββββββββββββββββββββββββββ
β Orchestration Layer β
β (kvmhost_setup) β
βββββββββββββββββββββββββββββββββββββββββββ€
β Application Layer β
β (cockpit, user_config, storage) β
βββββββββββββββββββββββββββββββββββββββββββ€
β Infrastructure Layer β
β (libvirt, networking, base) β
βββββββββββββββββββββββββββββββββββββββββββ€
β Foundation Layer β
β (OS, hardware, services) β
βββββββββββββββββββββββββββββββββββββββββββ
3. Configuration-Driven ApproachΒΆ
The collection uses extensive configuration variables to adapt to different environments without code changes:
Environment Flexibility: Same code works across dev, staging, production
Platform Abstraction: Supports multiple RHEL-based distributions
Feature Toggles: Enable/disable features based on requirements
π§© Component ArchitectureΒΆ
Core Roles and Their ResponsibilitiesΒΆ
Foundation LayerΒΆ
kvmhost_base
Purpose: Provides foundational system configuration
Responsibilities:
OS detection and validation
Base package installation
EPEL repository configuration
Essential service setup
Dependencies: None (foundation role)
Infrastructure LayerΒΆ
kvmhost_networking
Purpose: Network infrastructure setup
Responsibilities:
Network bridge creation and configuration
Interface management
Network validation and testing
Dependencies: kvmhost_base
kvmhost_libvirt
Purpose: Virtualization infrastructure
Responsibilities:
Libvirt daemon configuration
Virtual network management
Hardware feature detection
Performance tuning
Dependencies: kvmhost_base, kvmhost_networking
Application LayerΒΆ
kvmhost_storage
Purpose: Storage management
Responsibilities:
Storage pool creation and management
LVM configuration
Performance optimization
Backup and snapshot management
Dependencies: kvmhost_base, kvmhost_libvirt
kvmhost_cockpit
Purpose: Web-based management interface
Responsibilities:
Cockpit installation and configuration
SSL certificate management
User access control
Module configuration
Dependencies: kvmhost_base, kvmhost_libvirt
kvmhost_user_config
Purpose: User environment configuration
Responsibilities:
User account management
Shell environment setup
SSH configuration
Development tools installation
Dependencies: kvmhost_base
Orchestration LayerΒΆ
kvmhost_setup
Purpose: Main orchestration and coordination
Responsibilities:
Role execution coordination
Variable validation
Feature detection
Performance optimization
Dependencies: All other roles
Validation and Support RolesΒΆ
edge_hosts_validate
Purpose: System validation and compliance checking
Responsibilities:
Filesystem validation
Package validation
RHSM registration validation
Dependencies: None (standalone)
swygue_lvm
Purpose: Advanced LVM management
Responsibilities:
LVM precheck and validation
LVM deployment and configuration
Dependencies: None (standalone)
π Data Flow ArchitectureΒΆ
Configuration FlowΒΆ
graph TD
A[User Variables] --> B[Variable Validation]
B --> C[Role Defaults Merge]
C --> D[Environment Detection]
D --> E[Feature Detection]
E --> F[Role Execution]
F --> G[Validation & Verification]
Execution FlowΒΆ
Initialization: Variable validation and environment detection
Foundation: Base system configuration (kvmhost_base)
Infrastructure: Network and virtualization setup
Application: Storage, web interface, user configuration
Optimization: Performance tuning and feature enablement
Validation: System validation and health checks
Dependency ResolutionΒΆ
The collection automatically resolves role dependencies:
# Dependency chain example
kvmhost_setup:
depends_on:
- kvmhost_base
- kvmhost_networking # requires kvmhost_base
- kvmhost_libvirt # requires kvmhost_base, kvmhost_networking
- kvmhost_storage # requires kvmhost_base, kvmhost_libvirt
- kvmhost_cockpit # requires kvmhost_base, kvmhost_libvirt
- kvmhost_user_config # requires kvmhost_base
π― Design PatternsΒΆ
1. Idempotency Pattern (ADR-0004)ΒΆ
Every task is designed to be idempotent:
Safe Re-execution: Can be run multiple times safely
State Convergence: Brings system to desired state regardless of current state
Change Detection: Only makes changes when necessary
2. Validation PatternΒΆ
Comprehensive validation at multiple levels:
Input Validation: Variables and prerequisites
Runtime Validation: Service status and configuration
Post-Configuration Validation: Functionality testing
3. Feature Detection PatternΒΆ
Automatic detection and adaptation:
Hardware Capabilities: CPU features, virtualization support
OS Capabilities: Distribution-specific features
Environment Context: Container vs. bare metal
4. Configuration Template PatternΒΆ
Standardized configuration management:
Template-Based: Jinja2 templates for configuration files
Variable-Driven: Configuration through variables
Environment-Aware: Adapts to different environments
π Security ArchitectureΒΆ
Security LayersΒΆ
Access Control: User and group management
Network Security: Firewall configuration and network isolation
Service Security: Secure service configuration
File Security: Proper permissions and SELinux contexts
Security PrinciplesΒΆ
Secure by Default: Secure configurations out of the box
Principle of Least Privilege: Minimal required permissions
Defense in Depth: Multiple security layers
Audit Trail: Logging and monitoring capabilities
π Scalability ArchitectureΒΆ
Horizontal ScalingΒΆ
Multi-Host Support: Same configuration across multiple hosts
Inventory-Based: Ansible inventory for host management
Parallel Execution: Concurrent role execution where possible
Vertical ScalingΒΆ
Resource Optimization: Performance tuning for larger workloads
Hardware Utilization: Efficient use of available resources
Storage Scaling: Flexible storage pool management
π§ Integration ArchitectureΒΆ
External System IntegrationΒΆ
Ansible Ecosystem: Leverages community collections
Container Platforms: Podman/Docker integration for testing
Monitoring Systems: Integration points for monitoring tools
Backup Systems: Hooks for backup and disaster recovery
API IntegrationΒΆ
Libvirt API: Direct integration with libvirt management
NetworkManager API: Network configuration through NetworkManager
System APIs: Integration with systemd and other system services
π Quality ArchitectureΒΆ
Testing StrategyΒΆ
Unit Testing: Individual role testing with Molecule
Integration Testing: Multi-role interaction testing
System Testing: End-to-end functionality validation
Performance Testing: Resource usage and performance validation
Quality AssuranceΒΆ
Automated Linting: Ansible-lint and YAML-lint integration
Security Scanning: Automated vulnerability scanning
Compliance Checking: ADR compliance validation
Documentation Validation: Documentation accuracy checking
π Evolution and MaintenanceΒΆ
Architectural EvolutionΒΆ
The architecture has evolved to support:
RHEL 9/10 Support: Extended platform support (ADR-0008)
Container Testing: Modern testing approaches (ADR-0012)
Automated Releases: CI/CD integration (ADR-0014)
Performance Optimization: Enterprise-grade performance
Maintenance StrategyΒΆ
Backward Compatibility: Maintaining compatibility across versions
Deprecation Management: Graceful deprecation of old features
Documentation Synchronization: Keeping docs in sync with code
Community Feedback Integration: Incorporating user feedback
π Architectural BenefitsΒΆ
For UsersΒΆ
Simplicity: Complex tasks made simple through automation
Reliability: Consistent, predictable behavior
Flexibility: Configurable for different use cases
Maintainability: Easy to understand and modify
For DevelopersΒΆ
Modularity: Clear separation of concerns
Testability: Comprehensive testing framework
Extensibility: Easy to add new features
Documentation: Well-documented design decisions
For OperationsΒΆ
Automation: Reduced manual intervention
Monitoring: Built-in health checks and validation
Scalability: Supports growth and expansion
Security: Security best practices built-in