THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

Ansible Playbook for BloxOne Cloud

New Member
Posts: 3
3264     0

Hello All,

 

I am a newbie to Bloxone environmemt. I need to write an Ansible Playbook to configure DHCP scopes in BloxOne. I am facing some issue get Ansible work with BloxOne.

 

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

  tasks:
    #  Test
    - name: Test
      b1_ipam_ip_space_gather:
        host: "csp.infoblox.com"
        api_key: "xxxxxxxx"
        state: gather
      register: ip_spaces_id
   

This is a test playbook that I am using and it errors out when I run it.

 

user @@ ~/user$ ansible-playbook bloxone.yml     
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Executing playbook bloxone.yml

- localhost on hosts: localhost -
Gather Address block...
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Exception: /api/ddi/v1/ipam/ip_space
  localhost failed | msg: MODULE FAILURE
See stdout/stderr for the exact error

- Play recap -
  localhost                  : ok=0    changed=0    unreachable=0    failed=1    rescued=0    ignored=0   

Can anyone please help me to figured out the issue here?

Re: Ansible Playbook for BloxOne Cloud

New Member
Posts: 3
3264     0

Any help would be appreciated!

Re: Ansible Playbook for BloxOne Cloud

Superuser
Posts: 38
3264     0

Hey,

 

The reason you may be getting this error is because you have mentioned the host as 'csp.infoblox.com'. You can try and change it to 'https://csp.infoblox.com' and try running it.

 

You can also modify the below script as per your needs to create Subnets and Ranges in an IP Space

 

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

  vars:
  - host: "https://csp.infoblox.com"
  - api: "xxxxxx"

  tasks:
    #  Create a given IP space
    - name: Create IP space
      b1_ipam_ip_space:
        name: "Test-Ansible-Space"
        tags:
          - "Org": "Infoblox"
          - "Dept": "TME"
        comment: "This is a test IPSpace"
        host: "{{ host }}"
        api_key: "{{ api }}"
        state: present

    #  Create a Subnet in a given IP space
    - name: Create Subnet in a given IP Space
      b1_ipam_subnet:
        space: "Test-Ansible-Space"
        address: '172.16.0.0/24'
        name: "Test-Ansible-Subnet1"
        comment: "This is the test subnet"
        api_key: "{{ api }}"
        host: "{{ host }}"
        state: present

    #  Create a Range in a given subnet
    - name: Create Range in a given IP Space
      b1_ipam_range:
        space: "Test-Ansible-Space"
        name: "Test-Ansible-Range1"
        start: "172.16.0.100"
        end: "172.16.0.200"
        comment: "This is the test range"
        api_key: "{{ api }}"
        host: "{{ host }}"
        state: present

Regards,

Shukran

Shukran

Re: Ansible Playbook for BloxOne Cloud

New Member
Posts: 3
3265     0

Hello Shukran,

 

It worked! One follow up question. Do you know how to add default gateway option to the a subnet using the Playbook?

Re: Ansible Playbook for BloxOne Cloud

Superuser
Posts: 38
3265     0

I don't think that option is available in Ansible module. You can do it using API.

You can set the DHCP options by passing them in the request body.

Shukran
Showing results for 
Search instead for 
Did you mean: 

Recommended for You