Red Hat Certified Engineer RHCE · Free Practice Question Medium

Question 6

You are tasked with ensuring a playbook continues to run even if a specific task fails. How would you configure error handling in the playbook using the ignore_errors directive to bypass task failures?

  • A

    Using ignore_errors to Continue Playbook Execution
    To bypass task failures and continue:

    This ensures that the playbook continues running even if the task fails.

  • B

    This is a performance based question and not multiple choice.  Therefore the answer is in #1.  If you require additional explanation, please ask your question in the Q&A section.

Reveal correct answer

Correct answer: A

A.

This playbook demonstrates how to use the ignore_errors directive in Ansible to ensure the playbook continues execution even if a specific task fails. By setting ignore_errors: yes for a task, any error occurring during the execution of that task will be bypassed, and subsequent tasks will proceed as intended. This method is particularly useful in scenarios where the failure of certain tasks is non-critical or expected, allowing the rest of the automation to continue uninterrupted.

Line-by-Line Explanation:

  1. Define the Target Hosts:

    • Specifies that the playbook will be executed on all hosts listed in the inventory.

  2. Define the Task That Might Fail:

    • Executes a shell command (command_that_might_fail) that has a potential to fail.

    • The ignore_errors: yes directive ensures that any failure in this task does not halt the playbook execution. Instead, the playbook moves on to the next tasks.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need