Select Page

Why Infoblox and Ansible

Infoblox delivers actionable network intelligence to enterprise, government, and service provider customers around the world, as the industry leader in DNS, DHCP, and IP address management (known as DDI). Ansible is one of the leaders in IT Automation.

Summary

Over the upcoming weeks, I’ll be posting more about getting started with Ansible and Infoblox. I’ve had quite a few folks reached out to me asking for additional information around this integration, so I decided to do a series of blog posts around this.
I myself am a beginner to Ansible, so please forgive my novice examples.

What I’m using:

  • Ubuntu Linux running version 20.04
  • Python3
  • Ansible
  • Infoblox VM/Appliance

Installation

sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible

Now, let’s check that Ansible is installed and running with Python 3:

$ ansible --version
ansible 2.9.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sbaksh/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.6 (default, Jan 16 2020, 18:23:42) [GCC 9.2.1 20200110]

Next, we will need the Infoblox-Client for Python 3, which is what Ansible uses to connect to your IB Grid via API:

sudo apt install python3-pip
pip3 install infoblox-client

If you are running Python 2, and I’m not sure why you still are :), ignore the above and run the following:

sudo apt install python-pip
pip install infoblox-client

Now, let’s create our first playbook

In your home directory, create a folder called ansible. Open your favorite editor in Ubuntu and create a file name “get_members.yml” and save it in the ansible folder.

---
- name: Infoblox get all Members
  hosts: localhost
  vars:
    nios_provider:
      host: gm.baksh.com
      username: admin
      password: infoblox
      wapi_version: 2.6.1
  connection: local


  tasks:
    - name: fetch all members
      set_fact:
        member: "{{ lookup('nios', 'member', provider=nios_provider) }}"

    - name: check the member
      debug:
        var: member
I added this drawing due to a copy and paste error from here to my test subject (Scott F), so make sure your file matches all the spaces.

[et_bloom_inline optin_id=”optin_2″]

Let’s see the results:

sbaksh@ubuntu:~$ ansible-playbook get_members.yml 

PLAY [baksh get all Members] ***************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************
ok: [localhost]

TASK [fetch all members] **********************************************************************************************************
ok: [localhost]

TASK [check the member] ***********************************************************************************************************
ok: [localhost] => {
    "member": [
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQw:gm.baksh.com",
            "config_addr_type": "BOTH",
            "host_name": "gm.baksh.com",
            "platform": "baksh",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQz:m1.baksh.com",
            "config_addr_type": "BOTH",
            "host_name": "m1.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ0:m2.baksh.com",
            "config_addr_type": "BOTH",
            "host_name": "m2.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ3:m3.baksh.com",
            "config_addr_type": "IPV4",
            "host_name": "m3.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQxMg:rpt.baksh.com",
            "config_addr_type": "IPV4",
            "host_name": "rpt.baksh.com",
            "platform": "baksh",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQzMQ:pt1400.baksh.com",
            "config_addr_type": "IPV4",
            "host_name": "pt1400.baksh.com",
            "platform": "baksh",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQzMg:gm1nicons.baksh.com",
            "config_addr_type": "IPV4",
            "host_name": "gm1nicons.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQzMw:gm1p1.baksh.com",
            "config_addr_type": "IPV4",
            "host_name": "gm1p1.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQzNA:gm1p2.baksh.com",
            "config_addr_type": "IPV4",
            "host_name": "gm1p2.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQzNQ:gm1p3.baksh.com",
            "config_addr_type": "IPV4",
            "host_name": "gm1p3.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ0Ng:gmc.baksh.com",
            "config_addr_type": "BOTH",
            "host_name": "gmc.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ1NA:tempgmc.baksh.com",
            "config_addr_type": "BOTH",
            "host_name": "tempgmc.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        },
        {
            "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ1NQ:tempgmc2.baksh.com",
            "config_addr_type": "BOTH",
            "host_name": "tempgmc2.baksh.com",
            "platform": "VNIOS",
            "service_type_configuration": "ALL_V4"
        }
    ]
}

PLAY RECAP ************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

This will give you all of the members connected to your grid. The next steps will be to configure the Ubuntu host to use the /etc/ansible/hosts file and some other variables.

A future blog post will cover using lookups, next_ip, next_network, etc. Also, please comment on additional topics that you want to see demonstrated/explained.

Files are located here: GitHub

Next post in this series: Infoblox and Ansible Getting to know Lookup

Sif Baksh 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.
follow me