Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

Automation Scripts

Reply

ANSIBLE network_container already exist

Techie
Posts: 3
252     0

Hello.

 

I try to configure new containers in my IB grid from an ansible playbook with the following task

 

 

  #################################
  ##### CREATE ALL CONTAINERS #####
  #################################
  - name: ===> Create/Delete ALL CONTAINERS
    infoblox.nios_modules.nios_network:
      provider: "{{ nios_provider }}"
      state: "present"
      #--------------------------------#
      network: "10.22.0.0/16"
      comment: "network 10.22"
      container: true
      #--------------------------------#
    connection: local
    ignore_errors: yes
  #################################

All th contaziners are created the first tie I run the aansible-playbook, that is good.

 

But when I run again the playbook (withjout any modification) I have  the following error from each item.

 

fatal: [myGRID]: FAILED! => {"changed": false, "code": "Client.Ibap.Data.Conflict", "msg": "Duplicate object '10.22.0.0' of type 'network_container' already exists in the database.", "operation": "create_object", "type": "AdmConDataError"}

And I have the same behavior with 'network' object (OK the first time and fails time after)

I can not find where is the error.

 

Any idea ?

 

Note : I have temp_licences on a vNIOS (VMware VM)

Thx

Re: ANSIBLE network_container already exist

Superuser
Posts: 25
253     0

Hello,

 

When you run the playbook for the first time it runs as expected and creates the network/network container with the network configurations that you have mentioned.

When you run the same playbook again (without any modifications), it runs the same task again where it tries to create same objects again in NIOS and as you see in the error message it mentions that it is a duplicate object and it already exists.

 

So you can either update the configuration in the playbook before running it again or if you want to run the same playbook (to create the same objects again) you need to delete the existing ones first.

 

Below is a snippet for deleting the network object

tasks:
   - name: delete network
     infoblox.nios_modules.nios_network:
       network: 10.0.0.0/24
       network_view: default
       state: absent
       provider: "{{ nios_provider }}"

   - name: delete network container
     infoblox.nios_modules.nios_network:
       network: 10.0.0.0/8
       network_view: default
       state: absent
       provider: "{{ nios_provider }}"

You can refer the given link for a better understanding of Infoblox NIOS module for Ansible

 

Thanks,

Shukran

Shukran

Re: ANSIBLE network_container already exist

Techie
Posts: 3
253     0

Thanks Shukran

 

If I delete network/network container, it will remove all the included configuration (host objects DHCP ranges and so on). It is something that I have to avoid.

Is there a way to update an object whith no suppression step ?

Thanks again.

Vincent

Re: ANSIBLE network_container already exist

Superuser
Posts: 25
253     0

Hi Vincent,

 

Okay, could you let me know why are you trying to run the same playbook again? Is is to update the object?

The playbook that you have creates the object. You may have to modify it if you want to update it, right now you are trying to create a duplicate object that's why it fails.

 

Shukran

Shukran

Re: ANSIBLE network_container already exist

[ Edited ]
Techie
Posts: 3
253     0

Hi Shukran

 

Yes the point is that I want to update the object if it has been created previsouly. My goal is to be sure that the objects are configured as defined in my source of Truth. A scheduled job should be used to do that.

And I really do not want to delete before recreate.

Thanks again.

Vincent

Showing results for 
Search instead for 
Did you mean: 

Recommended for You