playbook linting

We're growing the number of contributors, and some books are under rapid development. I'd love to be able to put a linter to the task of linting pull requests and yelling if something doesn't look right.

Any of you doing any kind of linting for playbook files?

-jlk

So for starters, though it’s not everything:

ansible-playbook --syntax-check exists

Part of the issue here is that it does a bit too much manual work, rather than relying on logic in the Playbook/Play classes, as it should – which has been on the list for a little while to get more back into shared code.

I generally believe this should be a task for core ansible, not a linter, and is why for instance we added a warnings feature for deprecation and some of the common YAML errors.

(i.e. extra external things shouldn’t be required, good things should be built in)

–Michael

Yeah, I'd be really happy if it was built into ansible!

We are aware of --syntax-check, and it helps, along with --list-hosts, but that doesn't catch attempts to make use of files that don't exist. Even that is tricky though, because you could be attempting to make use of a /generated/ file, so there would be false warnings that would have to be filtered out.

-jlk