Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps

Reply

MS DHCP - IPv4 Fixed Address via Ansible

New Member
Posts: 2
684     1

I recently had one of my customers reach out with an interesting use case for using Ansible to create an ipv4 fixed address. We have a module to do this when using Infoblox as the DHCP server and that is pretty straighforward. This particular customer uses MS DHCP. They have Infoblox for authoritative IPAM and use the R/W feature of the MS Management license so they can manage their DHCP environment from the IB GUI.

 

This is easily accomplished via the GUI where you can select the MS server when creating the fixed address.

Screen Shot 2022-03-30 at 10.03.53 AM.png

 

Similarily it can be accomplished via API but they were trying to understand how to do it via Ansible.

 

What I learned is, if you need to automate Infoblox objects that are not a part of the 16 modules supported in the NIOS collection, you need to use the uri module that is part of ansible-base and included in all Ansible installations. It allows you to interact with HTTP and HTTPS web services. More information can be found here:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html

 

I tested and validated the below and shared with the customer:

 

- hosts: localhost

  vars:

    host: 192.168.2.##

    username: admin

    password: pwd1234

    wapi_version: 'v2.12'

  

  connection: local

  tasks:  

    - name: configure ipv4 dhcp fixed address

      uri:

        url: "https://{{ host }}/wapi/{{ wapi_version }}/fixedaddress"

        user: "{{ username }}"

        password: "{{ password }}"

        validate_certs: no

        return_content: yes

        method: POST

        force_basic_auth: yes

        status_code: 201, 302, 200

        headers:

          Content-Type: "application/json"

        body:

          ipv4addr: 172.16.2.127

          mac: aa:bb:cc:dd:ee:ff

          name: Test_Ansible_FA

          ms_server:

            ipv4addr: 172.16.2.10

        body_format:  json

 

Probably not a common use case but wanted to share as I wasn't able to find something similar. Feel free to use and modify to meet your needs.

 

Thanks,

Scott Baker

Infoblox Sr Solutions Architect

 

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You