EX294 Manage task execution and roles Practice Question
A team is writing an Ansible role to configure a web server. They want to include default variables that can be easily overridden by playbook variables. Which directory and file should they use to define these variables?
⚠ Common exam trap
Many exam-takers confuse the `defaults/` directory (lowest precedence) with the `vars/` directory (higher precedence), or they invent non-standard directory names like `default_vars/`, because the exam tests precise knowledge of the Ansible role directory structure and variable precedence rules.
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
✓
defaults/main.yml
In Ansible roles, default variables are defined in the `defaults/main.yml` file. These variables have the lowest precedence, meaning they can be easily overridden by playbook variables, inventory variables, or any other variable source with higher precedence. This design allows role authors to provide sensible defaults while giving users the flexibility to customize behavior without modifying the role itself.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
vars/defaults.yml
Why it's wrong here
Standard location is defaults/main.yml, not vars/defaults.yml.
- ✓
defaults/main.yml
Why this is correct
This file contains variables with the lowest precedence, allowing easy override.
- ✗
default_vars/main.yml
Why it's wrong here
This directory is not part of the standard Ansible role structure.
- ✗
vars/main.yml
Why it's wrong here
Variables here have high precedence and cannot be overridden by playbook variables.
Go deeper
Related to this question
About these practice questions
Courseiva writes every EX294 question from scratch — 520 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 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.