willthames / ansible-review

MIT License
228 stars 37 forks source link

ability to load configuration from current repository (setup.cfg) #39

Open ssbarnea opened 7 years ago

ssbarnea commented 7 years ago

ansible-review should be able to detect configuration rules by looking inside current code directory, just like any other build and linting tools pep8, flake8, tox.

Having a user specific config file that is not kept as the same place as the code does not work well for codebases shared across multiple users.

I think that the use of setup.cfg should be a good idea as it avoids spamming the repository root with tons of config files for each tool. Most tools already support it.

vmindru commented 6 years ago

+1 this i am now having the same problem, though not sure this should go into setup.cfg i would rather have it under ~./.ansible-review/config.ini. @willthames what if we would have a separate config_file and change the following

         config_dir = AppDirs("ansible-review", "com.github.willthames").user_config_dir$                                                                                                                                 
         default_config_file = os.path.join(config_dir, "config.ini")$    

to something like

https://github.com/vmindru/ansible-review/commit/52986292c83a9de8f4f3f5d108faa64736289d50

Having .asnible_review local dir also brings the possibility to place lint and other rules locally close to the code and run asnible-review clean without flags, as this would involve additional operations to figure out those flags and location etc etc.

ansiblejunky commented 5 years ago

Typically for Ansible projects, we advise creating a repo for your playbooks (playbooks, hosts/inventory and group-var files, etc, and plugins, etc) and a repo for each of the Ansible Roles you build. The reason is, the playbook repo holds the config mgmt variables for each of our target environments.

So with this overall structure, I definitely don't want my lint rules inside each of these repos. This is what I did initially and it's a pain because you now have multiple-sources-of-truth for your lint rules.

As a team, we want to apply the rules and be able to update these rules at any time. So having the rules held in a separate repo (with only maybe the standards.py and the lint-rules folder) is the right direction. This allows the rules to have their own versioning. The ansible-review config file should be able to point to a repo instead of physical files on the system. Otherwise, at the moment I am forced to find a shared location that works for all of our developers (e.g. /usr/local/share/ansible) and git clone the files in a subfolder called lint or something. This way, it can be updated and there's one source of truth now. This means, if we update our lint repo with new rules or changed rules, or changed standards, then all of our ansible repos must comply to those rules.

Perhaps the config file should support this:

[rules]
lint = https://github.com/willthames/ansible-review/tree/master/lib/ansiblereview/examples/lint-rules
standards = https://github.com/willthames/ansible-review/tree/master/lib/ansiblereview/examples

Thoughts on this?