Ansible Role Defaults Precedence: Lowest Priority Variables
Which TWO statements about Ansible role defaults are true?
Quick Answer
Role defaults having the lowest priority of all Ansible variables is correct because of what defaults/main.yml is designed to do: provide a fallback value that lets a role run out of the box, while still being trivially overridden by anyone using the role. Ansible's variable precedence system is built in layers, and defaults sit at the very bottom of that stack specifically so that any other variable source, such as group_vars, host_vars, playbook vars, or extra vars passed on the command line, can override them without any special syntax or effort. This is what makes roles reusable: the role author bakes in sensible starting values without locking consumers of the role into them. If defaults carried higher precedence, roles would become rigid and hard to customize, which would defeat their purpose as shareable, general-purpose building blocks. Whenever an exam question asks you to reason about which variable value wins in a conflict, it helps to remember that variable sources are essentially ranked by how likely they are to represent an intentional, specific override - defaults are the least specific and most easily overridden, while something like extra vars on the command line sits at the opposite end, so defaults will lose to virtually every other variable source.
⚠ Common exam trap
The EX294 exam often tests the distinction between role defaults and role vars, where candidates mistakenly think defaults have higher priority or cannot be overridden, but in reality defaults are the lowest priority and designed to be overridden by any other variable source.
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 are loaded from the defaults/main.yml file.
Ansible role defaults are defined in the defaults/main.yml file within the role directory structure. These defaults provide the most basic variable values that can be easily overridden by any other variable source, ensuring flexibility in role usage.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Defaults are only loaded if no vars are defined.
Why it's wrong here
Defaults are always loaded regardless of other variables.
- ✓
Defaults are loaded from the defaults/main.yml file.
Why this is correct
Defaults are defined in defaults/main.yml.
- ✗
Defaults have higher priority than variables defined in the playbook.
Why it's wrong here
Playbook variables have higher priority than defaults.
- ✗
Defaults cannot be overridden.
Why it's wrong here
Defaults are designed to be overridden by variables with higher priority.
- ✓
Defaults have the lowest priority of all variables.
Why this is correct
Role defaults are the lowest priority.
Go deeper
Related to this question
About these practice questions
One of 520 original EX294 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on EX294
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which TWO of the following statements about Ansible roles are correct?
medium- A.Role names must be prefixed with 'ansible-role-' when published to Ansible Galaxy.
- ✓ B.Variables in 'defaults/main.yml' have the lowest precedence and can be overridden by inventory variables.
- ✓ C.Role dependencies are defined in the 'meta/main.yml' file.
- D.The 'include_role' module can only be used for static imports.
- E.A role's tasks are executed before any 'pre_tasks' defined in the playbook.
Why B: Variables in defaults/main.yml have the lowest precedence and can be overridden by inventory variables. Role dependencies are defined in meta/main.yml. The other options are incorrect: pre_tasks run before roles, include_role is dynamic, and the naming convention is not mandatory.
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.