-
Notifications
You must be signed in to change notification settings - Fork 9
How to mark private plugins in a collection (with a proposal and implementation) #154
Comments
Implementations of my proposal:
|
+1 for the |
Definite +1 on having a way to have private content. It's a shame about not being able to use |
Let me clarify for posterity: +1 for the idea of being able to mark things private no matter the implementation method Also +1 for the |
I think this is a good idea. I also think that using |
+1 for the |
I'll also clarify why I'm not so keen on the underscore While Ansible is written in Python, and most modules are as well, a user of Ansible does not necessarily, and should not, need to understand Python conventions to use it. The convention has no specific semantic meaning that's obvious in the context of Ansible. In this way we would be adding meta meaning to a plugin or module's name, where there is no such implicit special meaning in these names generally. This can be a difficult point for us to grok since we're all pretty familiar with Python and use it so much to write ansible content. We should be careful about equating Ansible and Python, and about assuming Ansible users are Python programmers. The one exception is our existing convention for module_utils to be private by starting with an underscore. I also don't feel great about that one but it makes more sense because in plugins and in python-based modules, the utils are imported as python packages (it's more awkward in PowerShell module utils but that ship has sailed). |
From today's community meeting: #info There's some agreement that there should be a standardized way to mark content in a collection as private. If we proceed, the next steps are to decide whether to use the |
Based on review feedback in ansible/ansible#79218 I created a new PR for ansible-core in ansible/ansible#79370, which allows to mark plugins as private in |
Howdy! I absolutely like the idea of having private plugins, and I like the idea of using That said, I would prefer the metadata way. |
ansible-community/antsibull-docs#65 implements the metadata solution for antsibull-docs. (Will work also with older ansible-core versions.) |
The core team decided to not accept that PR, and in general they do not want to allow ansible-doc to not list all plugins by default (see the statement here: ansible/ansible#79370 (comment)). |
Ok. We cannot get support for this in ansible-doc, but we can get support for this in other projects, like antsibull-docs and antsibull-changelog. So IMO we should define a standard and try to get it implemented in multiple projects (like ansible-lint could warn if you use a private plugin from a collection someplace else). I want to start two votes on this:
What do you think about this? I'd especially like to hear about this from @ansible-community/steering-committee. To make 2 feasible, we need to limit the ways to do this down to a small set of choices (preferably a small number like 2 or 3). Right now we have:
Are there any other ideas? Like other names than |
Also please take a look at the internal filter showing up in the community.sops collection: https://docs.ansible.com/ansible/latest/collections/community/sops/#filter-plugins - the idea of this issue is to prevent things like that showing up in the public documentation. |
I'll reiterate that I'm against the underscore |
I like the option 2 |
There is an active vote on this topic - namely which way to use - in #204 CC @ansible-community/steering-committee |
We did talk more about this (mostly on 'whether we should', and less about 'how to do it') at today's community meeting (https://meetbot.fedoraproject.org/ansible-community/2023-03-01/ansible_community_meeting.2023-03-01-19.01.html). It was mentioned during the meeting that someone said that this "breaks the premise of auditability". Unfortunately the context of that statement isn't clear to us, but I would counter this with that ansible-doc should have an option which forces listing all plugins/modules, i.e. that the private ones are only not shown by default. It was also pointed out that other tools, such as galaxy/galaxy_ng, will likely stick to what ansible-doc shows, so their plugin listings will still list these plugins/modules even when the docsite does not. This was countered with the argument that it's better to at least have some tools/docsite which do not list the private plugins, instead of having them listed everywhere. When discussing how to do this, there were both proponents of filename marking (leading (Please look up the meeting log for more details on what exactly was discussed, if you want to know more.) |
The more I think about this, I'm +1 on the |
I am very happy that this was raised as I was aware of the issue since collections were introduced. Added ticket at https://issues.redhat.com/browse/AAP-9875 as decision on this would have a broader ecosystem impact, as devtools will need to recognize private modules and probably we would also need some minor changes in core, ansible-doc in particular. |
I think using the Python convention of marking modules private by starting the filename |
I'm copying @bcoca's comment (#204 (comment)) here since it is more an argument againts this feature (and not specific to the question how to implement it):
|
Regarding the vote #204 about how should private modules/plugins be marked, I'm counting: a) b) c) d) Can someone from the steering committee confirm these votes? |
i confirm the count by @felixfontein |
Not that it really matters, but for posterity, d) was the what core ended up recommending instead of ansible/ansible#79370, and as my comment came after bcoca's encompassing -1 he wasn't voting for or against it. The core team suggested b) instead of the original solution community chose (ansible/ansible#79218) only because we were considering potential runtime changes. Otherwise, the request would have been a new key or something in DOCUMENTATION (we wanted to avoid _). Hijacking the runtime metadata for external purposes... not great. |
There's kind of a broader theme that I'm noticing more and more: people want to augment core runtime-owned structures for non-core-runtime things. It's happening with the collections packaging mechanism as a whole, with collection metadata, and several other things. As the de-facto We're getting more requests around reusing collections to package and distribute content that's "foreign" to ansible-core, as well as things like this, where there's a desire to embed non-runtime metadata in critical runtime structures. Both issues are a double-edged sword for the core team; we don't want to say "this is ours, go build your own", but we have enough trouble maintaining and validating things internally with the proliferation of organically-grown tooling that's reliant on these structures (especially when they're tied to a particular core version, but need to validate content that spans core versions). I've been working on ways to retcon non-core extensibility into the collection directory structure in a future-friendly way. We don't want a constant stream of new "things to ignore" backports for core sanity tests, but ideally we'd also like to define some conventions to allow the collection loader and If
Thoughts? |
Hmm, having that extra data not in How about having a file
where every object can have namespaced keys (and that's the part I would like a linter to enforce), like every key having a prefix, followed by some defined symbol like (Yeah, XML handles this more nicely, since |
Either I understand the word auditability differently, or I don't really understand what's the problem here. The documentation of these 'hidden' plugins are still available, it just would require a little bit of knowledge to find them (with the proposed extra ansible-doc switch to list all plugins), and directly calling ansible-doc or using the docsite URL for the plugin also works. So it is very easy to find information about these plugins.
I disagree here, showing them in the default listing is IMO a really bad idea, but it should be easy to still list them (by an extra flag like I also diagree that preventing (or making it harder for) these plugins to be used outside the collection they are defined in is making it harder to audit a collection / some playbook. Especially this makes it easier, since you cannot use anything internal outside the collection. Or do you mean auditability of a collection itself? (In that case I don't understand how this is a problem either, since you are already looking at a collection's source and you can see that these plugins are there.) |
Clearly we have different dictionaries, by definition anything you do to hide part of the data to be audited goes against auditability. Imagine your tax auditor finds a few accounts in your ledger w/o visible description or information and you respond "don't worry, its in another set of books, we hide these accounts since they are internal and should not be readily seen". We will continue to disagree at any point that this makes core treat the plugins any differently. |
@felixfontein Please close this issue if done, or open a new forum topic and then close the issue with a pointer to the new discussion: Community-topics: Archiving the repo |
Summary
While working on community.sops EE support (ansible-collections/community.sops#98) I came around the need to have a 'private' filter plugin for a role in a collection. (Collection roles cannot have included plugins, as opposed to standalone roles, they have to be part of the collection itself. And thus are shown both by
ansible-doc --list --type filter
and show up on the collection's docsite plugin index.) There are various reasons for plugins in a collection to be private, and this topic isn't about discussing these, but about how this could be done :)My first idea was to have a documentation flag
private: true
to mark plugins as private, which could be used byansible-doc --list
(it showsshort_description
, so it looks at the documentation anyway), antsibull-docs, and other tools. Unfortunately this turned out to be more tricky than expected: ansible-doc uses some special code to quickly readshort_description
from plugins which is mainly working well because every plugin documentation hasshort_description
, and it usually shows up before the plugin's options. A similar trick won't work forprivate
, which would mean that eitheransible-doc --list
won't care about private plugins (and still show them), or that listing plugins becomes more inefficient (which has a very low chance of being merged IMO).Another idea is to classify plugins as private by their filename, or more precisely plugin name (the distinction is mainly important for test and filter plugins, where you have multiple plugins per file). The most obvious convention is using a underscore (
_
) prefix, as this is also the classic Python convention for marking something as private. Unfortunately, this convention is already partially used. Bothansible-doc --list
andansible-test sanity --test validate-modules
interpret the leading underscore as "this plugin is deprecated", and validate-modules interprets it the same way as whether the plugin would have been depecated inmeta/runtime.yml
. All other parts of ansible-core ignore this underscore, including looking at the plugin docs withansible-doc
will show no indication that the module is deprecated (if you don't add the regular deprecation information to the plugin's documentation as well).So my proposal would be:
ansible-doc --list
).What this discussion should be about:
The text was updated successfully, but these errors were encountered: