Implement standardized playbook organization with master orchestrator and Ansible collections requirements for extended functionality. Playbook Structure: playbooks/ ├── gather_system_info.yml # System inventory gathering ├── deploy_vm.yml # VM deployment (placeholder) ├── security_audit.yml # Security compliance checking (placeholder) ├── maintenance.yml # Routine maintenance tasks (placeholder) ├── backup.yml # Backup operations (placeholder) └── disaster_recovery.yml # DR procedures (placeholder) Master Playbook (site.yml): - Entry point for all infrastructure operations - Import structure for modular playbook organization - Tag-based execution for selective operations - Pre-flight checks and validations - Comprehensive documentation and usage examples Collections Requirements (collections/requirements.yml): - community.general: Essential utilities and modules - community.libvirt: KVM/libvirt management - ansible.posix: POSIX system administration - amazon.aws: AWS infrastructure management (optional) - Community versions for open-source compatibility Implemented Playbooks: 1. gather_system_info.yml: - Comprehensive system information gathering - Uses system_info role - Statistics export to ./stats/machines/ - Health checks and validation - Tag support: install, gather, export, validate, health-check 2. Placeholder Playbooks (documented structure): - deploy_vm.yml: VM provisioning with deploy_linux_vm role - security_audit.yml: CIS benchmark compliance checking - maintenance.yml: Updates, cleanup, optimization - backup.yml: Backup operations orchestration - disaster_recovery.yml: DR procedures and testing site.yml Master Playbook Features: - Central orchestration point - Import-based playbook inclusion - Tag inheritance and selective execution - Environment-aware (development, staging, production) - Pre-flight validation checks - Error handling and rollback support - Comprehensive inline documentation Usage Examples: ```bash # Run all playbooks ansible-playbook site.yml # Run specific playbook ansible-playbook site.yml --tags gather_info # Gather system information only ansible-playbook playbooks/gather_system_info.yml # Check syntax ansible-playbook site.yml --syntax-check # Dry run ansible-playbook site.yml --check # Limit to specific hosts ansible-playbook site.yml -l webservers ``` Collections Management: - Install: ansible-galaxy collection install -r collections/requirements.yml - Update: ansible-galaxy collection install -r collections/requirements.yml --upgrade - Location: ./collections/ (local) and ~/.ansible/collections (user) - Version pinning for stability - Community alternatives for RHEL-free deployments CLAUDE.md Compliance: ✅ Playbooks in ./playbooks/ directory ✅ Master playbook (site.yml) at root ✅ Tag-based execution support ✅ Modular organization with import_playbook ✅ Collections requirements documented ✅ Clear separation: playbooks (lasting) vs plays (temporary) Benefits: - Standardized playbook organization - Easy-to-navigate structure - Tag-based selective execution - Collection dependency management - Scalable to 100+ playbooks - Clear entry point (site.yml) - Environment isolation Next Steps: 1. Install collections: ansible-galaxy collection install -r collections/requirements.yml 2. Implement placeholder playbooks as needed 3. Add role-specific playbooks to playbooks/ directory 4. Create temporary plays in plays/ directory (per CLAUDE.md) 5. Test site.yml orchestration: ansible-playbook site.yml --check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
1.7 KiB
YAML
50 lines
1.7 KiB
YAML
---
|
|
# Playbook: Gather System Information
|
|
# Description: Collect comprehensive hardware and software information from all managed hosts
|
|
# Tags: system_info, inventory, monitoring
|
|
# Author: Ansible Infrastructure Team
|
|
|
|
- name: Gather comprehensive system information
|
|
hosts: all
|
|
become: true
|
|
gather_facts: true
|
|
|
|
vars:
|
|
# Override these variables as needed
|
|
system_info_stats_base_dir: "./stats/machines"
|
|
system_info_json_indent: 2
|
|
|
|
pre_tasks:
|
|
- name: Display playbook information
|
|
debug:
|
|
msg:
|
|
- "=================================================="
|
|
- "System Information Gathering Playbook"
|
|
- "=================================================="
|
|
- "Target hosts: {{ ansible_play_hosts | length }}"
|
|
- "Statistics directory: {{ system_info_stats_base_dir }}"
|
|
- "Timestamp: {{ ansible_date_time.iso8601 }}"
|
|
- "=================================================="
|
|
run_once: true
|
|
tags: [always]
|
|
|
|
roles:
|
|
- role: system_info
|
|
tags: [system_info]
|
|
|
|
post_tasks:
|
|
- name: Display completion summary
|
|
debug:
|
|
msg:
|
|
- "=================================================="
|
|
- "System Information Collection Complete"
|
|
- "=================================================="
|
|
- "Host: {{ ansible_fqdn }}"
|
|
- "Statistics saved to: {{ system_info_stats_dir }}"
|
|
- "Files created:"
|
|
- " - system_info.json (latest)"
|
|
- " - system_info_{{ ansible_date_time.epoch }}.json (backup)"
|
|
- " - summary.txt (human-readable)"
|
|
- "=================================================="
|
|
tags: [always]
|