0Pricing
Ansible Academy · Lesson

Custom Assertions with the fail Module

Stop a play with a clear message.

Stop With a Clear Message

Sometimes you want to halt a play on purpose with a helpful reason. The fail module does exactly that. 🛑

The fail Module

ansible.builtin.fail stops the current host with a custom message you write, instead of a cryptic error.

- name: Refuse unsupported OS
  ansible.builtin.fail:
    msg: "This playbook supports Ubuntu only"

All lessons in this course

  1. Group Tasks with block
  2. Try / Catch with rescue & always
  3. Control Failure: failed_when & ignore_errors
  4. Custom Assertions with the fail Module
← Back to Ansible Academy