EX294 Manage task execution and roles Practice Question
A team has developed several roles that share common variables. They want to organize these variables in a central file. Where should they place this file so it is automatically loaded by all roles?
⚠ Common exam trap
Red Hat often tests the distinction between role-level variable files (vars/main.yml and defaults/main.yml) and global variable files (group_vars/all.yml), trapping candidates who think a common role's vars/main.yml is automatically loaded by all roles when in fact it requires explicit role dependencies or includes.
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
✓
In the playbook directory as group_vars/all.yml
Placing a file in the playbook directory as group_vars/all.yml makes it automatically loaded by all roles. Ansible automatically includes any YAML files in the group_vars directory that match group names, and the special group 'all' applies to every host. This centralizes shared variables without requiring explicit imports in each role.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
In the inventory directory as host_vars/localhost.yml
Why it's wrong here
Placing shared variables in `host_vars/localhost.yml` scopes them to the localhost host only, so roles applied to other managed hosts never receive them. Host variables are intended for per-host customisation within an inventory; a central role-shared file belongs in `group_vars/all` or a role's `vars/main.yml`.
- ✗
In a common role's vars/main.yml
Why it's wrong here
A role's vars/main.yml has high precedence and is scoped to that role, so other roles do not inherit it automatically. It is the right location for constants a single role must not have overridden by inventory.
- ✗
In a common role's defaults/main.yml
Why it's wrong here
Variables in a common role's defaults/main.yml are scoped only to that role, so other roles never load them. It is tempting because defaults directories are the standard place for role variables, but central sharing requires group_vars or a vars file included via include_vars at play level.
- ✓
In the playbook directory as group_vars/all.yml
Why this is correct
Variables in group_vars/all.yml, relative to the playbook directory, are automatically loaded for every host in every play, giving all roles centralised access without explicit includes. This satisfies the requirement that the file load automatically for all roles.
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.