DOP-C02 Configuration Management and IaC Practice Question
A company uses Ansible for configuration management on EC2 instances. They want to ensure that only instances with a specific tag (Environment: Production) are targeted by their playbooks. What is the best way to achieve this?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use the AWS EC2 dynamic inventory plugin to filter instances based on tags.
The best approach because the AWS EC2 dynamic inventory plugin allows filtering instances by tags (e.g., 'Environment: Production') at runtime, ensuring only tagged instances are targeted. Option A (adding a 'when' condition) is less efficient as it connects to all instances first. Option B (static inventory) requires manual updates and is not dynamic. Option D (ec2_tag module) is for assigning tags, not selecting instances.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Add a 'when' condition in the playbook to check the instance tag at runtime.
Why it's wrong here
This would still connect to all instances, wasting resources.
- ✗
Maintain a static inventory file listing only Production instances.
Why it's wrong here
Static inventory requires manual updates and is not scalable.
- ✓
Use the AWS EC2 dynamic inventory plugin to filter instances based on tags.
Why this is correct
Dynamic inventory can filter by tags, so playbooks run only on matching instances.
- ✗
Use the ec2_tag module to assign the tag to instances.
Why it's wrong here
Assigning tags doesn't select instances.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DOP-C02 question from scratch — 251 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.