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

Add action_group to enable module defaults groups #800

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

jensrudolf
Copy link
Contributor

Related Issue

#799

New Behavior

This enables support for the module defaults groups feature introduced in ansible-core 2.12. Using module defaults groups one can provide default values (e.g. token, url, etc.) for a group of modules instead of having to specify them for every used module. For more details see: https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html#module-defaults-groups

This commit adds all modules available in this collection to an action group called 'netbox'. This change is backwards compatible. Older versions of Ansible just ignore this.

Contrast to Current Behavior

Currently, user has to specify module defaults (e.g. url, token) for every module in use.

Discussion: Benefits and Drawbacks

This change potentially reduces the amount of boilerplate code using this collection as required parameters like e.g. url or token need to be provided once and can be specified in a central place.

Changes to the Documentation

Might add a hint to the documentation about the usage of this feature.

Proposed Release Note Entry

Support module defaults groups

Double Check

  • [ x] I have read the comments and followed the CONTRIBUTING.md.
  • [ x] I have explained my PR according to the information in the comments or in a linked issue.
  • [ x] My PR targets the devel branch.

@sc68cal
Copy link
Contributor

sc68cal commented Jun 15, 2022

This looks good, I'd just like to see the documentation that makes this work, since I am not familiar with it myself, and the quicker we update the docs for it, the quicker everyone stops putting the url and token in every netbox module call

This enables support for the module defaults groups feature introduced in ansible-core 2.12. Using module defaults groups one can provide default values (e.g. token, url, etc.) for a group of modules instead of having to specify them for every used module. For more details see: https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html#module-defaults-groups

This commit adds all modules available in this collection to an action group called 'netbox'. This change is backwards compatible. Older versions of Ansible just ignore this.
@jensrudolf
Copy link
Contributor Author

I added an example on how to use this in the advanced section of the docs.

@rodvand rodvand merged commit 8ef1932 into netbox-community:devel Jun 16, 2022
@sc68cal
Copy link
Contributor

sc68cal commented Jun 16, 2022

@jensrudolf awesome work, thank you for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants