Courseiva

EX294 Manage task execution and roles Practice Question

Exhibit

Refer to the exhibit.

---
- hosts: webservers
  roles:
    - role: common
    - role: nginx
      vars:
        http_port: 8080
  tasks:
    - name: ensure nginx is running
      ansible.builtin.service:
        name: nginx
        state: started

What is the purpose of the 'vars' keyword under the httpd role inclusion?

⚠ Common exam trap

Candidates often confuse the 'vars' keyword under a role inclusion with setting global playbook variables, but it only overrides variables for that specific role instance.

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

✓

Override default variables for that role

The 'vars' keyword under a role inclusion in Ansible allows you to override the default variables defined within that specific role. This is done at the point of inclusion, providing role-specific variable overrides without affecting other roles or the playbook's global variable scope.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Set variables for the common role

    Why it's wrong here

    The vars keyword supplies variables to the included role itself, not to a separate common role. Confusion arises because roles can share variables through group_vars or role dependencies, but vars here scopes values to the httpd role's tasks. It would target another role only if that role were the one being included.

  • ✗

    Define new variables for the playbook

    Why it's wrong here

    Playbook-level variables belong under vars at the play level, not nested inside a role inclusion. The keyword here passes variables into the httpd role's context, overriding its defaults for that invocation. Defining playbook-wide values would instead use a play vars block or vars_files.

  • ✗

    Set variables for all roles in the play

    Why it's wrong here

    Role-level vars apply only to that role's invocation, not play-wide; play vars or extra vars scope across all roles. It is tempting because vars: does pass parameters into a role, which is correct when you want to override defaults for that single role only.

  • ✓

    Override default variables for that role

    Why this is correct

    Passing `vars` under a role inclusion overrides that role's default variables for the current play only, without editing the role's `defaults/main.yml`. This satisfies the scenario's need to customise role behaviour per host or play while keeping the role reusable and unmodified.

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.