infobloxopen / infoblox-ansible

Ansible modules for interfacing to Infoblox systems
GNU General Public License v3.0
55 stars 62 forks source link

Dynamically add host record to next available ip with an exclusion list #244

Open hmalphettes opened 3 months ago

hmalphettes commented 3 months ago

The usage of nios_next_ip when creating a host record has a few limitations:

These changes support passing the function call as documented in https://ipam.illinois.edu/wapidoc/objects/record.host_ipv4addr.html:

For example

- name: >
    Dynamically add host record to next available ip in
    a network and excluding a list of IPs
    see https://ipam.illinois.edu/wapidoc/objects/record.host_ipv4addr.html
  infoblox.nios_modules.nios_host_record:
    name: host.ansible.com
    ipv4:
      - address:
        _object_function: next_available_ip
        _parameters:
          exclude: ['192.168.10.1', '192.168.10.2', '192.168.10.3'],
        _result_fields: ips
        _object: network
        _object_parameters:
          network: 192.168.10.0/24
    comment: this is a test comment
    state: present
    provider:
      host: "{{ inventory_hostname_short }}"
      username: admin
      password: admin
  connection: local

I realize this is done fairly quickly without test units and other missing pieces before it can be merged. I appreciate your guidance: let me know if this is interesting for the community and if this is the right syntax to expose. Thanks!