Interview Prep/Python for DevOps/Kubernetes, Docker, SSH & fleet automation

You need an inventory of all EC2 instances turned into an Ansible dynamic inventory. Python script or plugin?

BeginnerScenarioKubernetes, Docker, SSH & fleet automation
Answer

Situation read → Ansible already ships this.

What I'd do →

  1. Use the amazon.aws.aws_ec2 inventory plugin with keyed_groups on tags and filters.
  2. Only write a custom script if the source is something without a plugin (a CMDB API), outputting JSON with _meta.hostvars for --list.

Why → The maintained plugin handles pagination, caching and regions.

Interview tip → Knowing the plugin exists is the point.

All Python for DevOps questions Roadmap: Python for automation

More on Kubernetes, Docker, SSH & fleet automation