Ansible - ansible-lint
by
Jeremy Canfield |
Updated: August 26 2020
| Ansible articles
This assumes you have installed ansible-lint.
Lint a playbook (yaml file)
Let's say you have a playbook named foo.yml that contains the following markup.
---
- hosts: all
tasks:
- debug:
msg: "Hello World"
Here is how to use the ansible-lint command to lint the foo.yml playbook.
ansible-lint foo.yml
Let's say the following output is displayed.
[201] Trailing whitespace
foo.yml:1
hosts: all
This means there is one or more whitespaces after the line hosts:all.
If the ansible-line command does not produce any output, then this means there were no issues detected with the playbook by the ansible-line command.
Lint a role
Let's say you have the following role directory.
/etc/ansible/roles/bar
Here is how to lint the YAML files below the "bar" roles directory.
ansible-lint /etc/ansible/roles/bar
Did you find this article helpful?
If so, consider buying me a coffee over at