- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Ansible lookup for a IPv4 network with specific extaddrs
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2021 12:12 PM
I have worked with the lookup plugin and I'm able to run through several scenarios using the record: host but I need to lookup a network based on an extaddrs. I tried this...
- name: Extattr lookup
set_fact:
host_records: "{{ lookup('nios', 'search', filter={'network': '10.x.x.36/30'}, return_fields=['extattrs', 'Client_Site_#'], provider=cli_infoblox ) }}"
Here's the error:
Failed on object search with url https://10.x.x.x/wapi/v2.1/search?network=10.x.x.36%2F30&_return_fields=extattrs%2CClient_Site_%23&_...: b'{ "Error": "AdmConProtoError: _return_fields illegal for search", \n "code": "Client.Ibap.Proto", \n "text": "_return_fields illegal for search"\n}'
Solved! Go to Solution.
Re: Ansible lookup for a IPv4 network with specific extaddrs
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2021 07:06 AM
Hi,
Can you try this following lookup instead:
host_records: "{{ lookup('nios', 'network', filter={'network': '10.x.x.36/30'}, return_fields=['extattrs', 'Client_Site_#'], provider=cli_infoblox ) }}"
Regards,
Krishna
Re: Ansible lookup for a IPv4 network with specific extaddrs
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2021 07:52 AM
Failed on object search with url https://10.x.x.22/wapi/v2.1/network?network=10.x.x.40%2F30&_return_fields=extattrs%2CClient_Site_%23...: b'{ "Error": "AdmConProtoError: Unknown argument/field: \'Client_Site_#\'", \n "code": "Client.Ibap.Proto", \n "text": "Unknown argument/field: \'Client_Site_#\'"\n}'
Upcoming Vacation/Training:
Sharon Day
Network Architect
HOPS - Network Engineering and Architecture
(904) 854-3477 - Work
(904) 210-1677 - Mobile
Sharon.Day@bkfs.com
601 Riverside Avenue
Jacksonville, FL 32204
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
Re: Ansible lookup for a IPv4 network with specific extaddrs
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2021 10:35 AM
Hi,
I get it now. So, if you just need to return the extensible attributes, then you can run the following command:
host_records: "{{ lookup('nios', 'network', filter={'network': '10.x.x.36/30'}, return_fields=['extattrs'], provider=cli_infoblox ) }}"
If you need to filter by a specif extensible attribute, then you can use the following command:
host_records: "{{ lookup('nios', 'network', filter={'network': '10.x.x.36/30','*Client_Site_#':'<replace_with your client side ID>'}, return_fields=['extattrs'], provider=cli_infoblox ) }}"
Let me know how this goes,
Regards,
Krishna
Re: Ansible lookup for a IPv4 network with specific extaddrs
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 07:22 AM - edited 04-11-2024 07:25 AM
In terms of regex lookups with Ansible lookup plugin
add ~ suffix to the field while using filter:
- name: fetch networks by regex starting with 10.231 set_fact: networks: "{{ lookup('nios', 'network', filter={'network~': '10.231'}, return_fields=['network','ipv4addr'], provider=nios_provider) }}" - name: print out the networks debug: var: networks
https://infoblox-client.readthedocs.io/en/stable/readme.html#search-by-regular-expression