EX294 Manage task execution and roles Practice Question
An administrator is building a role whose task list must run a platform-specific set of tasks: one file for Red Hat Enterprise Linux hosts and another for Debian hosts, with the choice made at runtime based on gathered facts. The role must remain readable and avoid loading the wrong file even partially. Which approach should the administrator use?
⚠ Common exam trap
The trap here is assuming that a when condition on an imported task file prevents that file from being parsed, when imports are resolved before facts exist.
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
✓
Use ansible.builtin.include_tasks with a filename built from ansible_facts, so only the matching file is loaded at runtime.
Dynamic inclusion through include_tasks evaluates the filename expression when the task executes, after facts are available, so exactly one platform file is loaded. Static import_tasks resolves at parse time and cannot branch on facts, and tags or meta dependencies are selected by the operator or parse order rather than by host platform.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Place both platform task files in the role and rely on the role's meta/main.yml dependencies to select one.
Why it's wrong here
Role dependencies in meta/main.yml are resolved at parse time and cannot branch on gathered facts, so they cannot choose a platform file at runtime. Dependencies also run before the role's own tasks, which changes execution order and does not match the intended conditional selection.
- ✗
Put the platform-specific tasks directly in tasks/main.yml and use tags to select which ones run.
Why it's wrong here
Tags select tasks by label at invocation, not by host platform, so running the role without the right tags would apply tasks meant for another operating system. This couples the role's correctness to how operators invoke it rather than to the facts of each managed host.
- ✓
Use ansible.builtin.include_tasks with a filename built from ansible_facts, so only the matching file is loaded at runtime.
Why this is correct
include_tasks is processed dynamically during execution, so a filename assembled from a fact such as ansible_facts['os_family'] is evaluated when the task is reached and only the selected file is read. This keeps platform logic readable and avoids parsing the non-matching file entirely.
- ✗
Use ansible.builtin.import_tasks for both platform files and wrap each in a when condition.
Why it's wrong here
import_tasks is resolved when the playbook is parsed, before facts are gathered, so a when condition cannot control whether the file is loaded. Conditions are attached to the imported tasks and evaluated later, which means both files are parsed up front and the logic becomes harder to follow.
Visual reference
Go deeper
Related to this question
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 →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Red Hat exam blueprint
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.