-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
exclude lookup_terms from config errors #41740
Conversation
I can confirm at minimum that this resolves #41696 |
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.
I'm getting weird behavior for required options in lookups but it doesn't seem like it's due to this. Also doesn't appear that any plugins are broken by it at the moment.
diff --git a/lib/ansible/plugins/lookup/vars.py b/lib/ansible/plugins/lookup/vars.py
index 9ce5d30467..8119f110f1 100644
--- a/lib/ansible/plugins/lookup/vars.py
+++ b/lib/ansible/plugins/lookup/vars.py
@@ -18,6 +18,9 @@ DOCUMENTATION = """
description:
- What to return if a variable is undefined.
- If no default is set, it will result in an error if any of the variables is undefined.
+ test_req_options:
+ description: test required options
+ required: true
with or without the required option outputs
$ ansible -m debug -a msg="{{ lookup('vars', 'foobar', default='ok', test_req_options='test') }}" -c local localhost
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
localhost | FAILED! => {
"msg": "An unhandled exception occurred while running the lookup plugin 'vars'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Invalid settings supplied for test_req_options: No setting was provided for required configuration plugin_type: lookup plugin: vars setting: test_req_options "
}
(Actually, looks like on devel required: True just might be ignored for lookup plugins right now?)
lib/ansible/config/manager.py
Outdated
@@ -365,7 +366,8 @@ def get_config_value_and_origin(self, config, cfile=None, plugin_type=None, plug | |||
if plugin_name: | |||
entry += 'plugin: %s ' % plugin_name | |||
entry += 'setting: %s ' % config | |||
raise AnsibleError("No setting was provided for required configuration %s" % (entry)) | |||
if not plugin_type or config not in INTERNAL_DEFS.get(plugin_type): |
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.
INTERNAL_DEFS.get(plugin_type, ()) since Nonetype isn't iterable
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.
i don't get that error, weird since it is defined on top in same file .... and plugin_type is not used if None
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.
I got that error using an inventory plugin, not a lookup.
the other behaviour is because of how i pass 'direct' ... its a bug |
try now, that should fix 'direct processing' |
lib/ansible/config/manager.py
Outdated
if plugin_name: | ||
entry += 'plugin: %s ' % plugin_name | ||
entry += 'setting: %s ' % config | ||
if not plugin_type or config not in INTERNAL_DEFS.get(plugin_type): |
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.
Causes unhelpful error if get() returns None
$ cat nmap_inv.yml
plugin: nmap
$ ansible-inventory -i nmap_inv.yml --graph
ERROR! Invalid settings supplied for address: argument of type 'NoneType' is not iterable
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.
ah, misunderstood your prev comment
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.
pushing fix, good catch
Looks good to me, shipit |
* exclude lookup_terms from config errors * moved direct (cherry picked from commit 0102e42)
* exclude lookup_terms from config errors * moved direct (cherry picked from commit 0102e42)
* exclude lookup_terms from config errors * moved direct
* exclude lookup_terms from config errors * moved direct (cherry picked from commit 0102e42)
SUMMARY
ISSUE TYPE
COMPONENT NAME
config
plugins/lookup
ANSIBLE VERSION