EX294 Implement advanced Ansible automation Practice Question
An automation engineer wants to run a playbook only on hosts that belong to both the 'webservers' group and the 'production' group. Which inventory grouping method achieves 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
✓
webservers:&production
In Ansible, the '&' operator is used to intersect groups. 'webservers:&production' targets hosts that are in both the 'webservers' and 'production' groups. Option B is wrong because 'webservers:production' uses ':' which is a union operator, meaning hosts in either group. Option C is wrong because 'webservers:!production' uses '!' to exclude hosts in production. Option D is wrong because 'webservers+,production' is not a valid inventory pattern; Ansible does not support '+' for group intersection.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
webservers:&production
Why this is correct
The :& intersection pattern targets hosts present in both groups simultaneously, matching the requirement to run only where webservers and production overlap. Other patterns like :! or union would include hosts outside the intended set.
- ✗
webservers:production
Why it's wrong here
Colon syntax nests groups, so webservers:production means production inside webservers, matching hosts in both only if the inventory is structured that way; the intersection pattern for two sibling groups is webservers:&production. It is tempting because colon notation is valid Ansible inventory syntax, but it expresses parent-child hierarchy, not intersection.
- ✗
webservers:!production
Why it's wrong here
The ! operator excludes production hosts, yielding webservers members that are not in production — the opposite of the intersection required. It is tempting because exclusions are commonly used to filter out hosts, and it would be correct if the playbook needed web servers outside production.
- ✗
webservers+,production
Why it's wrong here
The + operator builds the union of webservers and production, so hosts in either group run the playbook, including non-production web servers. It is tempting because unions are frequently used to target multiple groups, and it would be correct if the playbook needed to run on all hosts in both groups.
Go deeper
Related to this question
About these practice questions
This EX294 question is part of Courseiva's 392-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.