Courseiva

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

    Ansible loads role defaults from defaults/main.yml; vars/defaults.yml is never read automatically, so overrides fail. The vars directory is tempting because it holds higher-precedence role variables, and vars/main.yml would be correct for values intended to override playbook variables rather than be overridden.

  • ✓

    defaults/main.yml

    Why this is correct

    Placing variables in defaults/main.yml gives them the lowest precedence in Ansible's variable hierarchy, so playbook vars, host vars and role params all override them automatically. This satisfies the stem's requirement for easily overridden role defaults, unlike vars/main.yml, whose higher precedence resists such overrides.

  • ✗

    default_vars/main.yml

    Why it's wrong here

    Ansible loads role defaults only from defaults/main.yml; default_vars/main.yml is never read, so the variables would be undefined. Defaults are tempting because they have the lowest precedence and are overridden by playbook vars, which is exactly what defaults/main.yml provides.

  • ✗

    vars/main.yml

    Why it's wrong here

    vars/main.yml holds role variables with high precedence, so playbook variables cannot override them, contradicting the requirement. It is tempting because it does define variables, but it is intended for values that should take priority over playbook input, not for overridable defaults.

About these practice questions

Courseiva writes every EX294 question from scratch — 392 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 →

How Courseiva writes practice questions · Editorial policy

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.