You must provision AWS infrastructure with Ansible. How would you structure it?
AdvancedScenarioAWX, Cloud and Large-Scale Operations
Answer
Situation read → Cloud provisioning.
What I'd do →
- Use
amazon.awsmodules (ec2_instance,ec2_security_group,elb_application_lb). - Run on
localhostwithconnection: local. - Auth with an IAM role or environment credentials, not keys in the repo.
- Make every call idempotent by naming and tagging.
- hosts: localhost
connection: local
gather_facts: false
tasks:
- amazon.aws.ec2_instance:
name: app-01
image_id: "{{ ami }}"
instance_type: t3.small
vpc_subnet_id: "{{ subnet }}"
tags: { Env: prod, Role: app }
state: running
Why → Tags identify existing resources, so reruns do not create duplicates.
Interview tip → Be ready to say Terraform provisions, Ansible configures, and why.
More on AWX, Cloud and Large-Scale Operations
Your company wants a self-service UI for running playbooks with RBAC. What do you propose?BeginnerHow do you run AWX on Kubernetes?BeginnerA job template should prompt for the target limit and a version, with validation.IntermediateYou need provisioning followed by configuration followed by an approval and then deploy.IntermediateA dynamic inventory source in AWX syncs slowly and stale hosts remain.IntermediateYou manage 5,000 servers and a single job takes hours.Advanced