THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

Ansible lookup for a IPv4 network with specific extaddrs

Authority
Posts: 18
5518     0

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}'

Re: Ansible lookup for a IPv4 network with specific extaddrs

Adviser
Posts: 181
5519     0

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

Authority
Posts: 18
5519     0
This is the error. Look like something related to the extensible attribute.

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

Adviser
Posts: 181
5519     0

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 ]
New Member
Posts: 2
5519     0

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

Showing results for 
Search instead for 
Did you mean: 

Recommended for You