BloxOne Ansible

Infoblox has an unofficial Ansible integration here.

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
// You need Ansible 2.10 or higher for the following command to work
ansible-galaxy collection install git+https://github.com/infobloxopen/bloxone-ansible#ansible_collections/infoblox/b1ddi_modules

You will need a service API key. BloxOne > Administration > User Access > Users > Create User (and make sure type is set to 'Service').

Then Create serivce API key using BloxOne > Administration > Service API Keys > Create

Copy the key and the following is an example Playbook

---
- hosts: localhost
  connection: local
  collections:
    - infoblox.b1ddi_modules

  vars:
  - host: "https://csp.infoblox.com"
  - api: "1111111111111111112222222222222222333333333333333444444444444444"
  - ipspace: "my-ip-space-name"
  - organisation: "value-of-a-tag-i-want-to-set"
  - country: "value-of-a-tag-i-want-to-set"
  - site: "value-of-a-tag-i-want-to-set"
  - oph: "name-of-oph"
  - productionsubnet: "172.26.0.0/24"
  - productiongateway: "172.26.0.1"
  - productionstart: "172.26.0.2"
  - productionend: "172.26.0.254"
  - productionvlan: "101"


  tasks:

    # ****************************************************
    - name: Create Production Subnet
      b1_ipam_subnet:
        space: "{{ ipspace }}"
        comment: "{{ site }} Production"
        api_key: "{{ api }}"
        host: "{{ host }}"
        state: present
        address: "{{ productionsubnet }}"
        dhcp_host: "{{ oph }}"
        dhcp_options:
          - routers: "{{ productiongateway }}"
        tags:
          - "VLAN": "{{ productionvlan }}"
          - "VLANType": "Production"
          - "Country": "{{ country }}"
          - "Organisation": "{{ organisation }}"
          - "Site": "{{ site }}"
          - "ViewedByAxonius": "True"

    - name: Create Production Range
      b1_ipam_range:
        space: "{{ ipspace }}"
        start: "{{ productionstart }}"
        end: "{{ productionend }}"
        api_key: "{{ api }}"
        host: "{{ host }}"
        state: present

Put the above into a file called create_ip_space and run with the following command.

ansible-playbook create_ip_space