Playbook linting

Viewed 946

I want to lint a playbook to detect following few among many other possibilities:

  1. Undefined variable
  2. Unused variable
  3. See if vars defined, when case-ignored, are same( conflicting vars hereafter)

I'm not able to figure out what is the good way to do this? I don't want to re-invent the wheel, in the sense that:

  1. I don't want to do text processing. Ansible does this to accomplish its task.
  2. Hooks or callbacks if I'm not wrong are couple of levels higher than where I think my solution should hop in.

My intention is to write a tool that seamlessly, and optionally, works with ansible. I would like not to modify ansible's code if I can do without.

Any help or hack or suggestion is appreciated.

PS: Syntax check wouldn't tell me about what I have mentioned above. I've taken a look at the ansible-lint tool. It does text processing, doesn't support inventory(for host_vars etc) and doesn't use ansible python API. So in order to do what I need, I'd have to call many internal APIs of ansible and I would end up writing ansible's code in my tool.

1 Answers
Related