Courseiva

EX294 Manage inventories and credentials Practice Question

An administrator manages a static inventory file with a group `web` defined as children of `production`. The inventory also defines a group variable `http_port=80` at the `all` group level and `http_port=8080` at the `web` group level. A playbook targets `hosts: web` and uses `{{ http_port }}` in a template. Which value will be used for hosts in the `web` group?

⚠ Common exam trap

The trap here is assuming that the broadest group (all) or file order dictates variable precedence, when actually child groups override parent groups.

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

✓

8080, because variables defined at the `web` group override those at the `all` group.

Ansible group variable precedence follows group depth: variables in child groups override those in parent groups. Since `web` is a child of `production` and `all` is the root, the `web` group variable http_port=8080 takes precedence over the `all` group variable http_port=80 for hosts in `web`. This ensures more specific settings are used. The other options misstate the precedence rules.

Answer analysis

Option-by-option breakdown

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

  • ✗

    80, because variables defined at the `all` group take precedence over child groups.

    Why it's wrong here

    Ansible variable precedence places more specific groups higher than broader groups. The `all` group is the broadest, so its variables are overridden by child groups. Therefore, 80 would not be used when a more specific group variable exists. This option incorrectly assumes parent groups override child groups, which is opposite to Ansible's behavior.

  • ✗

    80, because the play targets `web` but the variable is defined at `all` and that is the default.

    Why it's wrong here

    The play targeting `web` does not change variable precedence. The `all` group is the least specific, so its variables are overridden by any child group variables. The default behavior is not to prefer `all`; rather, more specific groups win. This option misstates precedence and would result in the wrong port being used.

  • ✓

    8080, because variables defined at the `web` group override those at the `all` group.

    Why this is correct

    In Ansible, group variable precedence increases with group depth. The `web` group is a child of `production`, which is a child of `all`. Variables defined at a more specific (deeper) group level override those at broader levels. Thus, http_port=8080 at the `web` group level takes precedence over http_port=80 at the `all` level for hosts in `web`. This is the correct value.

  • ✗

    8080, because the last definition in the inventory file wins regardless of group hierarchy.

    Why it's wrong here

    Ansible does not use a simple last-definition-wins rule for group variables across different groups. Precedence is based on group hierarchy, not file order. If both variables were in the same group, the last one might win, but here they are in different groups. This option incorrectly applies a file-order rule, which could lead to unpredictable results if the inventory order changes.

About these practice questions

This EX294 question is part of Courseiva's 392-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 →

How Courseiva writes practice questions · Editorial policy

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.