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

Lookup for Next Available Network

Authority
Posts: 18
5041     0

I need to create a lookup for the next available network from a group of four possible aggregate blocks.  For example I have four different /24 subnets that I want to lookup and find the next available /28 I can then create.  The /28 can be from any of the 4 networks.  

 

vars:

  networks:

   - 10.0.0.0/24 

   - 10.0.1.0/24

   - 10.0.2.0/24

   - 10.0.3.0/24

 

    - name: Return the next available trans_lan IP subnet for network
      set_fact:
         trans_lan: "{{ lookup('nios_next_network', networks, cidr=28, provider=cli_infoblox ) }}"
 
I need it to lookup in 10.0.0.0/24 and if it doesn't find anything then lookup in 10.0.1.0/24 and continue through the list of subnets until it finds 1 available /28.

Re: Lookup for Next Available Network

[ Edited ]
Superuser
Posts: 115
5041     0

Without looking at anything else, trying looping through the 0-255?

 

0 - 255

10.0.x.0/24

 

 

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com

Re: Lookup for Next Available Network

Authority
Posts: 18
5041     0
I’m not sure I follow. Can you provide an example?

Get Outlook for iOS
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: Lookup for Next Available Network

[ Edited ]
Authority
Posts: 18
5041     0

This is what I tried and I'm getting three networks from each subnet but I'm getting an error.

 

    - name: New Tran_Lan network
      set_fact:
         trans_lan0: "{{ lookup('nios_next_network', '206.201.%02d.0/24' | format(item), cidr=28, num=1, provider=cli_infoblox ) }}"
      loop: "{{ range(70, 73 + 1, 1)|list }}"
 
Here's the error:
 
TASK [New Tran_Lan network] ******************************************************************************************************************************
task path: /automation/ansible/gitlab/infoblox_ip_clt_rem/infoblox_rem_client.yml:98
ok: [10.x.x.22] => (item=70) => {
    "ansible_facts": {
        "trans_lan0": [
            "206.201.70.0/28"
        ]
    },
    "ansible_loop_var": "item",
    "changed": false,
    "item": 70
}
ok: [10.x.x.22] => (item=71) => {
    "ansible_facts": {
        "trans_lan0": [
            "206.201.71.64/28"
        ]
    },
    "ansible_loop_var": "item",
    "changed": false,
    "item": 71
}
ok: [10.x.x.22] => (item=72) => {
    "ansible_facts": {
        "trans_lan0": [
            "206.201.72.32/28"
        ]
    },
    "ansible_loop_var": "item",
    "changed": false,
    "item": 72
}
fatal: [10.x.x.22]: FAILED! => {
    "msg": "An unhandled exception occurred while running the lookup plugin 'nios_next_network'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Can not find requested number of networks"

Re: Lookup for Next Available Network

Adviser
Posts: 181
5042     0

Hi,

 

Is this because the last network in the loop has no free /28 blocks to give out?

You could probably try adding the ignore_errors flag as part of your play.

You can find more information about it here. This is not recommended in production though. You might miss out on actuall error scenarios.

 

Regards,

Krishna

Re: Lookup for Next Available Network

Authority
Posts: 18
5042     0
The lat network in the loop is 206.201.72.0/24 and from the output you can see that it finds an available network. I do plan to use this for production so I don’t want to ignore the error. It there another way to perform the lookup on multiple subnet?

Re: Lookup for Next Available Network

Authority
Posts: 18
5042     0
Sorry I checked my playbook again and you were correct. I had the range from 70 - 73 and it should have been 70 - 72. I changed it and it’s working now.
Showing results for 
Search instead for 
Did you mean: 

Recommended for You