Interview Prep/Ansible/Performance and Scale

How do you make dynamic inventory fast with many instances?

IntermediateProductionPerformance and Scale
Answer
  • Filter at the API (filters: and regions:) instead of fetching everything and discarding it client-side.
  • Enable plugin caching (cache: true, cache_timeout) so repeated runs and ansible-inventory calls do not call the EC2 API each time.
  • Avoid expensive compose expressions and unused hostnames strategies.
  • In AWX, use inventory sources with "update on launch" and a cache timeout, or schedule syncs separately from jobs.
plugin: amazon.aws.aws_ec2
regions: [ap-south-1]
filters:
  tag:Managed: ansible
  instance-state-name: running
cache: true
cache_timeout: 300
All Ansible questions Roadmap: Ansible

More on Performance and Scale