Ansible - Getting next IP from range : Error "Network View Default Not Found"

I've started a playbook that checks if a host is already in infoblox, and if not, it should add it. The checking is working fine, correctly giving an IP if its there, and nothing if it is not. The issue I am having is getting the next available ip.

 - name: set host record if it isn't there
nios_host_record:
name: test-ansible.scsu.southernct.edu
ipv4addrs:
- ipv4addr:
"{{ lookup('nios_next_ip', '10.64.33.0/24',provider=nios_provider)[0] }}"
state: present
provider: "{{nios_provider}}"

The playbook error is this

fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'nios_next_ip'. Error was a <class 'infoblox_client.exceptions.InfobloxConnectionError'>, original message: Infoblox HTTP request failed with: 404 Client Error: Not Found for url: https://infoblox.XXXXX/wapi/v2.13.4/network?network=10.64.33.0%2F24&network_view=default&_max_results=1000&_proxy_search=GM. Infoblox HTTP request failed with: 404 Client Error: Not Found for url: https://infoblox.XXXXXX/wapi/v2.13.4/network?network=10.64.33.0%2F24&network_view=default&_max_results=1000&_proxy_search=GM"}

If I go directly to that URL and log in, I am greeted with this JSON

{ "Error": "AdmConDataNotFoundError: Network View default not found",  "code": "Client.Ibap.Data.NotFound",  "text": "Network View default not found"}

I am not sure if this is a problem with my ansible code, or a problem with Infoblox configuration at this point. Since the searching of infoblox is working, I don't suspect is a major ansible issue, but why doesn't that code work? It is basically the code from the ansible.com community documentation. https://docs.ansible.com/ansible/8/scenario_guides/guide_infoblox.html

Thank you.

Tagged:

Answers

  • The error you're encountering — 

    "Network View default not found"

     This is most likely due to a mismatch between the network view as you're not specifying any network view in your Ansible playbook and By default, this lookup assumes the network view is "default"




    How to Fix this.

    1. Find the Correct Network View
      Either check directly in the Infoblox UI under Administration → Network Views
      Or You can use the nios_network_viewmodule to list or verify available network views:

    - name: Get network views

      infoblox.nios_modules.nios_network_view:

        provider: "{{ nios_provider }}"

        state: gather_facts

    2. Update Your Lookup to Use the Correct View
    Once you know the correct network view (e.g., "Internal" or "Corporate"), update your lookup like this

    ipv4addr: "{{ lookup('nios_next_ip', '10.64.33.0/24', network_view='Internal', provider=nios_provider)[0] }}"