-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ansible-lint support #54
base: main
Are you sure you want to change the base?
Conversation
- Created a check goal for an ansible playbook (--syntax-check)
… by re-using lint/check code
ansible-lint will helpfully also pull in `ansible` as a module if there is an 'ansible' in the same venv. However, this isn't a general solution for running other binaries from the same venv. I would rather force using more robust features of PEX or the toolchain so that it's easier to use this as a base for other plugins or rules within this plugin
This option isn't plumbed with the VenvPexRequest, so I just use the PexRequest with additional args which do the same. VenvPexRequest mostly just adds the `--venv` argument to the PEX creation, so using the PexRequest in this way is mostly equivalent anyhow. `--venv prepend` prepends the binaries to the PATH, so they're discoverable
- new way to get sources - we no longer need to strip the top-level directory
required adding wrapping type to keep graph separate
the playbook itself is already included as a source
they're wrong, but at least they'll be easier to fix
Wow, that's a big PR :) |
rules and target_types merged too messily
using the envvar ANSIBLE_COLLECTIONS_PATHS, we can use the installed collections regardless of the location of the playbook and without relying on the local collections path. This also means that we don't have to relocate playbooks. Keeping playbooks in their positions in the repo makes relative references cleaner. For example, importing from /envs/prod/vars.yml
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. |
the *Option types are only necessary on the Subsystem class (as classvars), not dataclasses created from their values
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. |
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 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. |
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.
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!
I've started this split by at least moving the most logical, isolated block (the I was trying to add you as a reviewer to this - but couldn't last night. I gave up and went to bed instead. 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. |
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:
Tests:
Deferred: