Ansible Automation Infoblox

Infoblox and Ansible Updating a CNAME via Playbook

A

Anonymous

3 min read
Share:

A good friend of mine asked me the other day, “How does one update a CNAME in Infoblox using an Ansible Playbook.” I told him to use the URI if it’s not available in the module, so he went looking on Google and didn’t come across a good example. So I decided to write this quick post on “How To” use Ansible Playbook first to make a URI call to “GET” data and then take the “Response” and “Update” via another URI call.

We are going to update “bobhome.ansible.com” in my zone using the following API calls:

  • /wapi/v2.7/record:cname?name=bobhope.ansible.com

  • We will Search for “bobhope.ansible.com” with the above “GET” command

  • /wapi/v2.7/record:cname/ZG5zLmJpbmRfY25hbWUkLl9kZWZhdWx0LmNvbS5hbnNpYmxlLmRlbW8uY25hbWU:cname.demo.ansible.com/default

  • We will pass in the body {“name”:”bobhope.ansible.com”} using a “PUT” command

---
- hosts: localhost
  connection: local
  tasks:
 
  - name: Get the next available network from 10.1.0.0/16
    uri:
      url: "https://192.168.0.200/wapi/v2.7/record:cname?name=bobhope.ansible.com"
      method: GET
      user: admin
      password: infoblox
      status_code: 201, 302, 200
      headers:
          Content-Type: "application/json"
      body_format: json
      validate_certs: no
      return_content: yes
    register: data
 
  - name: CNAME _ref
    debug:
      var: data.json[0]._ref
 
  - name: Update CNAME
    uri:
      url: "https://192.168.0.200/wapi/v2.7/{{ data.json[0]._ref }}"
      method: PUT
      user: admin
      password: infoblox
      status_code: 201, 302, 200
      headers:
          Content-Type: "application/json"
      body:
        name: "bobhopelives.ansible.com"
      validate_certs: no

Let’s run the “playbook” and take a look at the results:

As you can see the CNAME is updated via Ansible URI Module playbook

Let me know if you found this useful and any others you would like to see in the comments below.

  • Author Details

      		![](https://i0.wp.com/sifbaksh.com/wp-content/uploads/2020/04/sifbaksh.png?w=200&ssl=1)
      			
    
    
      
      [Sif Baksh](https://sifbaksh.com/author/sifbaksh/)
      
      Administrator	
      	
      	
      		Principal Solutions Architect			 		
      

    As Principal Solutions Architect, Sif Baksh is responsible for the design of large-scale Core Services and Security systems. With 25 years of engineering experience in the computer and communications industry, Sif brings a depth of understanding of complex solutions for large and small organizations.

      						web
      							
      			[https://sifbaksh.com](https://sifbaksh.com)
      		
      		
      					
      
      
      
      			
      	email
      			
      	[sifbaksh@gmail.com](mailto:sifbaksh@gmail.com)
      
    
    
      				follow me
      			
  • **

  • **

  • **

  • **

  • **

Comments

Related Posts

Automating IOC Management with Tines + Infoblox Threat Defense

If you’ve ever had to manually wrangle external threat intel feeds — CSVs, JSON dumps, or raw text files full of Indicators of Compromise — you know it’s a pain. Some sources send you neat JSON, others hand you a 2 MB CSV. Then you’ve got to clean it

Automation Infoblox

My Journey into Automation: From Postman to Curl and Beyond

Introduction: The Beginning of Automation Today, I want to take you on a journey that started with curiosity and has become an essential part of my daily workflow. I’m talking about the fascinating world of automation. If you’ve ever need

Automation python