EX294 Manage task execution and roles Practice Question
A systems administrator needs to run a playbook that installs packages on a group of managed nodes. The playbook should run only on nodes that are part of the 'web_servers' group in the inventory. Which approach is best practice?
⚠ Common exam trap
The trap here is that candidates may overcomplicate the solution by choosing runtime flags or conditional logic, forgetting that Ansible's simplest and most explicit targeting method—setting 'hosts' to the group name—is both best practice and the most reliable for clarity and execution.
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
✓
Set 'hosts: web_servers' in the play.
Setting 'hosts: web_servers' in the play directly targets only the nodes in that inventory group, which is the simplest and most maintainable approach. This follows Ansible's best practice of declaring the target group explicitly in the playbook rather than relying on runtime flags or conditional logic, ensuring the playbook's intent is clear and portable.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Set 'hosts: web_servers' in the play.
Why this is correct
Directly targeting the group is the simplest and most readable approach.
- ✗
Set 'hosts: all' and use '--limit web_servers' when running ansible-playbook.
Why it's wrong here
This requires remembering the limit flag each run; not idempotent in playbook definition.
- ✗
Set 'hosts: localhost' and delegate tasks to web_servers.
Why it's wrong here
localhost is the control node, not the managed nodes; delegation complicates the setup.
- ✗
Set 'hosts: all' and use a 'when' condition to check if the node is in the web_servers group.
Why it's wrong here
Using 'hosts: all' runs on all nodes, requiring extra conditional logic that can be avoided.
Go deeper
Related to this question
About these practice questions
This EX294 question is part of Courseiva's 520-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 EX294 practice question is part of Courseiva's free Red Hat 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 EX294 exam.