--- # ============================================================================= # Master Playbook - Ansible Infrastructure Automation # ============================================================================= # # This is the master playbook that orchestrates all infrastructure management # tasks across all environments. Use this playbook for complete infrastructure # deployment and configuration. # # Usage: # ansible-playbook site.yml # Full run # ansible-playbook site.yml --limit production # Specific environment # ansible-playbook site.yml --tags security # Specific tasks # ansible-playbook site.yml --check # Dry-run mode # # ============================================================================= - name: Infrastructure Management Master Playbook hosts: all gather_facts: true # Pre-flight validation pre_tasks: - name: Display execution environment debug: msg: - "=====================================" - "Ansible Infrastructure Automation" - "=====================================" - "Target: {{ inventory_hostname }}" - "Environment: {{ environment | default('undefined') }}" - "OS Family: {{ ansible_os_family }}" - "Distribution: {{ ansible_distribution }} {{ ansible_distribution_version }}" - "=====================================" tags: [always] - name: Validate required variables assert: that: - ansible_user is defined - ansible_become is defined fail_msg: "Required variables not defined. Check group_vars configuration." tags: [always, validate] roles: # Add roles as needed for your infrastructure # Example: # - role: common # tags: [common, baseline] # - role: security_baseline # tags: [security, hardening] post_tasks: - name: Display completion summary debug: msg: - "=====================================" - "Playbook execution completed" - "Host: {{ inventory_hostname }}" - "=====================================" tags: [always] # ============================================================================= # Infrastructure Components # ============================================================================= # System Information Gathering - name: Gather System Information import_playbook: playbooks/gather_system_info.yml tags: [never, system_info, inventory] # Security and Compliance - name: Security Audit and Compliance import_playbook: playbooks/security_audit.yml tags: [never, security, audit, compliance] # Maintenance Operations - name: System Maintenance import_playbook: playbooks/maintenance.yml tags: [never, maintenance, updates] # Backup Operations - name: Backup Infrastructure import_playbook: playbooks/backup.yml tags: [never, backup] # Disaster Recovery - name: Disaster Recovery Procedures import_playbook: playbooks/disaster_recovery.yml tags: [never, disaster_recovery, dr] # ============================================================================= # Tag Usage Guide # ============================================================================= # # Common tags: # always - Tasks that always run # validate - Validation and pre-flight checks # security - Security-related tasks # audit - Compliance auditing # maintenance - System maintenance # backup - Backup operations # system_info - System information gathering # # Usage examples: # ansible-playbook site.yml --tags security # ansible-playbook site.yml --tags "security,audit" # ansible-playbook site.yml --skip-tags backup # # =============================================================================