Today we’re going to talk about Ansible troubleshooting and specifically about indentation errors.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot

Demo

The best way of talking about Ansible troubleshooting is to jump in a live Playbook to show you practically the error and how to solve it!

Error

``yaml

---

  • name: blockinfile module demo

hosts: all

become: true

tasks:

  • name: Generate /etc/hosts file

ansible.builtin.blockinfile:

state: present

dest: /etc/hosts

content: |

192.168.0.200 Playbook demo.example.com

`

Fix

`yaml

---

  • name: blockinfile module demo

hosts: all

become: true

tasks:

- name: Generate /etc/hosts file

ansible.builtin.blockinfile:

state: present

dest: /etc/hosts

content: |

192.168.0.200 Playbook demo.example.com

``

[code with ❤️ in GitHub](https://github.com/lucab85/ansible-pilot/tree/master/troubleshooting)

Conclusion

Now you know better how to troubleshoot the most common Ansible error about indentation.