How to ignore bash command errors in Ansible

Ansible check the return codes of commands and modules and it fails with error if the action is not success. The playbooks will stop executing any more steps from this point.

Sometimes a command that returns different than 0 isn’t an error and it might be the default behavior. So we need to configure the playbook to ignore the error.

Let's see one sample snippet.

- name: Test command
  command: linux-command
  ignore_errors: yes

Here we need to replace the required Linux commands accordingly. Note that this will ignore the error whatever it is.

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *