Digging into playbook execution problems

There are cases where an Ansible execution will interrupt. Many things can cause these situations.

The single most frequent cause of problems I've found while executing Ansible playbooks is the network. Since the machine that is issuing the commands and the one that is performing them are usually linked through the network, a problem in the network will immediately show itself as an Ansible execution problem.

Sometimes, and this is particularly true for some modules, such as shell or command, the return code is non-zero, even though the execution was successful. In those cases, you can ignore the error by using the following line in your module:

ignore_errors: yes

For instance, if you run the /bin/false command, it will always return 1. To execute this in a playbook so that you can avoid it blocking there, you can write something like the following:

- name: Run a command that will return 1
command: /bin/false
ignore_errors: yes

As we have seen, /bin/false will always return 1 as return code, but we still managed to go forward in the execution. Be aware that this is a particular case, and often, the best approach is to fix your application so that you're following UNIX standards and return 0 if the application runs appropriately, instead of putting a workaround in your Playbooks.

Next, we will talk more about the methods we can use to diagnose Ansible execution problems.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.196.182