diff --git a/lib/ansible/plugins/lookup/nios.py b/lib/ansible/plugins/lookup/nios.py index 5236bef492..e545f25fb8 100644 --- a/lib/ansible/plugins/lookup/nios.py +++ b/lib/ansible/plugins/lookup/nios.py @@ -44,6 +44,10 @@ options: description: a dict object that is used to filter the return objects required: False default: null + extattrs: + descrpition: a dict object that is used to filter on extattrs + required: false + default: null """ EXAMPLES = """ @@ -93,6 +97,7 @@ obj_type: from ansible.plugins.lookup import LookupBase from ansible.module_utils.net_tools.nios.api import nios_provider_spec from ansible.module_utils.net_tools.nios.api import get_connector +from ansible.module_utils.net_tools.nios.api import normalize_extattrs, flatten_extattrs from ansible.errors import AnsibleError @@ -106,6 +111,11 @@ class LookupModule(LookupBase): return_fields = kwargs.pop('return_fields', None) filter_data = kwargs.pop('filter', {}) + extattrs = normalize_extattrs(kwargs.pop('extattrs', {})) provider = kwargs.pop('provider', {}) connector = get_connector(**provider) - return connector.get_object(obj_type, filter_data, return_fields=return_fields) + res = connector.get_object(obj_type, filter_data, return_fields=return_fields) + for obj in res: + if 'extattrs' in obj: + obj['extattrs'] = flatten_extattrs(obj['extattrs']) + return res