ansibleyamllintansible-lint

Identify Ansible playbooks


I would like to add an automatic syntax check (as CI process) for all the Ansible playbooks in my project, using ansible-lint. There are playbooks in several directories in the project, so I thought of using something like locate *.yml. However, the problem is that there are some other YAML files in my project, which are not Ansible playbooks, and therefore I would not want ansible-lint to test those files(as it will always fail).

Is there any way to distinguish between ansible playbooks and regular YAML files?


Solution

  • I assume all your ansible-playbooks contain something like - hosts, perhaps you can use grep for that search query. And then perform the linter on the found files with | xargs ansible-lint.

    So forget the .yaml file extension, but take another approach. You'll figure it out :)