salt.modules.infoblox

This module have been tested on infoblox API v1.2.1, other versions of the API are likly workable.

depends:

libinfoblox, https://github.com/steverweber/libinfoblox

libinfoblox can be installed using pip install libinfoblox

API documents can be found on your infoblox server at:

configuration:

The following configuration defaults can be defined (pillar or config files '/etc/salt/master.d/infoblox.conf'):

infoblox.config:
    api_sslverify: True
    api_url: 'https://INFOBLOX/wapi/v1.2.1'
    api_user: 'username'
    api_key: 'password'

Many of the functions accept api_opts to override the API config.

salt-call infoblox.get_host name=my.host.com             api_url: 'https://INFOBLOX/wapi/v1.2.1'             api_user=admin             api_key=passs
salt.modules.infoblox.create_a(data, **api_opts)

Create A record.

This is a helper function to create_object. See your infoblox API for full data format.

CLI Example:

salt-call infoblox.create_a                     data =
            name: 'fastlinux.math.example.ca'
            ipv4addr: '127.0.0.1'
            view: External
salt.modules.infoblox.create_cname(data, **api_opts)

Create a cname record.

CLI Example:

salt-call infoblox.create_cname data={             "comment": "cname to example server",             "name": "example.example.com",             "zone": "example.com",             "view": "Internal",             "canonical": "example-ha-0.example.com"         }
salt.modules.infoblox.create_host(data, **api_opts)

Add host record

Avoid race conditions, use func:nextavailableip for ipv[4,6]addrs:

  • func:nextavailableip:network/ZG54dfgsrDFEFfsfsLzA:10.0.0.0/8/default

  • func:nextavailableip:10.0.0.0/8

  • func:nextavailableip:10.0.0.0/8,external

  • func:nextavailableip:10.0.0.3-10.0.0.10

See your infoblox API for full data format.

CLI Example:

salt-call infoblox.create_host             data =
        {'name': 'hostname.example.ca',
        'aliases': ['hostname.math.example.ca'],
    'extattrs': [{'Business Contact': {'value': 'example@example.ca'}},
        {'Pol8 Classification': {'value': 'Restricted'}},
        {'Primary OU': {'value': 'CS'}},
        {'Technical Contact': {'value': 'example@example.ca'}}],
    'ipv4addrs': [{'configure_for_dhcp': True,
        'ipv4addr': 'func:nextavailableip:129.97.139.0/24',
        'mac': '00:50:56:84:6e:ae'}],
    'ipv6addrs': [], }
salt.modules.infoblox.create_ipv4_range(data, **api_opts)

Create a ipv4 range

This is a helper function to create_object See your infoblox API for full data format.

CLI Example:

salt-call infoblox.create_ipv4_range data={
    start_addr: '129.97.150.160',
    end_addr: '129.97.150.170'}
salt.modules.infoblox.create_object(object_type, data, **api_opts)

Create raw infoblox object. This is a low level api call.

CLI Example:

salt-call infoblox.update_object object_type=record:host  data={}
salt.modules.infoblox.delete_a(name=None, ipv4addr=None, allow_array=False, **api_opts)

Delete A record

If the A record is used as a round robin you can set allow_array=True to delete all records for the hostname.

CLI Examples:

salt-call infoblox.delete_a name=abc.example.com
salt-call infoblox.delete_a ipv4addr=192.168.3.5
salt-call infoblox.delete_a name=acname.example.com allow_array=True
salt.modules.infoblox.delete_cname(name=None, canonical=None, **api_opts)

Delete CNAME. This is a helper call to delete_object.

If record is not found, return True

CLI Examples:

salt-call infoblox.delete_cname name=example.example.com
salt-call infoblox.delete_cname canonical=example-ha-0.example.com
salt.modules.infoblox.delete_host(name=None, mac=None, ipv4addr=None, **api_opts)

Delete host

CLI Example:

salt-call infoblox.delete_host name=example.domain.com
salt-call infoblox.delete_host ipv4addr=123.123.122.12
salt-call infoblox.delete_host ipv4addr=123.123.122.12 mac=00:50:56:84:6e:ae
salt.modules.infoblox.delete_ipv4_range(start_addr=None, end_addr=None, **api_opts)

Delete ip range.

CLI Example:

salt-call infoblox.delete_ipv4_range start_addr=123.123.122.12
salt.modules.infoblox.delete_object(objref, **api_opts)

Delete infoblox object. This is a low level api call.

CLI Example:

salt-call infoblox.delete_object objref=[ref_of_object]
salt.modules.infoblox.diff_objects(obja, objb)

Diff two complex infoblox objects. This is used from salt states to detect changes in objects.

Using func:nextavailableip will not cause a diff if the ipaddress is in range

salt.modules.infoblox.get_a(name=None, ipv4addr=None, allow_array=True, **api_opts)

Get A record

CLI Examples:

salt-call infoblox.get_a name=abc.example.com
salt-call infoblox.get_a ipv4addr=192.168.3.5
salt.modules.infoblox.get_cname(name=None, canonical=None, return_fields=None, **api_opts)

Get CNAME information.

CLI Examples:

salt-call infoblox.get_cname name=example.example.com
salt-call infoblox.get_cname canonical=example-ha-0.example.com
salt.modules.infoblox.get_host(name=None, ipv4addr=None, mac=None, return_fields=None, **api_opts)

Get host information

CLI Examples:

salt-call infoblox.get_host hostname.domain.ca
salt-call infoblox.get_host ipv4addr=123.123.122.12
salt-call infoblox.get_host mac=00:50:56:84:6e:ae
salt.modules.infoblox.get_host_advanced(name=None, ipv4addr=None, mac=None, **api_opts)

Get all host information

CLI Example:

salt-call infoblox.get_host_advanced hostname.domain.ca
salt.modules.infoblox.get_host_domainname(name, domains=None, **api_opts)

Get host domain name

If no domains are passed, the hostname is checked for a zone in infoblox, if no zone split on first dot.

If domains are provided, the best match out of the list is returned.

If none are found the return is None

dots at end of names are ignored.

CLI Example:

salt-call uwl.get_host_domainname name=localhost.t.domain.com             domains=['domain.com', 't.domain.com.']

# returns: t.domain.com
salt.modules.infoblox.get_host_hostname(name, domains=None, **api_opts)

Get hostname

If no domains are passed, the hostname is checked for a zone in infoblox, if no zone split on first dot.

If domains are provided, the best match out of the list is truncated from the fqdn leaving the hostname.

If no matching domains are found the fqdn is returned.

dots at end of names are ignored.

CLI Examples:

salt-call infoblox.get_host_hostname fqdn=localhost.xxx.t.domain.com             domains="['domain.com', 't.domain.com']"
#returns: localhost.xxx

salt-call infoblox.get_host_hostname fqdn=localhost.xxx.t.domain.com
#returns: localhost
salt.modules.infoblox.get_host_ipv4(name=None, mac=None, allow_array=False, **api_opts)

Get ipv4 address from host record.

Use allow_array to return possible multiple values.

CLI Examples:

salt-call infoblox.get_host_ipv4 host=localhost.domain.com
salt-call infoblox.get_host_ipv4 mac=00:50:56:84:6e:ae
salt.modules.infoblox.get_host_ipv4addr_info(ipv4addr=None, mac=None, discovered_data=None, return_fields=None, **api_opts)

Get host ipv4addr information

CLI Examples:

salt-call infoblox.get_ipv4addr ipv4addr=123.123.122.12
salt-call infoblox.get_ipv4addr mac=00:50:56:84:6e:ae
salt-call infoblox.get_ipv4addr mac=00:50:56:84:6e:ae return_fields=host return_fields='mac,host,configure_for_dhcp,ipv4addr'
salt.modules.infoblox.get_host_ipv6addr_info(ipv6addr=None, mac=None, discovered_data=None, return_fields=None, **api_opts)

Get host ipv6addr information

CLI Example:

salt-call infoblox.get_host_ipv6addr_info ipv6addr=2001:db8:85a3:8d3:1349:8a2e:370:7348
salt.modules.infoblox.get_host_mac(name=None, allow_array=False, **api_opts)

Get mac address from host record.

Use allow_array to return possible multiple values.

CLI Example:

salt-call infoblox.get_host_mac host=localhost.domain.com
salt.modules.infoblox.get_ipv4_range(start_addr=None, end_addr=None, return_fields=None, **api_opts)

Get ip range

CLI Example:

salt-call infoblox.get_ipv4_range start_addr=123.123.122.12
salt.modules.infoblox.get_network(ipv4addr=None, network=None, return_fields=None, **api_opts)

Get list of all networks. This is helpful when looking up subnets to use with func:nextavailableip

This call is offen slow and not cached!

some return_fields comment,network,network_view,ddns_domainname,disable,enable_ddns

CLI Example:

salt-call infoblox.get_network
salt.modules.infoblox.get_object(objref, data=None, return_fields=None, max_results=None, ensure_none_or_one_result=False, **api_opts)

Get raw infoblox object. This is a low level api call.

CLI Example:

salt-call infoblox.get_object objref=[_ref of object]
salt.modules.infoblox.is_ipaddr_in_ipfunc_range(ipaddr, ipfunc)

Return true if the ipaddress is in the range of the nextavailableip function

CLI Example:

salt-call infoblox.is_ipaddr_in_ipfunc_range             ipaddr="10.0.2.2" ipfunc="func:nextavailableip:10.0.0.0/8"
salt.modules.infoblox.update_cname(name, data, **api_opts)

Update CNAME. This is a helper call to update_object.

Find a CNAME _ref then call update_object with the record data.

CLI Example:

salt-call infoblox.update_cname name=example.example.com data="{
        'canonical':'example-ha-0.example.com',
        'use_ttl':true,
        'ttl':200,
        'comment':'Salt managed CNAME'}"
salt.modules.infoblox.update_host(name, data, **api_opts)

Update host record. This is a helper call to update_object.

Find a hosts _ref then call update_object with the record data.

CLI Example:

salt-call infoblox.update_host name=fqdn data={}
salt.modules.infoblox.update_object(objref, data, **api_opts)

Update raw infoblox object. This is a low level api call.

CLI Example:

salt-call infoblox.update_object objref=[ref_of_object] data={}