Ansible - ansible-lint

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 Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 9b81c in the box below so that we can be sure you are a human.