Courseiva
Transform data with filters and pluginseasyMultiple ChoiceObjective-mapped

EX294 Transform data with filters and plugins Practice Question

A playbook needs to set a fact 'total_memory' by summing the 'memory_mb' values from a list of servers. Which filter should be used?

⚠ Common exam trap

Test-takers frequently confuse the `map` filter's `attribute` parameter with a direct filter name argument, leading them to choose option B, or they incorrectly assume `sum` can accept an `attribute` parameter like some other filters do.

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

{{ servers | map(attribute='memory_mb') | sum }}

It uses the `map` filter with the `attribute` parameter to extract the `memory_mb` value from each dictionary in the list, then pipes the resulting list of integers into the `sum` filter to compute the total. This is the standard Ansible idiom for summing a specific attribute across a list of dictionaries.

Answer analysis

Option-by-option breakdown

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

  • {{ servers | map(attribute='memory_mb') | sum }}

    Why this is correct

    Correct: map attribute then sum.

  • {{ servers | map('memory_mb') | sum }}

    Why it's wrong here

    map expects a filter or lambda, not attribute name.

  • {{ servers | sum }}

    Why it's wrong here

    Would sum the list objects, not the attribute.

  • {{ servers | sum(attribute='memory_mb') }}

    Why it's wrong here

    The 'sum' filter does not take an attribute parameter.

About these practice questions

Courseiva writes every EX294 question from scratch — 520 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.