-
Notifications
You must be signed in to change notification settings - Fork 56
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
Feature: Introduce var env and ini variables in lookup plugins #546
Feature: Introduce var env and ini variables in lookup plugins #546
Conversation
@msekania just some quick (and somewhat lazy questions): Could one implement this as easily for the modules and maybe even for roles? I am asking, because I did not do any research yet, but playing around with it did not lead to success. |
To be honest, I haven't seen any implementation for modules or roles with this type functionality, but for lookup plugins, most lookup plugins in the Ansible collection have vars, ini and env included. |
@msekania that makes sense. I could not find anything on a quick search as well. So I think we are good here. The integration test failures I do understand, so they are not a blocker (I think). I want to test this a bit more and maybe do a little formatting, but from a code point of view everything should be in order. So I will line this up for the next release. Thanks! |
OMG, I didn't know that it's possible to get rid of these nasty repeatedly appearing parameters. They annoyed me a lot when doing the lookup modules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works fine. I tested the version lookup plugin with environment variables, ansible.ini and with local variables:
- name: "Get CMK version. Use local variables."
vars:
ansible_lookup_checkmk_server_url: http://klapplg/
ansible_lookup_checkmk_site: klapplg
ansible_lookup_checkmk_validate_certs: False
ansible_lookup_checkmk_automation_user: automation
ansible_lookup_checkmk_automation_secret: 3f87273f-98f0-4e39-92e4-02eacd8e538a
debug:
msg: "Server version is {{ lookup('checkmk.general.version')}}"
run_once: True
All three worked fine!
Introduce var env and ini variables in plugins.
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
one cannot specify variable like server_url and site "globally"
What is the new behavior?
One can specify variable like server_url and site "globally", either in
Examples:
1: in shell
2: or in ansible.cfg
Then lookup can be done as follows (example form folder lookup plugin)
Another example:
Other information
One can also define only subset of variables and at different places, e.g., some in ansible.cfg, some in console or in bashrc ...