HowTo Troubleshoot Ansible Playbook Errors Yamllint
Writing and ansible playbook is easy but if you miss little things spaces and alignment then your playbook is not going to execute. Let’s see howto troubleshoot ansible playbook errors Yamllint
HowTo Troubleshoot Ansible Playbook Errors Yamllint
Before jumping into the topic here are few ansible articles which may help you in learning ansible
- First Configuration After Ansible Installation
- Installing Python virtual Ansible Environment
- How To Write Ansible Playbook
- Configure SNMP Using Ansible Playbook
- Copying SSH Keys Using Ansible
- Install Ansible tower
- Ansible-Doc Accessing Documentation
- Lab Setup Using Docker Containers
A linter for YAML files. yamllint does not only check for syntax validity, but for weirdnesses like key repetition and cosmetic problems such as lines length, trailing spaces, indentation, etc.
On Fedora / CentOS
sudo dnf install yamllint
On Debian / Ubuntu
sudo apt-get install yamllint
On older Debian / Ubuntu versions
sudo add-apt-repository -y ppa:adrienverge/ppa && sudo apt-get update sudo apt-get install yamllint
Alternatively using pip, the Python package manager
sudo pip install yamllint
If you prefer installing from source follow below steps
python setup.py sdist sudo pip install dist/yamllint-*.tar.gz
Yamllint command syntax
yamllint <Filename.yml>
Few Errors listed above.
Custom Linting file
$ yamllint -c ~/myconfig file.yaml
this custom lint config will make your life easier in troubleshoot ansible playbook
If you would like to check all the YAML files in directory then use below command to verify all of them
# yamllint workingcopies/*
Use Website links to validate your YAML file
Conclusion : Troubleshoot ansible playbook errors is made easy using YAML validator sites and yamllint command line tool.
Thanks for your wonderful Support and Encouragement