Red Hat Certified Engineer RHCE · Free Practice Question Medium

Question 8

You are running an Ansible playbook, and one of the tasks fails unexpectedly. How would you configure Ansible to continue running the playbook even if one of the tasks fails, ensuring that the rest of the tasks are executed?

  • A

    Configuring Ansible to Continue After a Task Fails
    To ensure a playbook continues after a task failure, use ignore_errors:

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

In this playbook, the ignore_errors directive is used to ensure that Ansible continues executing subsequent tasks even if a specific task fails. This is particularly useful in scenarios where some failures are acceptable or expected, and you do not want the playbook to halt entirely. By setting ignore_errors: yes in a task, Ansible prevents a failure in that task from interrupting the overall execution flow, allowing the playbook to complete and execute all other tasks as planned.

Line-by-Line Explanation

Defines that the tasks will be executed on all hosts specified in the inventory.

Starts the list of tasks to be performed.

Specifies the first task, which is intentionally set up to fail.

Executes the /bin/false command, which always returns a failure status (exit code 1).

Ensures that the playbook will not stop if this task fails. Ansible will log the failure but proceed to subsequent tasks.

Specifies the next task to be executed regardless of the outcome of the previous task.

Uses the debug module to display a message for demonstration.

Prints the message, confirming that the playbook continues execution.

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