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

  1. First Configuration After Ansible Installation
  2. Installing Python virtual Ansible Environment
  3. How To Write Ansible Playbook
  4. Configure SNMP Using Ansible Playbook
  5. Copying SSH Keys Using Ansible
  6. Install Ansible tower
  7. Ansible-Doc Accessing Documentation
  8. 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

YAML Site

Yaml validator

Conclusion : Troubleshoot ansible playbook errors is made easy using YAML validator sites and yamllint command line tool.

Ansible Video Tutorial

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

1 Response

  1. krutik says:

    You can also use https://yamlonline.com/ for the yaml validator as well as yaml converter to json,csv,xml,base64 also for beautify and minify YAML.

Leave a Reply

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