Courseiva

EX294 Transform data with filters and plugins Practice Question

Consider the task: `- debug: msg={{ item | upper }}` with `loop: "{{ ['a','b'] }}"`. What will be the output?

⚠ Common exam trap

The trap here is that candidates may overlook the fact that the `upper` filter is applied to each item individually within the loop, leading them to think the output remains lowercase (Option B) or that the filter fails on a loop variable (Option A).

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

✓

Two debug messages: 'A' and 'B'

The `upper` filter in Ansible converts each string item in the loop to uppercase. The `loop` directive iterates over the list `['a','b']`, and for each iteration, the `{{ item | upper }}` expression applies the `upper` filter to the current item, resulting in `'A'` and `'B'`. The `debug` module then prints each transformed value as a separate message.

Answer analysis

Option-by-option breakdown

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

  • ✗

    An error because upper expects a string, not a loop variable.

    Why it's wrong here

    The upper filter accepts any value and coerces it to a string, so no type error occurs. It tempts because filters normally expect strings, but Jinja2's upper simply stringifies the loop variable, making the task valid.

  • ✗

    Two debug messages: 'a' and 'b'

    Why it's wrong here

    The upper filter transforms each item, so output is 'A' and 'B', not the lowercase originals. It tempts because loop iterates the list, but the filter is applied per item before the debug message renders, changing each value's case.

  • ✓

    Two debug messages: 'A' and 'B'

    Why this is correct

    The `upper` filter transforms each string to uppercase, and `loop` iterates the list, producing one debug message per item. This satisfies the stem's requirement that both list elements be processed individually, yielding 'A' then 'B' as separate task iterations rather than a single combined output.

  • ✗

    One debug message with the list ['A','B']

    Why it's wrong here

    Loop runs the task once per list element, producing two separate messages, not one combined list. It tempts because the filter could conceptually map over the list, but Ansible applies it to each item individually during iteration.

About these practice questions

One of 392 original EX294 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.