Bootstrap FreeKB - Ansible - ansible-lint
Ansible - ansible-lint

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



Comments


Add a Comment


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