Projects and Inventories

Managing 15 Git Repositories and 300+ Hosts

When we hit 15 different Git repositories containing our Ansible playbooks and 300+ servers spread across AWS, Azure, and on-premises datacenters, our simple static inventory file approach collapsed.

Manual inventory maintenance consumed 4 hours weekly. Servers were added to AWS but forgotten in inventories. Dynamic inventory scripts ran locally but weren't centralized. Different teams had different inventory files that conflicted.

Implementing AAP's advanced project and inventory features changed everything. We consolidated 15 projects into organized SCM-backed resources, implemented cloud dynamic inventories that auto-sync every 5 minutes, created smart inventories for complex filtering, and built a single source of truth for all infrastructure.

Manual inventory maintenance: 4 hours/week → 0 hours/week. Inventory accuracy: 75% → 99%. Time saved: 200+ hours annually.

This article shares the project and inventory patterns that made it possible.

What You'll Learn

  • Multi-repository project management strategies

  • Git branch and tag workflows in AAP

  • Collections and Execution Environments in projects

  • Cloud dynamic inventory sources (AWS, Azure, GCP, VMware)

  • Smart inventories with advanced filters

  • Inventory plugins and custom sources

  • Performance optimization for large inventories

  • Inventory variable management at scale

Advanced Project Management

Multi-Environment Project Strategy

Pattern 1: Multiple Branches, Single Project

Pattern 2: Git Tags for Releases

Pattern 3: Multiple Repositories

Real-world implementation: We use Pattern 3 with separate repos per domain, and Pattern 1 within each repo for environment separation.

Collections in Projects

Modern Ansible uses Collections. AAP handles this elegantly.

requirements.yml in Project:

Project Configuration:

Real-world benefit: Collections auto-update from Automation Hub. No manual installation on execution nodes.

Execution Environments in Projects

Projects can specify required Execution Environment:

Cloud Dynamic Inventories

AWS EC2 Inventory

Configuration:

Resulting Inventory Groups:

Real-world AWS example:

Azure Resource Manager Inventory

Configuration:

Real-world Azure pattern:

GCP Compute Inventory

Configuration:

VMware vCenter Inventory

Configuration:

Real-world VMware insight: We use custom attributes in vCenter (Environment, Application, Owner) which automatically become inventory groups in AAP.

Smart Inventories

Smart Inventories are dynamic subsets of other inventories based on filters.

Creating Smart Inventories

Use Case: All Web Servers Across All Clouds

Advanced Smart Inventory Filters

Filter Syntax:

Real-world smart inventories:

Inventory Variables at Scale

Variable Precedence

Variable Organization Patterns

Pattern 1: Group Variables for Common Config

Pattern 2: Host Variables for Specific Config

Pattern 3: Inventory Source Variables

Pattern 4: Constructed Variables

Real-world variable strategy:

Performance Optimization

Large Inventory Best Practices

Challenge: 500+ host inventory taking 2 minutes to sync

Solution:

Results:

  • Sync time: 2 minutes → 15 seconds

  • Host count: 800 → 520 (excluded irrelevant hosts)

  • Job launch delay: Eliminated

Inventory Update Strategies

Strategy 1: Update on Launch

Strategy 2: Scheduled Updates

Strategy 3: Manual Updates

Our approach: Scheduled updates every 5 minutes for cloud inventories, on-launch for critical inventories.

Custom Inventory Scripts

For sources AAP doesn't support natively:

Example: Custom CMDB Integration

AAP Configuration:

Key Takeaways

Multi-project strategy - separate by concern or environment ✅ Cloud dynamic inventories - auto-sync from AWS/Azure/GCP ✅ Smart inventories - powerful filtering across all sources ✅ Variable precedence - understand the hierarchy ✅ Performance optimization - cache, filter, schedule wisely ✅ Custom scripts - integrate any data source

What's Next

The next article covers Job Templates and Workflows - building parameterized automation, visual workflow designer, approval gates, and complex multi-step automation orchestration.


Next Article: Job Templates and Workflows →

Additional Resources


Part of the Ansible Automation Platform 101 Series

Last updated