mschuchard / linter-ansible-syntax

ansible syntax check linter for pulsar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for per-project parameters (inventory/roles_path/module_path)

oolongbrothers opened this issue · comments

Hi!

I'm loving the idea of having the official ansible-playbook syntax checking as a linter in Atom!

In the current form of the implementation I'm having troubles with making linter-ansible-syntax
work with my many different Ansible projects. All of them have different places for roles, inventories and the like. I realised that this is not a use case for this linter currently.

On the command line this is relatively easy to achieve without having to pass anything but the playbook name to ansible-playbook --check-syntax: As long as the playbook check is executed from within the directory where the playbook resides, an ansible.cfg file in the same folder will be picked up by ansible-playbook.
I'm wondering, could it maybe be a relatively easy way to support a vastly wider range of use cases by having the linter execute ansible-playbook in the folder where the playbook resides? That way ansible-playbook would automatically pick up a possible local ansible.cfg file, which would in turn add support for all the endless things that can be specified in the ansible.cfg to linter-ansible-syntax. This would also be easy to maintain, since no parameters need to be understood or touched by the linter.

But maybe I am missing something here?
I don't have experience with Atom package development but if you would be interested in implementing this, I would be willing to help out - in case you need any help at all 😛

Cheers,
oolongbrothers

This is a good idea for using per-project ansible.cfg and should be easy to implement. There is an API option for the node module that actually invokes ansible-playbook to execute in a specified directory, so I should just be able to pass the playbook directory variable to that option hash.

The bad news is I likely will not be able to get out a release with this feature for another few weeks. I just put out a release to make it Linter 2 compatible and I am in a "wait and see" mode for how that and the UI package are developing since that affects this, the ansible-lint package, and the terraform package. This is because they each do multi-file linting which is now different in Linter 2.

Great to hear!
No worries, there's no hurry. Better to keep an eye on quality now than pushing out features.
Ping me when you feel ready and need someone to test it out with a few use cases.

Ah, awesome! I have been testing master today and it has been working pretty well for me so far. Thanks for adding this in.
The only thing I was wondering is if it wouldn't be useful to explain this feature in the Readme/settings panel so that people can easily discover the full potential of linter-ansible-syntax.

Could you sat how could i use it to syntax check for roles/role_name/tasks/main.yml ?