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

nios_host_record fails to populate on the first loop

[ Edited ]
Authority
Posts: 18
2983     0

I have a playbook that creates two network, looks up the next 2 available IP addresses from each network and then assigns the host record using the nios_host_record module via a loop off the lookup results. So in the end I should have two hosts in both new networks. My issue is that the playbook runs fine it creates the networks it assigns the IPs at least according to the ansible and the Infoblox audit log but when I look at the IPs assigned in the networks there is only one IP addresses assigned in the first network and its the second IP in the subnet but both IP address are assigned in the second network. The debug output in Ansible shows the correct IPs to assign out of the /30 and I see the created statements in the Infoblox audit log.  If I run the same playbook again the IPs are assigned correctly in both networks and I see them listed in the network as host assignments.  Its only the first time it runs that it fails to populate the first available IP in the first network. 

 

I did a search for the IP address I know should have been assigned just in case it was populated somewhere else in the database and the IP was not found. 

I running Ansible 2.10, python 3.6.12, collection infoblox.nios_modules 1.0.2 and Infoblox is running 8.4.8

Re: nios_host_record fails to populate on the first loop

Adviser
Posts: 181
2984     0

Hi,

 

Could you please share the playbook you are using? That would be help debug the issue.

 

Regards,

Krishna

Re: nios_host_record fails to populate on the first loop

Authority
Posts: 18
2984     0

I'm creating two network and assigning 2 IP addresses out of each one.  

 

 

vars:

client_num: 81_2
client_name: client1
city: Seattle
state: WA
verizon: 10.x.x.0/20
century: 10.x.x.0/20

collections:
- infoblox.nios_modules

tasks:

- name: Obtain Creds
include_vars: "/etc/ansible/group_vars/e092-creds.yml"
no_log: true

- 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 ) }}"

- name: Return the next available Verizon IP subnet for network
set_fact:
verizon_pe_ce: "{{ lookup('nios_next_network', '10.x.x.0/20', cidr=30, exclude=['10.x.x.0/30', '10.x.x.4/30', '10.x.x.36/30'], provider=cli_infoblox ) }}"

- name: Print the subnet
debug:
var: verizon_pe_ce

- name: Return the next available at_t IP subnet for network
set_fact:
century_pe_ce: "{{ lookup('nios_next_network', century, cidr=30, exclude=['10.x.x.0/30', '10.x.x.4/30'], provider=cli_infoblox ) }}"
- name: Print the subnet
debug:
var: century_pe_ce

- name: configure a network ipv4
nios_network:
network: "{{ item }}"
comment: WAN ansible assignment
extattrs:
Network_Name: ansible_test_assignment
Network_Environment: CLIENT_REMOTE
Client_Site_#: "{{ client_num }}-{{ client_name }} - ({{ city }}, {{ state }})"
CL_RTR_INT: [ "Router A", "WAN Network _30" ]
VRF_NAME: CL
Network_Container: NG
state: present
provider: "{{ cli_infoblox }}"
loop:
- '{{ verizon_pe_ce[0] }}'
- '{{ century_pe_ce[0] }}'
delegate_to: localhost


- name: "Return next available IP address for network {{ verizon_pe_ce[0] }}"
set_fact:
verizon_ipaddr: "{{ lookup('nios_next_ip', verizon_pe_ce[0], num=1, provider=cli_infoblox ) }}"

- name: show output
debug:
var: verizon_ipaddr

 

- name: "Return next available IP address for network {{ century_pe_ce[0] }}"
set_fact:
century_ipaddr: "{{ lookup('nios_next_ip', century_pe_ce[0], num=1, provider=cli_infoblox ) }}"

- name: show output
debug:
var: century_ipaddr

 

- name: dynamically add host record to next available ip
infoblox.nios_modules.nios_host_record:
name: host.ansible
dns: false
ipv4:
- address: "{{ item }}"
comment: this is a test comment
extattrs:
Application_ID: 22222
Client_Site_#: "{{ client_num }}-{{ client_name }} - ({{ city }}, {{ state }})"
CL_RTR_INT: [ "Router A", "PE IP Address" ]
state: present
provider: "{{ cli_infoblox }}"
loop:
- '{{ verizon_ipaddr[0] }}'
- '{{ century_ipaddr[0] }}'
delegate_to: localhost

Showing results for 
Search instead for 
Did you mean: 

Recommended for You