@ -20,6 +20,7 @@ description:
- Adds and / or removes instances of network objects from
- Adds and / or removes instances of network objects from
Infoblox NIOS servers . This module manages NIOS C ( network ) objects
Infoblox NIOS servers . This module manages NIOS C ( network ) objects
using the Infoblox WAPI interface over REST .
using the Infoblox WAPI interface over REST .
- Supports both IPV4 and IPV6 internet protocols
requirements :
requirements :
- infoblox_client
- infoblox_client
extends_documentation_fragment : nios
extends_documentation_fragment : nios
@ -87,7 +88,7 @@ options:
'''
'''
EXAMPLES = '''
EXAMPLES = '''
- name : configure a network
- name : configure a network ipv4
nios_network :
nios_network :
network : 192.168 .10 .0 / 24
network : 192.168 .10 .0 / 24
comment : this is a test comment
comment : this is a test comment
@ -98,7 +99,18 @@ EXAMPLES = '''
password : admin
password : admin
connection : local
connection : local
- name : set dhcp options for a network
- name : configure a network ipv6
nios_network :
network : fe80 : : / 64
comment : this is a test comment
state : present
provider :
host : " {{ inventory_hostname_short }} "
username : admin
password : admin
connection : local
- name : set dhcp options for a network ipv4
nios_network :
nios_network :
network : 192.168 .10 .0 / 24
network : 192.168 .10 .0 / 24
comment : this is a test comment
comment : this is a test comment
@ -112,7 +124,7 @@ EXAMPLES = '''
password : admin
password : admin
connection : local
connection : local
- name : remove a network
- name : remove a network ipv4
nios_network :
nios_network :
network : 192.168 .10 .0 / 24
network : 192.168 .10 .0 / 24
state : absent
state : absent
@ -128,6 +140,7 @@ RETURN = ''' # '''
from ansible . module_utils . basic import AnsibleModule
from ansible . module_utils . basic import AnsibleModule
from ansible . module_utils . six import iteritems
from ansible . module_utils . six import iteritems
from ansible . module_utils . net_tools . nios . api import WapiModule
from ansible . module_utils . net_tools . nios . api import WapiModule
from ansible . module_utils . network . common . utils import validate_ip_address , validate_ip_v6_address
def options ( module ) :
def options ( module ) :
@ -159,6 +172,17 @@ def options(module):
return options
return options
def check_ip_addr_type ( ip ) :
''' This function will check if the argument ip is type v4/v6 and return appropriate infoblox network type
'''
check_ip = ip . split ( ' / ' )
if validate_ip_address ( check_ip [ 0 ] ) :
return ' network '
elif validate_ip_v6_address ( check_ip [ 0 ] ) :
return ' ipv6network '
def main ( ) :
def main ( ) :
''' Main entry point for module execution
''' Main entry point for module execution
'''
'''
@ -194,8 +218,12 @@ def main():
module = AnsibleModule ( argument_spec = argument_spec ,
module = AnsibleModule ( argument_spec = argument_spec ,
supports_check_mode = True )
supports_check_mode = True )
# to get the argument ipaddr
obj_filter = dict ( [ ( k , module . params [ k ] ) for k , v in iteritems ( ib_spec ) if v . get ( ' ib_req ' ) ] )
network_type = check_ip_addr_type ( obj_filter [ ' network ' ] )
wapi = WapiModule ( module )
wapi = WapiModule ( module )
result = wapi . run ( ' network ' , ib_spec )
result = wapi . run ( network_type , ib_spec )
module . exit_json ( * * result )
module . exit_json ( * * result )