This module have been tested on infoblox API v1.2.1, other versions of the API are likly workable.
libinfoblox, https://github.com/steverweber/libinfoblox
libinfoblox can be installed using pip install libinfoblox
API documents can be found on your infoblox server at:
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
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
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" }
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': [], }
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'}
Create raw infoblox object. This is a low level api call.
CLI Example:
salt-call infoblox.update_object object_type=record:host data={}
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
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
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
Delete ip range.
CLI Example:
salt-call infoblox.delete_ipv4_range start_addr=123.123.122.12
Delete infoblox object. This is a low level api call.
CLI Example:
salt-call infoblox.delete_object objref=[ref_of_object]
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
Get A record
CLI Examples:
salt-call infoblox.get_a name=abc.example.com
salt-call infoblox.get_a ipv4addr=192.168.3.5
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
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
Get all host information
CLI Example:
salt-call infoblox.get_host_advanced hostname.domain.ca
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
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
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
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'
Get host ipv6addr information
CLI Example:
salt-call infoblox.get_host_ipv6addr_info ipv6addr=2001:db8:85a3:8d3:1349:8a2e:370:7348
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
Get ip range
CLI Example:
salt-call infoblox.get_ipv4_range start_addr=123.123.122.12
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
Get raw infoblox object. This is a low level api call.
CLI Example:
salt-call infoblox.get_object objref=[_ref of object]
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"
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'}"
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={}
Update raw infoblox object. This is a low level api call.
CLI Example:
salt-call infoblox.update_object objref=[ref_of_object] data={}