Add ansible-lint support
I think this is pretty decent for ansible-lint support. I dropped the generator stuff from main, I'll reintroduce it later. Currently it does something similar but much more jank by fulling in a slightly tailored **/*
Features:
- ansible-lint support
- support for other Ansible artifacts (Playbook&context, Role, Collection)
Tests:
- some end2end tests
- capture the helloansible directory to test resources
Deferred:
- Use source generators instead of fancy globs
Wow, that's a big PR :)
Wow, that's a big PR :)
yeah it, uh, got away a bit. Some of it is ansible test code.
Heya, I've merged HEAD into this branch, a rebase was getting messy fast. There are some open mypy problems, most of them seems like Type Tetris related (some pants things aren't exported; I'm having trouble with some of the config settings like StrOption). LMK if you want me to work harder on those.
Okay, so - in the process of reviewing. Is there a mechanism to NOT take and entire subfolder and have it owned by Ansible? Like, can the list of sources be trimmed or filtered? I'm just trying to get my head around some of the Pants ownership semantics
Also, I might split this PR up into a couple of them, as there's a lot of intermingled items - so it's a bit tricky to grok all the changes.
Okay, so - in the process of reviewing. Is there a mechanism to NOT take and entire subfolder and have it owned by Ansible? Like, can the list of sources be trimmed or filtered? I'm just trying to get my head around some of the Pants ownership semantics
do you mean on the pants side, or the ansible side? I'm pretty sure there isn't a way to affect the ansible file discovery, and all files are technically fair game for ansible. That said, there's nothing stopping us from restricting pants to only pull in a constrained subset. We could also add tailor support, so it's not so kludgy to request that people add eg role_defaults() to a role's defaults/BUILD file; that would really help constrain things, and make it more reasonable to not pull in every file ansible might.
I haven't really read up on implementing tailor or on using target generation or any of that. I'm sure they'd provide benefits over the globs I have here, but also would make this MR even bigger.
Speaking of size, LMK if there's a way you'd like this broken up and I can help with that. I'm a history packrat so I didn't see a way to disentangle this, but if you'd like me to try again but more segmented this time I can give it a shot.
do you mean on the pants side, or the ansible side? I'm pretty sure there isn't a way to affect the ansible file discovery, and all files are technically fair game for ansible. That said, there's nothing stopping us from restricting pants to only pull in a constrained subset. We could also add tailor support, so it's not so kludgy to request that people add eg role_defaults() to a role's defaults/BUILD file; that would really help constrain things, and make it more reasonable to not pull in every file ansible might.
I meant on the Pants side with a sources filter. I used a glob previously for simplicity, but it allows the end-user to add/remove whatever they want and constrain as needed.
I haven't really read up on implementing tailor or on using target generation or any of that. I'm sure they'd provide benefits over the globs I have here, but also would make this MR even bigger.
Can be added as a different PR. I implemented it in a couple language targets, and if we can constrain the obvious ansible files (which is hard, as it's more free-form), it's surprisingly trivial to add tailor support!
Speaking of size, LMK if there's a way you'd like this broken up and I can help with that. I'm a history packrat so I didn't see a way to disentangle this, but if you'd like me to try again but more segmented this time I can give it a shot.
I've started this split by at least moving the most logical, isolated block (the ansible-lint tool itself) into a separate PR. We can always add to it when targets get changed and all of that. If the test coverage is in place, there won't be an accidental breakage.
I was trying to add you as a reviewer to this - but couldn't last night. I gave up and went to bed instead. https://github.com/sureshjoshi/pants-plugins/pull/64
Incomplete PR, as I haven't finished pulling in your testing. I've also tried to line it up with some of the other formatters/linters I've added - so there is consistency (and it should also be consistent with Pants mainline linters too).
There's currently a bug somewhere I think, as I'm only seeing a subset of lint bugs, but I haven't looked into it much.
Once that PR is merged, we can pull it in, and then have a PR for each Ansible "type" (role, collection, galaxy support + testing). That way each PR is pretty constrained in scope and easy to review, and test.