interesting. My hybrid (custom) lookup_plugin:
def run(self, terms='', **kwargs):
'''Normalize terms and args and perform lookup.
Args:
terms (Optional[str,list]): Comma-delimited string (or python
list) of terms.
kwargs (**dict): See ``Store()`` object for details. All kwargs
are sent
when creating instance.
Caveats:
Ansible 2.0 sends all args as list::
"{{ lookup('myplug', ['key1', 'key2']) }}" ==> [['key1', 'key2
']]
"{{ lookup('myplug', 'key1', 'key2') }}" ==> ['key1', 'key2']
Ansible 1.9 sends first arg as list::
"{{ lookup('myplug', ['key1', 'key2']) }}" ==> ['key1', 'key2']
"{{ lookup('myplug', 'key1', 'key2') }}" ==> ERROR! Too many
args.
'''
## Normalize terms to be a list
if not isinstance(terms, list):
terms = terms.split()
## Ansible 2.0 sends all args as list
## Ansible 1.9 sends first arg as list
if len(terms) == 1 and isinstance(terms[0], list):
terms = terms[0]
...etc...
Now, I want to switch to use listify_lookup_plugin_terms!
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bc9e082a-80d0-4b92-b0ce-d7b8c7f35b68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.