EX294 Transform data with filters and plugins Practice Question
A playbook uses the 'debug' module to print a variable 'myvar' which is a list of dictionaries. The output shows 'VARIABLE IS UNDEFINED' despite the variable being defined earlier. Which filter issue is most likely?
⚠ Common exam trap
It's easy for candidates to assume any variable defined earlier in the playbook is globally accessible, but Ansible's variable scoping with `include_role` is dynamic and does not automatically propagate role-internal variables to the parent play.
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
✓
The variable is defined in a role but the playbook uses include_role incorrectly.
When a variable is defined inside a role but the playbook uses `include_role` incorrectly (e.g., without `tasks_from` or with a static import instead of dynamic include), the variable may not be available in the play's variable scope. The `debug` module then reports 'VARIABLE IS UNDEFINED' because the variable was never loaded into the play's namespace. This is a common scoping issue with role variables and dynamic includes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The debug task uses 'var: myvar' instead of 'msg: "{{ myvar }}"'.
Why it's wrong here
Both are valid; 'var' prints the variable directly without extra quotes.
- ✗
The playbook uses 'set_fact' with quotes around the variable name.
Why it's wrong here
Quotes around variable name are fine.
- ✗
The variable contains a fact that is only available on the control node.
Why it's wrong here
Facts are gathered on target hosts, but can be used anywhere.
- ✓
The variable is defined in a role but the playbook uses include_role incorrectly.
Why this is correct
If the variable is defined inside a role but not exposed to the play, it will be undefined.
Go deeper
Related to this question
About these practice questions
This EX294 question is part of Courseiva's 520-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.