Skip to content
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

Update module default groups documentation #1893

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

mariolenz
Copy link
Contributor

Fixes #1759

It looks like default groups / action groups are stable. I think we should update the documentation accordingly, since it still says it's a preview feature.

I've also learned that that there is some magic happening for some special groups for reasons of downwards compatibility or whatever:

https://github.com/ansible/ansible/blob/b5ae8a382baca04442ad82e654ab6e35379844c3/lib/ansible/config/ansible_builtin_runtime.yml#L9685

I think we should document this also.

@felixfontein felixfontein added backport-2.16 Automatically create a backport for the stable-2.16 branch backport-2.17 Automatically create a backport for the stable-2.17 branch labels Sep 15, 2024
@mariolenz
Copy link
Contributor Author

Thanks for reviewing @felixfontein!

@mariolenz
Copy link
Contributor Author

@s-hertel Since you've answered my original question (#1759) I thought you might be interested in having a look at this PR.

@felixfontein
Copy link
Collaborator

One general thing I'm wondering about this documentation is: why is part of the syntax for collection development documented here? There's also a separate set of documentation for this feature in dev_guide/developing_collections_structure.rst, which also mentions the special metadata: entry:

- *action_groups*

  A mapping of groups and the list of action plugin and module names they contain. They may also have a special 'metadata' dictionary in the list, which can be used to include actions from other groups.

  .. code:: yaml

     action_groups:
       groupname:
         # The special metadata dictionary. All action/module names should be strings.
         - metadata:
             extend_group:
               - another.collection.groupname
               - another_group
         - my_action
       another_group:
         - my_module
         - another.collection.another_module

Maybe the meta/runtime part of the documentation here should be deleted, and the other documentation should be referenced instead?

(There's also essentially no validation of action_groups in the ansible-core sanity tests. They only make sure that action_groups is a dictionary if it's specified, but nothing else...)

@s-hertel
Copy link
Contributor

One general thing I'm wondering about this documentation is: why is part of the syntax for collection development documented here?

I added both in 74039. Linking to the other would be better, I think I just wanted to make sure it was mentioned both places.

Adding a good sanity test seems like it should be a prerequisite for documenting this as no longer preview. Fwiw, I made the runtime behavior for action_groups very forgiving, it's at most a warning, and there's a toggle to ignore invalid action_groups: https://github.com/ansible/ansible/blob/devel/lib/ansible/playbook/base.py#L33-L69.

Co-authored-by: Sloane Hertel <[email protected]>
@mariolenz
Copy link
Contributor Author

Yes, this is a little bit weird. I should say that this file should document how to use module defaults, but not how to implement them in a collection.


In ansible-core 2.12, collections can define their own groups in the ``meta/runtime.yml`` file. ``module_defaults`` does not take the ``collections`` keyword into account, so the fully qualified group name must be used for new groups in ``module_defaults``.
.. note::
``module_defaults`` does not take the ``collections`` keyword into account, so the fully qualified group name must be used for new groups in ``module_defaults``.

Here is an example ``runtime.yml`` file for the ``ns.coll`` collection.
This file defines an action group named ``ns.coll.my_group`` and places the ``sample_module`` from ``ns.coll`` and ``another_module`` from ``another.collection`` into the group.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the following (or something similar) after the code block below (I cannot add a comment there directly):

More information on meta/runtime.yml, including the complete format for `action_groups`, can be found in :ref:`meta_runtime_yml`.

Copy link
Contributor Author

@mariolenz mariolenz Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the following (or something similar) after the code block below (I cannot add a comment there directly):

More information on meta/runtime.yml, including the complete format for `action_groups`, can be found in :ref:`meta_runtime_yml`.

@felixfontein Like this?

@felixfontein
Copy link
Collaborator

Yes, this is a little bit weird. I should say that this file should document how to use module defaults, but not how to implement them in a collection.

I agree, though right now users often have to consult the implementation to find out which module default groups are available and which actions they cover. (You can document this with attributes for an individual module/action, but not every collection is doing that. And even that doesn't give you a list of all actions in an action group either, it only tells you for a specific action whether its in there. So being able to look at meta/runtime.yml right now is a necessary skill for users of action groups...)

@felixfontein
Copy link
Collaborator

I created a better validation test in ansible/ansible#83965.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-2.16 Automatically create a backport for the stable-2.16 branch backport-2.17 Automatically create a backport for the stable-2.17 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module defaults groups stable or not?
3 participants