Adding host records to Infoblox with Ansible

Entering tens or hundreds of DNS entries in Infoblox from the GUI is a slow process. Previously, I used the IBCLI which is showing its age. I am concerned future updates may make it obsolete at some point.

A more modern approach is a configuration tool like Ansible or the restAPI.

The following playbook has an array of key/value pairs which contain hostname and IP information for the host_record task. It is much easier to update a text file with the basic key/value pairs then clicking several times for each host record in the GUI.

Ansible playbook:

- hosts: localhost
  connection: local
      username: jemurray
      password: "your-password"
      - { host_name:, ipaddr: }
      - { host_name:, ipaddr: }
      - { host_name:, ipaddr: }

    - name: Create host record
        name: "{{ item.host_name }}"
          - ipv4addr: "{{ item.ipaddr }}"
        state: present
        provider: "{{ local_nios_provider }}"
      loop: "{{ host_records }}"

Running the playbook:

(.venv) jemurray@mbp-2019:~/Documents/src/ansible/tasks/infoblox $ ansible-playbook ./add-host-record.yaml

PLAY [localhost] **********************************************************************************************************************************************************************

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

TASK [Create host record] *************************************************************************************************************************************************************
changed: [localhost] => (item={'host_name': '', 'ipaddr': ''})
changed: [localhost] => (item={'host_name': '', 'ipaddr': ''})

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