summaryrefslogtreecommitdiffstats
path: root/ansible_collections/infoblox/nios_modules/plugins
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:22 +0000
commit38b7c80217c4e72b1d8988eb1e60bb6e77334114 (patch)
tree356e9fd3762877d07cde52d21e77070aeff7e789 /ansible_collections/infoblox/nios_modules/plugins
parentAdding upstream version 7.7.0+dfsg. (diff)
downloadansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.tar.xz
ansible-38b7c80217c4e72b1d8988eb1e60bb6e77334114.zip
Adding upstream version 9.4.0+dfsg.upstream/9.4.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/infoblox/nios_modules/plugins')
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py2
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py26
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py21
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_http.py272
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_icmp.py154
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_pdp.py159
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_sip.py209
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_snmp.py279
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_tcp.py163
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py26
-rw-r--r--ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_topology.py253
11 files changed, 1553 insertions, 11 deletions
diff --git a/ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py b/ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py
index bd1f02eaf..bbecf7a63 100644
--- a/ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py
+++ b/ansible_collections/infoblox/nios_modules/plugins/doc_fragments/nios.py
@@ -77,7 +77,7 @@ options:
wapi_version:
description:
- Specifies the version of WAPI to use
- - Value can also be specified using C(INFOBLOX_WAP_VERSION) environment
+ - Value can also be specified using C(INFOBLOX_WAPI_VERSION) environment
variable.
- Until ansible 2.8 the default WAPI was 1.4
type: str
diff --git a/ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py b/ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py
index 51c512571..3a586193b 100644
--- a/ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py
+++ b/ansible_collections/infoblox/nios_modules/plugins/module_utils/api.py
@@ -71,6 +71,13 @@ NIOS_MEMBER = 'member'
NIOS_DTC_SERVER = 'dtc:server'
NIOS_DTC_POOL = 'dtc:pool'
NIOS_DTC_LBDN = 'dtc:lbdn'
+NIOS_DTC_MONITOR_HTTP = 'dtc:monitor:http'
+NIOS_DTC_MONITOR_ICMP = 'dtc:monitor:icmp'
+NIOS_DTC_MONITOR_PDP = 'dtc:monitor:pdp'
+NIOS_DTC_MONITOR_SIP = 'dtc:monitor:sip'
+NIOS_DTC_MONITOR_SNMP = 'dtc:monitor:snmp'
+NIOS_DTC_MONITOR_TCP = 'dtc:monitor:tcp'
+NIOS_DTC_TOPOLOGY = 'dtc:topology'
NIOS_PROVIDER_SPEC = {
'host': dict(fallback=(env_fallback, ['INFOBLOX_HOST'])),
@@ -84,8 +91,8 @@ NIOS_PROVIDER_SPEC = {
'http_pool_connections': dict(type='int', default=10),
'http_pool_maxsize': dict(type='int', default=10),
'max_retries': dict(type='int', default=3, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES'])),
- 'wapi_version': dict(default='2.9', fallback=(env_fallback, ['INFOBLOX_WAP_VERSION'])),
- 'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES']))
+ 'wapi_version': dict(default='2.9', fallback=(env_fallback, ['INFOBLOX_WAPI_VERSION'])),
+ 'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RESULTS']))
}
@@ -113,7 +120,12 @@ def get_connector(*args, **kwargs):
# explicitly set
env = ('INFOBLOX_%s' % key).upper()
if env in os.environ:
- kwargs[key] = os.environ.get(env)
+ if NIOS_PROVIDER_SPEC[key].get('type') == 'bool':
+ kwargs[key] = eval(os.environ.get(env).title())
+ elif NIOS_PROVIDER_SPEC[key].get('type') == 'int':
+ kwargs[key] = eval(os.environ.get(env))
+ else:
+ kwargs[key] = os.environ.get(env)
if 'validate_certs' in kwargs.keys():
kwargs['ssl_verify'] = kwargs['validate_certs']
@@ -746,6 +758,11 @@ class WapiModule(WapiBase):
except TypeError:
txt = obj_filter['text']
test_obj_filter['text'] = txt
+
+ # removing Port param from get params for NIOS_DTC_MONITOR_TCP
+ elif (ib_obj_type == NIOS_DTC_MONITOR_TCP):
+ test_obj_filter = dict([('name', obj_filter['name'])])
+
# check if test_obj_filter is empty copy passed obj_filter
else:
test_obj_filter = obj_filter
@@ -767,9 +784,6 @@ class WapiModule(WapiBase):
except TypeError:
ipaddr = obj_filter['ipv4addr']
test_obj_filter['ipv4addr'] = ipaddr
- # prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found
- if old_ipv4addr_exists and ib_obj is None:
- raise Exception("A Record with ipv4addr: '%s' is not found" % (ipaddr))
ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=list(ib_spec.keys()))
# prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found
if old_ipv4addr_exists and ib_obj is None:
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py
index e18689035..bc5a79c16 100644
--- a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_lbdn.py
@@ -37,6 +37,12 @@ options:
- RATIO
- ROUND_ROBIN
- TOPOLOGY
+ topology:
+ description:
+ - Configures the topology rules for the C(TOPOLOGY) load balancing method.
+ - Required only when I(lb_method) is set to C(TOPOLOGY).
+ required: false
+ type: str
auth_zones:
description:
- List of linked authoritative zones.
@@ -172,7 +178,7 @@ def main():
for zone in module.params['auth_zones']:
zone_obj = wapi.get_object('zone_auth',
{'fqdn': zone})
- if zone_obj is not None:
+ if zone_obj:
zone_list.append(zone_obj[0]['_ref'])
else:
module.fail_json(
@@ -188,13 +194,23 @@ def main():
{'name': pool['pool']})
if 'ratio' not in pool:
pool['ratio'] = 1
- if pool_obj is not None:
+ if pool_obj:
pool_list.append({'pool': pool_obj[0]['_ref'],
'ratio': pool['ratio']})
else:
module.fail_json(msg='pool %s cannot be found.' % pool)
return pool_list
+ def topology_transform(module):
+ topology = module.params['topology']
+ if topology:
+ topo_obj = wapi.get_object('dtc:topology', {'name': topology})
+ if topo_obj:
+ return topo_obj[0]['_ref']
+ else:
+ module.fail_json(
+ msg='topology %s cannot be found.' % topology)
+
auth_zones_spec = dict()
pools_spec = dict(
@@ -207,6 +223,7 @@ def main():
lb_method=dict(required=True, choices=['GLOBAL_AVAILABILITY',
'RATIO', 'ROUND_ROBIN', 'TOPOLOGY']),
+ topology=dict(type='str', transform=topology_transform),
auth_zones=dict(type='list', elements='str', options=auth_zones_spec,
transform=auth_zones_transform),
patterns=dict(type='list', elements='str'),
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_http.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_http.py
new file mode 100644
index 000000000..b90e98a04
--- /dev/null
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_http.py
@@ -0,0 +1,272 @@
+#!/usr/bin/python
+# Copyright (c) 2018-2019 Red Hat, Inc.
+# Copyright (c) 2020 Infoblox, Inc.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+module: nios_dtc_monitor_http
+author: "Joachim Buyse (@jbisabel)"
+version_added: "1.6.0"
+short_description: Configure Infoblox NIOS DTC HTTP monitors
+description:
+ - Adds and/or removes instances of DTC HTTP monitor objects from Infoblox NIOS
+ servers. This module manages C(dtc:monitor:http) objects using the Infoblox
+ WAPI interface over REST.
+requirements:
+ - infoblox-client
+extends_documentation_fragment: infoblox.nios_modules.nios
+notes:
+ - This module supports C(check_mode).
+options:
+ name:
+ description:
+ - Configures the display name for this DTC monitor. Values with leading
+ or trailing white space are not valid for this field.
+ required: true
+ type: str
+ port:
+ description:
+ - Configures the port value for HTTP requests.
+ type: int
+ default: 80
+ ciphers:
+ description:
+ - Configures an optional cipher list for the secure HTTP/S connection.
+ type: str
+ client_cert:
+ description:
+ - Configures an optional client certificate, supplied in a secure HTTP/S
+ mode if present.
+ type: str
+ content_check:
+ description:
+ - Configures the content check type
+ type: str
+ choices:
+ - EXTRACT
+ - MATCH
+ - NONE
+ default: NONE
+ content_check_input:
+ description:
+ - Configures the portion of the response to use as input for content check.
+ type: str
+ choices:
+ - ALL
+ - BODY
+ - HEADERS
+ default: ALL
+ content_check_op:
+ description:
+ - Configures the content check success criteria operator.
+ type: str
+ choices:
+ - EQ
+ - GEQ
+ - LEQ
+ - NEQ
+ content_check_regex:
+ description:
+ - Configures the content check regular expression. Values with leading
+ or trailing white space are not valid for this field.
+ type: str
+ content_extract_group:
+ description:
+ - Configures the content extraction sub-expression to extract.
+ type: int
+ default: 0
+ content_extract_type:
+ description:
+ - Configures the content extraction expected type for the extracted data.
+ type: str
+ choices:
+ - INTEGER
+ - STRING
+ default: STRING
+ content_extract_value:
+ description:
+ - Configures the content extraction value to compare with the extracted
+ result. Values with leading or trailing white space are not valid for
+ this field.
+ type: str
+ request:
+ description:
+ - Configures the HTTP request to send
+ type: str
+ default: GET /
+ result:
+ description:
+ - Configures the type of the expected result
+ type: str
+ choices:
+ - ANY
+ - CODE_IS
+ - CODE_IS_NOT
+ default: ANY
+ result_code:
+ description:
+ - Configures the expected return code
+ type: int
+ default: 200
+ enable_sni:
+ description:
+ - Configures whether or not Server Name Indication (SNI) for the HTTPS
+ monitor is enabled.
+ type: bool
+ default: false
+ secure:
+ description:
+ - Configures the security status of the connection.
+ type: bool
+ default: false
+ validate_cert:
+ description:
+ - Configures whether the validation of the remote server's certificate is
+ enabled.
+ type: bool
+ default: true
+ interval:
+ description:
+ - Configures the interval for HTTP health check.
+ type: int
+ default: 5
+ retry_down:
+ description:
+ - Configures the value of how many times the server should appear as
+ down to be treated as dead after it was alive.
+ type: int
+ default: 1
+ retry_up:
+ description:
+ - Configures the value of how many times the server should appear as up
+ to be treated as alive after it was dead.
+ type: int
+ default: 1
+ timeout:
+ description:
+ - Configures the timeout for HTTP health check in seconds.
+ type: int
+ default: 15
+ extattrs:
+ description:
+ - Allows for the configuration of Extensible Attributes on the
+ instance of the object. This argument accepts a set of key / value
+ pairs for configuration.
+ type: dict
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ state:
+ description:
+ - Configures the intended state of the instance of the object on
+ the NIOS server. When this value is set to C(present), the object
+ is configured on the device and when this value is set to C(absent)
+ the value is removed (if necessary) from the device.
+ default: present
+ choices:
+ - present
+ - absent
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Configure a DTC HTTPS monitor
+ infoblox.nios_modules.nios_dtc_monitor_http:
+ name: https_monitor
+ port: 443
+ secure: true
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Add a comment to an existing DTC HTTPS monitor
+ infoblox.nios_modules.nios_dtc_monitor_http:
+ name: https_monitor
+ comment: this is a test comment
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Remove a DTC HTTPS monitor from the system
+ infoblox.nios_modules.nios_dtc_monitor_http:
+ name: https_monitor
+ state: absent
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+'''
+
+RETURN = ''' # '''
+
+from ansible.module_utils.basic import AnsibleModule
+from ..module_utils.api import WapiModule
+from ..module_utils.api import NIOS_DTC_MONITOR_HTTP
+from ..module_utils.api import normalize_ib_spec
+
+
+def main():
+ ''' Main entry point for module execution
+ '''
+
+ ib_spec = dict(
+ name=dict(required=True, ib_req=True),
+
+ port=dict(type='int', default=80),
+ ciphers=dict(type='str'),
+ client_cert=dict(type='str'),
+ content_check=dict(default='NONE', choices=['EXTRACT', 'MATCH', 'NONE']),
+ content_check_input=dict(default='ALL', choices=['ALL', 'BODY', 'HEADERS']),
+ content_check_op=dict(choices=['EQ', 'GEQ', 'LEQ', 'NEQ']),
+ content_check_regex=dict(type='str'),
+ content_extract_group=dict(type='int', default=0),
+ content_extract_type=dict(default='STRING', choices=['INTEGER', 'STRING']),
+ content_extract_value=dict(type='str'),
+ request=dict(type='str', default='GET /'),
+ result=dict(default='ANY', choices=['ANY', 'CODE_IS', 'CODE_IS_NOT']),
+ result_code=dict(type='int', default=200),
+ enable_sni=dict(type='bool', default=False),
+ secure=dict(type='bool', default=False),
+ validate_cert=dict(type='bool', default=True),
+ interval=dict(type='int', default=5),
+ retry_down=dict(type='int', default=1),
+ retry_up=dict(type='int', default=1),
+ timeout=dict(type='int', default=15),
+
+ extattrs=dict(type='dict'),
+ comment=dict(),
+ )
+
+ argument_spec = dict(
+ provider=dict(required=True),
+ state=dict(default='present', choices=['present', 'absent'])
+ )
+
+ argument_spec.update(normalize_ib_spec(ib_spec))
+ argument_spec.update(WapiModule.provider_spec)
+
+ module = AnsibleModule(argument_spec=argument_spec,
+ supports_check_mode=True)
+
+ wapi = WapiModule(module)
+ result = wapi.run(NIOS_DTC_MONITOR_HTTP, ib_spec)
+
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_icmp.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_icmp.py
new file mode 100644
index 000000000..e133954ef
--- /dev/null
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_icmp.py
@@ -0,0 +1,154 @@
+#!/usr/bin/python
+# Copyright (c) 2018-2019 Red Hat, Inc.
+# Copyright (c) 2020 Infoblox, Inc.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+module: nios_dtc_monitor_icmp
+author: "Joachim Buyse (@jbisabel)"
+version_added: "1.6.0"
+short_description: Configure Infoblox NIOS DTC ICMP monitors
+description:
+ - Adds and/or removes instances of DTC ICMP monitor objects from Infoblox NIOS
+ servers. This module manages C(dtc:monitor:icmp) objects using the Infoblox
+ WAPI interface over REST.
+requirements:
+ - infoblox-client
+extends_documentation_fragment: infoblox.nios_modules.nios
+notes:
+ - This module supports C(check_mode).
+options:
+ name:
+ description:
+ - Configures the display name for this DTC monitor. Values with leading
+ or trailing white space are not valid for this field.
+ required: true
+ type: str
+ interval:
+ description:
+ - Configures the interval for ICMP health check.
+ type: int
+ default: 5
+ retry_down:
+ description:
+ - Configures the value of how many times the server should appear as
+ down to be treated as dead after it was alive.
+ type: int
+ default: 1
+ retry_up:
+ description:
+ - Configures the value of how many times the server should appear as up
+ to be treated as alive after it was dead.
+ type: int
+ default: 1
+ timeout:
+ description:
+ - Configures the timeout for ICMP health check in seconds.
+ type: int
+ default: 15
+ extattrs:
+ description:
+ - Allows for the configuration of Extensible Attributes on the
+ instance of the object. This argument accepts a set of key / value
+ pairs for configuration.
+ type: dict
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ state:
+ description:
+ - Configures the intended state of the instance of the object on
+ the NIOS server. When this value is set to C(present), the object
+ is configured on the device and when this value is set to C(absent)
+ the value is removed (if necessary) from the device.
+ default: present
+ choices:
+ - present
+ - absent
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Configure a DTC ICMP monitor
+ infoblox.nios_modules.nios_dtc_monitor_icmp:
+ name: icmp_monitor
+ port: 8080
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Add a comment to an existing DTC ICMP monitor
+ infoblox.nios_modules.nios_dtc_monitor_icmp:
+ name: icmp_monitor
+ comment: this is a test comment
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Remove a DTC ICMP monitor from the system
+ infoblox.nios_modules.nios_dtc_monitor_icmp:
+ name: icmp_monitor
+ state: absent
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+'''
+
+RETURN = ''' # '''
+
+from ansible.module_utils.basic import AnsibleModule
+from ..module_utils.api import WapiModule
+from ..module_utils.api import NIOS_DTC_MONITOR_ICMP
+from ..module_utils.api import normalize_ib_spec
+
+
+def main():
+ ''' Main entry point for module execution
+ '''
+
+ ib_spec = dict(
+ name=dict(required=True, ib_req=True),
+
+ interval=dict(type='int', default=5),
+ retry_down=dict(type='int', default=1),
+ retry_up=dict(type='int', default=1),
+ timeout=dict(type='int', default=15),
+
+ extattrs=dict(type='dict'),
+ comment=dict(),
+ )
+
+ argument_spec = dict(
+ provider=dict(required=True),
+ state=dict(default='present', choices=['present', 'absent'])
+ )
+
+ argument_spec.update(normalize_ib_spec(ib_spec))
+ argument_spec.update(WapiModule.provider_spec)
+
+ module = AnsibleModule(argument_spec=argument_spec,
+ supports_check_mode=True)
+
+ wapi = WapiModule(module)
+ result = wapi.run(NIOS_DTC_MONITOR_ICMP, ib_spec)
+
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_pdp.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_pdp.py
new file mode 100644
index 000000000..d9cf8e4a8
--- /dev/null
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_pdp.py
@@ -0,0 +1,159 @@
+#!/usr/bin/python
+# Copyright (c) 2018-2019 Red Hat, Inc.
+# Copyright (c) 2020 Infoblox, Inc.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+module: nios_dtc_monitor_pdp
+author: "Joachim Buyse (@jbisabel)"
+version_added: "1.6.0"
+short_description: Configure Infoblox NIOS DTC PDP monitors
+description:
+ - Adds and/or removes instances of DTC PDP monitor objects from Infoblox NIOS
+ servers. This module manages C(dtc:monitor:pdp) objects using the Infoblox
+ WAPI interface over REST.
+requirements:
+ - infoblox-client
+extends_documentation_fragment: infoblox.nios_modules.nios
+notes:
+ - This module supports C(check_mode).
+options:
+ name:
+ description:
+ - Configures the display name for this DTC monitor. Values with leading
+ or trailing white space are not valid for this field.
+ required: true
+ type: str
+ port:
+ description:
+ - Configures the port value for PDP requests.
+ type: int
+ default: 2123
+ interval:
+ description:
+ - Configures the interval for PDP health check.
+ type: int
+ default: 5
+ retry_down:
+ description:
+ - Configures the value of how many times the server should appear as
+ down to be treated as dead after it was alive.
+ type: int
+ default: 1
+ retry_up:
+ description:
+ - Configures the value of how many times the server should appear as up
+ to be treated as alive after it was dead.
+ type: int
+ default: 1
+ timeout:
+ description:
+ - Configures the timeout for PDP health check in seconds.
+ type: int
+ default: 15
+ extattrs:
+ description:
+ - Allows for the configuration of Extensible Attributes on the
+ instance of the object. This argument accepts a set of key / value
+ pairs for configuration.
+ type: dict
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ state:
+ description:
+ - Configures the intended state of the instance of the object on
+ the NIOS server. When this value is set to C(present), the object
+ is configured on the device and when this value is set to C(absent)
+ the value is removed (if necessary) from the device.
+ default: present
+ choices:
+ - present
+ - absent
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Configure a DTC PDP monitor
+ infoblox.nios_modules.nios_dtc_monitor_pdp:
+ name: pdp_monitor
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Add a comment to an existing DTC PDP monitor
+ infoblox.nios_modules.nios_dtc_monitor_pdp:
+ name: pdp_monitor
+ comment: this is a test comment
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Remove a DTC PDP monitor from the system
+ infoblox.nios_modules.nios_dtc_monitor_pdp:
+ name: pdp_monitor
+ state: absent
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+'''
+
+RETURN = ''' # '''
+
+from ansible.module_utils.basic import AnsibleModule
+from ..module_utils.api import WapiModule
+from ..module_utils.api import NIOS_DTC_MONITOR_PDP
+from ..module_utils.api import normalize_ib_spec
+
+
+def main():
+ ''' Main entry point for module execution
+ '''
+
+ ib_spec = dict(
+ name=dict(required=True, ib_req=True),
+
+ port=dict(type='int', default=2123),
+ interval=dict(type='int', default=5),
+ retry_down=dict(type='int', default=1),
+ retry_up=dict(type='int', default=1),
+ timeout=dict(type='int', default=15),
+
+ extattrs=dict(type='dict'),
+ comment=dict(),
+ )
+
+ argument_spec = dict(
+ provider=dict(required=True),
+ state=dict(default='present', choices=['present', 'absent'])
+ )
+
+ argument_spec.update(normalize_ib_spec(ib_spec))
+ argument_spec.update(WapiModule.provider_spec)
+
+ module = AnsibleModule(argument_spec=argument_spec,
+ supports_check_mode=True)
+
+ wapi = WapiModule(module)
+ result = wapi.run(NIOS_DTC_MONITOR_PDP, ib_spec)
+
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_sip.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_sip.py
new file mode 100644
index 000000000..c1df09853
--- /dev/null
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_sip.py
@@ -0,0 +1,209 @@
+#!/usr/bin/python
+# Copyright (c) 2018-2019 Red Hat, Inc.
+# Copyright (c) 2020 Infoblox, Inc.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+module: nios_dtc_monitor_sip
+author: "Joachim Buyse (@jbisabel)"
+version_added: "1.6.0"
+short_description: Configure Infoblox NIOS DTC SIP monitors
+description:
+ - Adds and/or removes instances of DTC SIP monitor objects from Infoblox NIOS
+ servers. This module manages C(dtc:monitor:sip) objects using the Infoblox
+ WAPI interface over REST.
+requirements:
+ - infoblox-client
+extends_documentation_fragment: infoblox.nios_modules.nios
+notes:
+ - This module supports C(check_mode).
+options:
+ name:
+ description:
+ - Configures the display name for this DTC monitor. Values with leading
+ or trailing white space are not valid for this field.
+ required: true
+ type: str
+ port:
+ description:
+ - Configures the port value for SIP requests.
+ type: int
+ default: 5060
+ ciphers:
+ description:
+ - Configures an optional cipher list for the secure TLS/SIPS connection.
+ type: str
+ client_cert:
+ description:
+ - Configures an optional client certificate, supplied in TLS or SIPS mode
+ if present.
+ type: str
+ request:
+ description:
+ - Configures the SIP request to send
+ type: str
+ result:
+ description:
+ - Configures the type of the expected result
+ type: str
+ choices:
+ - ANY
+ - CODE_IS
+ - CODE_IS_NOT
+ default: ANY
+ result_code:
+ description:
+ - Configures the expected return code
+ type: int
+ default: 200
+ transport:
+ description:
+ - Configures the transport layer protocol to use for the SIP check
+ type: str
+ choices:
+ - SIPS
+ - TCP
+ - TLS
+ - UDP
+ default: TCP
+ validate_cert:
+ description:
+ - Configures whether the validation of the remote server's certificate is
+ enabled.
+ type: bool
+ default: true
+ interval:
+ description:
+ - Configures the interval for SIP health check.
+ type: int
+ default: 5
+ retry_down:
+ description:
+ - Configures the value of how many times the server should appear as
+ down to be treated as dead after it was alive.
+ type: int
+ default: 1
+ retry_up:
+ description:
+ - Configures the value of how many times the server should appear as up
+ to be treated as alive after it was dead.
+ type: int
+ default: 1
+ timeout:
+ description:
+ - Configures the timeout for SIP health check in seconds.
+ type: int
+ default: 15
+ extattrs:
+ description:
+ - Allows for the configuration of Extensible Attributes on the
+ instance of the object. This argument accepts a set of key / value
+ pairs for configuration.
+ type: dict
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ state:
+ description:
+ - Configures the intended state of the instance of the object on
+ the NIOS server. When this value is set to C(present), the object
+ is configured on the device and when this value is set to C(absent)
+ the value is removed (if necessary) from the device.
+ default: present
+ choices:
+ - present
+ - absent
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Configure a DTC SIP monitor
+ infoblox.nios_modules.nios_dtc_monitor_sip:
+ name: sip_monitor
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Add a comment to an existing DTC SIP monitor
+ infoblox.nios_modules.nios_dtc_monitor_sip:
+ name: sip_monitor
+ comment: this is a test comment
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Remove a DTC SIP monitor from the system
+ infoblox.nios_modules.nios_dtc_monitor_sip:
+ name: sip_monitor
+ state: absent
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+'''
+
+RETURN = ''' # '''
+
+from ansible.module_utils.basic import AnsibleModule
+from ..module_utils.api import WapiModule
+from ..module_utils.api import NIOS_DTC_MONITOR_SIP
+from ..module_utils.api import normalize_ib_spec
+
+
+def main():
+ ''' Main entry point for module execution
+ '''
+
+ ib_spec = dict(
+ name=dict(required=True, ib_req=True),
+
+ port=dict(type='int', default=5060),
+ ciphers=dict(type='str'),
+ client_cert=dict(type='str'),
+ request=dict(type='str'),
+ result=dict(default='ANY', choices=['ANY', 'CODE_IS', 'CODE_IS_NOT']),
+ result_code=dict(type='int', default=200),
+ transport=dict(default='TCP', choices=['SIPS', 'TCP', 'TLS', 'UDP']),
+ validate_cert=dict(type='bool', default=True),
+ interval=dict(type='int', default=5),
+ retry_down=dict(type='int', default=1),
+ retry_up=dict(type='int', default=1),
+ timeout=dict(type='int', default=15),
+
+ extattrs=dict(type='dict'),
+ comment=dict(),
+ )
+
+ argument_spec = dict(
+ provider=dict(required=True),
+ state=dict(default='present', choices=['present', 'absent'])
+ )
+
+ argument_spec.update(normalize_ib_spec(ib_spec))
+ argument_spec.update(WapiModule.provider_spec)
+
+ module = AnsibleModule(argument_spec=argument_spec,
+ supports_check_mode=True)
+
+ wapi = WapiModule(module)
+ result = wapi.run(NIOS_DTC_MONITOR_SIP, ib_spec)
+
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_snmp.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_snmp.py
new file mode 100644
index 000000000..036580e86
--- /dev/null
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_snmp.py
@@ -0,0 +1,279 @@
+#!/usr/bin/python
+# Copyright (c) 2018-2019 Red Hat, Inc.
+# Copyright (c) 2020 Infoblox, Inc.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+module: nios_dtc_monitor_snmp
+author: "Joachim Buyse (@jbisabel)"
+version_added: "1.6.0"
+short_description: Configure Infoblox NIOS DTC SNMP monitors
+description:
+ - Adds and/or removes instances of DTC SNMP monitor objects from Infoblox NIOS
+ servers. This module manages C(dtc:monitor:snmp) objects using the Infoblox
+ WAPI interface over REST.
+requirements:
+ - infoblox-client
+extends_documentation_fragment: infoblox.nios_modules.nios
+notes:
+ - This module supports C(check_mode).
+options:
+ name:
+ description:
+ - Configures the display name for this DTC monitor. Values with leading
+ or trailing white space are not valid for this field.
+ required: true
+ type: str
+ port:
+ description:
+ - Configures the port value for SNMP requests.
+ type: int
+ default: 161
+ version:
+ description:
+ - Configures the SNMP protocol version for the SNMP health check.
+ type: str
+ choices:
+ - V1
+ - V2C
+ - V3
+ default: V2C
+ community:
+ description:
+ - Configures the SNMP community string for SNMP authentication.
+ type: str
+ default: public
+ user:
+ description:
+ - Configures the SNMPv3 user setting.
+ type: str
+ context:
+ description:
+ - Configures the SNMPv3 context. Values with leading or trailing white
+ space are not valid for this field.
+ type: str
+ engine_id:
+ description:
+ - Configures the SNMPv3 engine identifier. Values with leading or
+ trailing white space are not valid for this field.
+ type: str
+ oids:
+ description:
+ - Configures the list of OIDs for SNMP monitoring.
+ type: list
+ elements: dict
+ suboptions:
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ condition:
+ description:
+ - Configures the condition of the validation result for the SNMP
+ health check.
+ type: str
+ choices:
+ - ANY
+ - EXACT
+ - GEQ
+ - LEQ
+ - RANGE
+ default: ANY
+ first:
+ description:
+ - Configures the condition's first term to match against the SNMP
+ health check result.
+ type: str
+ last:
+ description:
+ - Configures the condition's second term to match against the SNMP
+ health check result with 'RANGE' condition.
+ type: str
+ oid:
+ description:
+ - Configures the SNMP OID value for DTC SNMP Monitor health checks.
+ - This field is required on creation
+ required: true
+ type: str
+ type:
+ description:
+ - Configures the condition type for DTC SNMP Monitor health checks
+ results.
+ type: str
+ choices:
+ - INTEGER
+ - STRING
+ default: STRING
+ interval:
+ description:
+ - Configures the interval for SNMP health check.
+ type: int
+ default: 5
+ retry_down:
+ description:
+ - Configures the value of how many times the server should appear as
+ down to be treated as dead after it was alive.
+ type: int
+ default: 1
+ retry_up:
+ description:
+ - Configures the value of how many times the server should appear as up
+ to be treated as alive after it was dead.
+ type: int
+ default: 1
+ timeout:
+ description:
+ - Configures the timeout for SNMP health check in seconds.
+ type: int
+ default: 15
+ extattrs:
+ description:
+ - Allows for the configuration of Extensible Attributes on the
+ instance of the object. This argument accepts a set of key / value
+ pairs for configuration.
+ type: dict
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ state:
+ description:
+ - Configures the intended state of the instance of the object on
+ the NIOS server. When this value is set to C(present), the object
+ is configured on the device and when this value is set to C(absent)
+ the value is removed (if necessary) from the device.
+ default: present
+ choices:
+ - present
+ - absent
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Configure a DTC SNMP monitor
+ infoblox.nios_modules.nios_dtc_monitor_snmp:
+ name: snmp_monitor
+ port: 8080
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Add a comment to an existing DTC SNMP monitor
+ infoblox.nios_modules.nios_dtc_monitor_snmp:
+ name: snmp_monitor
+ comment: this is a test comment
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Remove a DTC SNMP monitor from the system
+ infoblox.nios_modules.nios_dtc_monitor_snmp:
+ name: snmp_monitor
+ state: absent
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+'''
+
+RETURN = ''' # '''
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.six import iteritems
+from ..module_utils.api import WapiModule
+from ..module_utils.api import NIOS_DTC_MONITOR_SNMP
+from ..module_utils.api import normalize_ib_spec
+
+
+def oids(module):
+ ''' Transform the module argument into a valid WAPI struct
+ This function will transform the oids argument into a structure that is a
+ valid WAPI structure in the format of:
+ {
+ comment: <value>,
+ condition: <value>,
+ first: <value>,
+ last: <value>,
+ oid: <value>,
+ type: <value>,
+ }
+ It will remove any options that are set to None since WAPI will error on
+ that condition.
+ The remainder of the value validation is performed by WAPI
+ '''
+
+ oids = list()
+ for item in module.params['oids']:
+ oid = dict([(k, v) for k, v in iteritems(item) if v is not None])
+ if 'oid' not in oid:
+ module.fail_json(msg='oid is required for oid value')
+ oids.append(oid)
+ return oids
+
+
+def main():
+ ''' Main entry point for module execution
+ '''
+
+ oid_spec = dict(
+ comment=dict(type='str'),
+ condition=dict(default='ANY', choices=['ANY', 'EXACT', 'GEQ', 'LEQ', 'RANGE']),
+ first=dict(type='str'),
+ last=dict(type='str'),
+ oid=dict(type='str', required=True),
+ type=dict(default='STRING', choices=['INTEGER', 'STRING'])
+ )
+
+ ib_spec = dict(
+ name=dict(required=True, ib_req=True),
+
+ port=dict(type='int', default=161),
+ version=dict(default='V2C', choices=['V1', 'V2C', 'V3']),
+ community=dict(type='str', default='public'),
+ user=dict(type='str'),
+ context=dict(type='str'),
+ engine_id=dict(type='str'),
+ oids=dict(type='list', elements='dict', options=oid_spec, transform=oids),
+ interval=dict(type='int', default=5),
+ retry_down=dict(type='int', default=1),
+ retry_up=dict(type='int', default=1),
+ timeout=dict(type='int', default=15),
+
+ extattrs=dict(type='dict'),
+ comment=dict(),
+ )
+
+ argument_spec = dict(
+ provider=dict(required=True),
+ state=dict(default='present', choices=['present', 'absent'])
+ )
+
+ argument_spec.update(normalize_ib_spec(ib_spec))
+ argument_spec.update(WapiModule.provider_spec)
+
+ module = AnsibleModule(argument_spec=argument_spec,
+ supports_check_mode=True)
+
+ wapi = WapiModule(module)
+ result = wapi.run(NIOS_DTC_MONITOR_SNMP, ib_spec)
+
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_tcp.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_tcp.py
new file mode 100644
index 000000000..e812f13c6
--- /dev/null
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_tcp.py
@@ -0,0 +1,163 @@
+#!/usr/bin/python
+# Copyright (c) 2018-2019 Red Hat, Inc.
+# Copyright (c) 2020 Infoblox, Inc.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+module: nios_dtc_monitor_tcp
+author: "Joachim Buyse (@jbisabel)"
+version_added: "1.6.0"
+short_description: Configure Infoblox NIOS DTC TCP monitors
+description:
+ - Adds and/or removes instances of DTC TCP monitor objects from Infoblox NIOS
+ servers. This module manages C(dtc:monitor:tcp) objects using the Infoblox
+ WAPI interface over REST.
+requirements:
+ - infoblox-client
+extends_documentation_fragment: infoblox.nios_modules.nios
+notes:
+ - This module supports C(check_mode).
+options:
+ name:
+ description:
+ - Configures the display name for this DTC monitor. Values with leading
+ or trailing white space are not valid for this field.
+ required: true
+ type: str
+ port:
+ description:
+ - Configures the port value for TCP requests. The field is required on
+ creation.
+ required: true
+ type: int
+ interval:
+ description:
+ - Configures the interval for TCP health check.
+ type: int
+ default: 5
+ retry_down:
+ description:
+ - Configures the value of how many times the server should appear as
+ down to be treated as dead after it was alive.
+ type: int
+ default: 1
+ retry_up:
+ description:
+ - Configures the value of how many times the server should appear as up
+ to be treated as alive after it was dead.
+ type: int
+ default: 1
+ timeout:
+ description:
+ - Configures the timeout for TCP health check in seconds.
+ type: int
+ default: 15
+ extattrs:
+ description:
+ - Allows for the configuration of Extensible Attributes on the
+ instance of the object. This argument accepts a set of key / value
+ pairs for configuration.
+ type: dict
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ state:
+ description:
+ - Configures the intended state of the instance of the object on
+ the NIOS server. When this value is set to C(present), the object
+ is configured on the device and when this value is set to C(absent)
+ the value is removed (if necessary) from the device.
+ default: present
+ choices:
+ - present
+ - absent
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Configure a DTC TCP monitor
+ infoblox.nios_modules.nios_dtc_monitor_tcp:
+ name: tcp_monitor
+ port: 8080
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Add a comment to an existing DTC TCP monitor
+ infoblox.nios_modules.nios_dtc_monitor_tcp:
+ name: tcp_monitor
+ port: 8080
+ comment: this is a test comment
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Remove a DTC TCP monitor from the system
+ infoblox.nios_modules.nios_dtc_monitor_tcp:
+ name: tcp_monitor
+ port: 8080
+ state: absent
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+'''
+
+RETURN = ''' # '''
+
+from ansible.module_utils.basic import AnsibleModule
+from ..module_utils.api import WapiModule
+from ..module_utils.api import NIOS_DTC_MONITOR_TCP
+from ..module_utils.api import normalize_ib_spec
+
+
+def main():
+ ''' Main entry point for module execution
+ '''
+
+ ib_spec = dict(
+ name=dict(required=True, ib_req=True),
+ port=dict(type='int', required=True, ib_req=True),
+
+ interval=dict(type='int', default=5),
+ retry_down=dict(type='int', default=1),
+ retry_up=dict(type='int', default=1),
+ timeout=dict(type='int', default=15),
+
+ extattrs=dict(type='dict'),
+ comment=dict(),
+ )
+
+ argument_spec = dict(
+ provider=dict(required=True),
+ state=dict(default='present', choices=['present', 'absent'])
+ )
+
+ argument_spec.update(normalize_ib_spec(ib_spec))
+ argument_spec.update(WapiModule.provider_spec)
+
+ module = AnsibleModule(argument_spec=argument_spec,
+ supports_check_mode=True)
+
+ wapi = WapiModule(module)
+ result = wapi.run(NIOS_DTC_MONITOR_TCP, ib_spec)
+
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py
index 422d76f16..82491f62b 100644
--- a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_pool.py
@@ -41,6 +41,12 @@ options:
- TOPOLOGY
required: true
type: str
+ lb_preferred_topology:
+ description:
+ - Configures the topology rules for the C(TOPOLOGY) load balancing method.
+ - Required only when I(lb_preferred_method) is set to C(TOPOLOGY).
+ required: false
+ type: str
servers:
description:
- Configure the DTC Servers related to the pool
@@ -170,9 +176,11 @@ def main():
for server in module.params['servers']:
server_obj = wapi.get_object('dtc:server',
{'name': server['server']})
- if server_obj is not None:
+ if server_obj:
server_list.append({'server': server_obj[0]['_ref'],
'ratio': server['ratio']})
+ else:
+ module.fail_json(msg='Server %s cannot be found.' % server)
return server_list
def monitors_transform(module):
@@ -181,10 +189,23 @@ def main():
for monitor in module.params['monitors']:
monitor_obj = wapi.get_object('dtc:monitor:' + monitor['type'],
{'name': monitor['name']})
- if monitor_obj is not None:
+ if monitor_obj:
monitor_list.append(monitor_obj[0]['_ref'])
+ else:
+ module.fail_json(
+ msg='monitor %s cannot be found.' % monitor)
return monitor_list
+ def topology_transform(module):
+ topology = module.params['lb_preferred_topology']
+ if topology:
+ topo_obj = wapi.get_object('dtc:topology', {'name': topology})
+ if topo_obj:
+ return topo_obj[0]['_ref']
+ else:
+ module.fail_json(
+ msg='topology %s cannot be found.' % topology)
+
servers_spec = dict(
server=dict(required=True),
ratio=dict(type='int', default=1)
@@ -203,6 +224,7 @@ def main():
'RATIO',
'ROUND_ROBIN',
'TOPOLOGY']),
+ lb_preferred_topology=dict(type='str', transform=topology_transform),
servers=dict(type='list', elements='dict', options=servers_spec,
transform=servers_transform),
diff --git a/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_topology.py b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_topology.py
new file mode 100644
index 000000000..eec857256
--- /dev/null
+++ b/ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_topology.py
@@ -0,0 +1,253 @@
+#!/usr/bin/python
+# Copyright (c) 2018-2019 Red Hat, Inc.
+# Copyright (c) 2020 Infoblox, Inc.
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+module: nios_dtc_topology
+author: "Joachim Buyse (@jbisabel)"
+short_description: Configure Infoblox NIOS DTC Topology
+version_added: "1.6.0"
+description:
+ - Adds and/or removes instances of DTC Topology objects from
+ Infoblox NIOS topologies. This module manages NIOS C(dtc:topology) objects
+ using the Infoblox WAPI interface over REST.
+requirements:
+ - infoblox-client
+extends_documentation_fragment: infoblox.nios_modules.nios
+notes:
+ - This module supports C(check_mode).
+options:
+ name:
+ description:
+ - Specifies the DTC Topology display name.
+ required: true
+ type: str
+ rules:
+ description:
+ - Configures the topology rules
+ type: list
+ elements: dict
+ suboptions:
+ dest_type:
+ description:
+ - Configures the type of the destination for this DTC Topology Rule.
+ type: str
+ choices:
+ - POOL
+ - SERVER
+ required: true
+ destination_link:
+ description:
+ - Configures the name of the destination DTC pool or DTC server.
+ type: str
+ return_type:
+ description:
+ - Configures the type of the DNS response for the rule.
+ type: str
+ choices:
+ - NOERR
+ - NXDOMAIN
+ - REGULAR
+ default: REGULAR
+ sources:
+ description:
+ - Configures the conditions for matching sources. Should be empty to
+ set the rule as default destination.
+ type: list
+ elements: dict
+ suboptions:
+ source_op:
+ description:
+ - Configures the operation used to match the value.
+ type: str
+ choices:
+ - IS
+ - IS_NOT
+ source_type:
+ description:
+ - Configures the source type.
+ type: str
+ choices:
+ - CITY
+ - CONTINENT
+ - COUNTRY
+ - EA0
+ - EA1
+ - EA2
+ - EA3
+ - SUBDIVISION
+ - SUBNET
+ required: true
+ source_value:
+ description:
+ - Configures the source value.
+ type: str
+ required: true
+ extattrs:
+ description:
+ - Allows for the configuration of Extensible Attributes on the
+ instance of the object. This argument accepts a set of key / value
+ pairs for configuration.
+ type: dict
+ comment:
+ description:
+ - Configures a text string comment to be associated with the instance
+ of this object. The provided text string will be configured on the
+ object instance.
+ type: str
+ state:
+ description:
+ - Configures the intended state of the instance of the object on
+ the NIOS topology. When this value is set to C(present), the object
+ is configured on the device and when this value is set to C(absent)
+ the value is removed (if necessary) from the device.
+ default: present
+ choices:
+ - present
+ - absent
+ type: str
+'''
+
+EXAMPLES = '''
+- name: Configure a DTC Topology
+ infoblox.nios_modules.nios_dtc_topology:
+ name: a_topology
+ rules:
+ - dest_type: POOL
+ destination_link: web_pool1
+ return_type: REGULAR
+ sources:
+ - source_op: IS
+ source_type: EA0
+ source_value: DC1
+ - dest_type: POOL
+ destination_link: web_pool2
+ return_type: REGULAR
+ sources:
+ - source_op: IS
+ source_type: EA0
+ source_value: DC2
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Add a comment to a DTC topology
+ infoblox.nios_modules.nios_dtc_topology:
+ name: a_topology
+ comment: this is a test comment
+ state: present
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+
+- name: Remove a DTC Topology from the system
+ infoblox.nios_modules.nios_dtc_topology:
+ name: a_topology
+ state: absent
+ provider:
+ host: "{{ inventory_hostname_short }}"
+ username: admin
+ password: admin
+ connection: local
+'''
+
+RETURN = ''' # '''
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.six import iteritems
+from ..module_utils.api import WapiModule
+from ..module_utils.api import NIOS_DTC_TOPOLOGY
+from ..module_utils.api import normalize_ib_spec
+
+
+def main():
+ ''' Main entry point for module execution
+ '''
+
+ def sources_transform(sources, module):
+ source_list = list()
+ for source in sources:
+ src = dict([(k, v) for k, v in iteritems(source) if v is not None])
+ if 'source_type' not in src or 'source_value' not in src:
+ module.fail_json(msg='source_type and source_value are required for source')
+ source_list.append(src)
+ return source_list
+
+ def rules_transform(module):
+ rule_list = list()
+ dest_obj = None
+
+ if not module.params['rules']:
+ return rule_list
+
+ for rule in module.params['rules']:
+ if rule['dest_type'] == 'POOL':
+ dest_obj = wapi.get_object('dtc:pool', {'name': rule['destination_link']})
+ else:
+ dest_obj = wapi.get_object('dtc:server', {'name': rule['destination_link']})
+ if not dest_obj and rule['return_type'] == 'REGULAR':
+ module.fail_json(msg='destination_link %s does not exist' % rule['destination_link'])
+
+ tf_rule = dict(
+ dest_type=rule['dest_type'],
+ destination_link=dest_obj[0]['_ref'] if dest_obj else None,
+ return_type=rule['return_type']
+ )
+
+ if rule['sources']:
+ tf_rule['sources'] = sources_transform(rule['sources'], module)
+
+ rule_list.append(tf_rule)
+ return rule_list
+
+ source_spec = dict(
+ source_op=dict(choices=['IS', 'IS_NOT']),
+ source_type=dict(required=True, choices=['CITY', 'CONTINENT', 'COUNTRY', 'EA0', 'EA1', 'EA2', 'EA3', 'SUBDIVISION', 'SUBNET']),
+ source_value=dict(required=True, type='str')
+ )
+
+ rule_spec = dict(
+ dest_type=dict(required=True, choices=['POOL', 'SERVER']),
+ destination_link=dict(type='str'),
+ return_type=dict(default='REGULAR', choices=['NOERR', 'NXDOMAIN', 'REGULAR']),
+ sources=dict(type='list', elements='dict', options=source_spec)
+ )
+
+ ib_spec = dict(
+ name=dict(required=True, ib_req=True),
+
+ rules=dict(type='list', elements='dict', options=rule_spec, transform=rules_transform),
+
+ extattrs=dict(type='dict'),
+ comment=dict(),
+ )
+
+ argument_spec = dict(
+ provider=dict(required=True),
+ state=dict(default='present', choices=['present', 'absent'])
+ )
+
+ argument_spec.update(normalize_ib_spec(ib_spec))
+ argument_spec.update(WapiModule.provider_spec)
+
+ module = AnsibleModule(argument_spec=argument_spec,
+ supports_check_mode=True)
+
+ wapi = WapiModule(module)
+ result = wapi.run(NIOS_DTC_TOPOLOGY, ib_spec)
+
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()