-
Notifications
You must be signed in to change notification settings - Fork 292
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
module_defaults group for zabbix modules #326
Comments
This unfortunately never made it into the ansible as a feature. So it is not possible yet |
@D3DeFi Maybe it's a good idea to reopen this once since it's available from version 2.12?
Ref: https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html |
Yees, but! :) We are migrating away from zabbix-api into httpapi. With 1.9 this would be released as opt-in, with 2.0 zabbix-api will be dropped altogether. I am not sure that defining @BGmot can you share your opinion here when you have a little bit of time to spare please? |
I am not sure I understand the request. |
Normally, you have to specify module_defaults per module: module_defaults:
community.zabbix.zabbix_host:
server_url: ...
login_user: ...
login_pass: ...
community.zabbix.zabbix_groupt:
server_url: ...
login_user: ...
login_pass: ... But implementing this in collections runtime.yml would allow users to provide: module_defaults:
group/zabbix:
server_url: http://zabbix
login_user: Admin
timeout: 15 and it would be inherited by all modules in the collection. However, I am not sure if we still have need for this as login credentials will be set only once for httpapi if I understand it correctly, so they don't have to be repeated for each module as it was with zabbix-api. Except Anyway, as I am looking at it. This only requires keeping list of modules in runtime.yml from our side, I think we should implement it: # collections/ansible_collections/ns/coll/meta/runtime.yml
action_groups:
groupname:
- module
- another.collection.module Re-opening the issue. |
How is it different from modules parameters defaults? |
This is amazing! I come to the same conclusion when I read the documentation for the httpapi connection plugin.
Thanks a lot, appreciate it! |
We have 20+ modules, lets ignore httpapi for a moment and pretend that we will be using 15 modules in our playbook, each multiple times. We know that there will be lot of code duplicity due to - hosts: all
module_defaults:
community.zabbix.zabbix_host:
server_url: ...
login_user: ...
login_pass: ...
community.zabbix.zabbix_group:
server_url: ...
login_user: ...
login_pass: ...
community.zabbix.zabbix_action:
server_url: ...
login_user: ...
login_pass: ...
community.zabbix.zabbix_service:
server_url: ...
login_user: ...
login_pass: ...
... and so on for each module ...
tasks:
... Now, with group - hosts: all
module_defaults:
group/community.zabbix.zabbix:
server_url: ...
login_user: ...
login_pass: ...
tasks:
... That's it. Now back to the httpapi - I know it will deprecate some of the stuff, instead of specifying This small example also comes to my mind: # roles/myrole/tasks/setup-zabbix-resources.yml
module_defaults:
group/community.zabbix.zabbix:
state: present
- set_fact:
...httpapi parameters...
- zabbix_host:
...
- zabbix_group:
... |
Thank you very much for explanation, now I get it and sure we need this "feature". |
@ansiballZ would you have any chance to test my proposed changes in #833? |
Sure thing, happy to help! EDIT: I saw the discussion in the PR and my testing is only done with I really appreciate this implementation. Thank you very much! |
SUMMARY
It should be now possible for collections to somehow define module_defaults for groups. E.g.:
ISSUE TYPE
COMPONENT NAME
plugins/
ADDITIONAL INFORMATION
Additional reference:
ansible/ansible#69919
ansible/ansible#67291
The text was updated successfully, but these errors were encountered: