--- - name: Demonstration of failed when hosts: nodes tasks: - name: Print the message debug: msg: "Incompatiable host not allowed in the list" when: ansible_default_ipv4.address == "192.168.0.2" - name: installing the zsh package dnf: name: zsh state: latest failed_when: ansible_default_ipv4.address == "192.168.0.2" ... # failed_when is used to mark the task a failed in the ansible even if the task executed itsel correctly # the 2nd task above is marked as failed in the ansible during playbook execution even though it is executed successfully with rc 0