Courseiva

EX294 Implement advanced Ansible automation Practice Question

Exhibit

Refer to the exhibit.
---
- name: example block
  block:
    - name: risky task
      command: /bin/false
  rescue:
    - name: rescue task
      debug:
        msg: "Rescued"
  always:
    - name: always task
      debug:
        msg: "Always runs"

Refer to the exhibit. An Ansible playbook contains the following block structure. If the task inside the block fails, which of the following describes the execution order of the rescue and always sections?

⚠ Common exam trap

It's easy for candidates to confuse the order of rescue and always, mistakenly thinking always runs first or that only one of them executes, when in fact rescue runs before always on failure.

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

✓

Rescue runs, then always.

In Ansible, when a task inside a block fails, the rescue section executes to handle the failure, and then the always section runs unconditionally. This ensures that cleanup or finalization tasks are performed regardless of success or failure. Therefore, the correct execution order is rescue first, then always.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Only always runs.

    Why it's wrong here

    The rescue section executes whenever a task in the block fails, before always runs; only always running describes a block lacking rescue. Rescue is tempting because it handles failures, but it is the correct choice precisely when you need recovery steps between failure and cleanup.

  • ✗

    Only rescue runs.

    Why it's wrong here

    The always section executes even when rescue handles the failure, so omitting it is wrong. Always exists precisely to guarantee teardown or notification tasks run on every outcome, making it the correct mechanism when cleanup must not be skipped after a rescued failure.

  • ✓

    Rescue runs, then always.

    Why this is correct

    When a task inside a block fails, Ansible transfers control to the rescue section, executing its tasks to handle the error. After rescue completes, the always section runs regardless of success or failure, ensuring cleanup tasks execute. This matches Ansible's documented block error-handling flow, satisfying the stem's requirement to describe execution order.

  • ✗

    Always runs, then rescue.

    Why it's wrong here

    Ansible runs the rescue section first to handle the failed task, then always runs last regardless of outcome, so this reverses the documented order. Always is designed for cleanup that must execute whether the block succeeds or fails, which is why it is sequenced after rescue.

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 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.