Debian Codegraph @

ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_tcp.py

raw symbols SCIP
1 #!/usr/bin/python
2 # Copyright (c) 2018-2019 Red Hat, Inc.
3 # Copyright (c) 2020 Infoblox, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import absolute_import, division, print_function
7 __metaclass__ = type
8
9 DOCUMENTATION = '''
10 ---
11 module: nios_dtc_monitor_tcp
12 author: "Joachim Buyse (@jbisabel)"
13 version_added: "1.6.0"
14 short_description: Configure Infoblox NIOS DTC TCP monitors
15 description:
16 - Adds and/or removes instances of DTC TCP monitor objects from Infoblox NIOS
17 servers. This module manages C(dtc:monitor:tcp) objects using the Infoblox
18 WAPI interface over REST.
19 requirements:
20 - infoblox-client
21 extends_documentation_fragment: infoblox.nios_modules.nios
22 notes:
23 - This module supports C(check_mode).
24 options:
25 name:
26 description:
27 - Configures the display name for this DTC monitor. Values with leading
28 or trailing white space are not valid for this field.
29 required: true
30 type: str
31 port:
32 description:
33 - Configures the port value for TCP requests. The field is required on
34 creation.
35 required: true
36 type: int
37 interval:
38 description:
39 - Configures the interval for TCP health check.
40 type: int
41 default: 5
42 retry_down:
43 description:
44 - Configures the value of how many times the server should appear as
45 down to be treated as dead after it was alive.
46 type: int
47 default: 1
48 retry_up:
49 description:
50 - Configures the value of how many times the server should appear as up
51 to be treated as alive after it was dead.
52 type: int
53 default: 1
54 timeout:
55 description:
56 - Configures the timeout for TCP health check in seconds.
57 type: int
58 default: 15
59 extattrs:
60 description:
61 - Allows for the configuration of Extensible Attributes on the
62 instance of the object. This argument accepts a set of key / value
63 pairs for configuration.
64 type: dict
65 comment:
66 description:
67 - Configures a text string comment to be associated with the instance
68 of this object. The provided text string will be configured on the
69 object instance.
70 type: str
71 state:
72 description:
73 - Configures the intended state of the instance of the object on
74 the NIOS server. When this value is set to C(present), the object
75 is configured on the device and when this value is set to C(absent)
76 the value is removed (if necessary) from the device.
77 default: present
78 choices:
79 - present
80 - absent
81 type: str
82 '''
83
84 EXAMPLES = '''
85 - name: Configure a DTC TCP monitor
86 infoblox.nios_modules.nios_dtc_monitor_tcp:
87 name: tcp_monitor
88 port: 8080
89 state: present
90 provider:
91 host: "{{ inventory_hostname_short }}"
92 username: admin
93 password: admin
94 connection: local
95
96 - name: Add a comment to an existing DTC TCP monitor
97 infoblox.nios_modules.nios_dtc_monitor_tcp:
98 name: tcp_monitor
99 port: 8080
100 comment: this is a test comment
101 state: present
102 provider:
103 host: "{{ inventory_hostname_short }}"
104 username: admin
105 password: admin
106 connection: local
107
108 - name: Remove a DTC TCP monitor from the system
109 infoblox.nios_modules.nios_dtc_monitor_tcp:
110 name: tcp_monitor
111 port: 8080
112 state: absent
113 provider:
114 host: "{{ inventory_hostname_short }}"
115 username: admin
116 password: admin
117 connection: local
118 '''
119
120 RETURN = ''' # '''
121
122 from ansible.module_utils.basic import AnsibleModule
123 from ..module_utils.api import WapiModule
124 from ..module_utils.api import NIOS_DTC_MONITOR_TCP
125 from ..module_utils.api import normalize_ib_spec
126
127
128 def main():
129 ''' Main entry point for module execution
130 '''
131
132 ib_spec = dict(
133 name=dict(required=True, ib_req=True),
134 port=dict(type='int', required=True, ib_req=True),
135
136 interval=dict(type='int', default=5),
137 retry_down=dict(type='int', default=1),
138 retry_up=dict(type='int', default=1),
139 timeout=dict(type='int', default=15),
140
141 extattrs=dict(type='dict'),
142 comment=dict(),
143 )
144
145 argument_spec = dict(
146 provider=dict(required=True),
147 state=dict(default='present', choices=['present', 'absent'])
148 )
149
150 argument_spec.update(normalize_ib_spec(ib_spec))
151 argument_spec.update(WapiModule.provider_spec)
152
153 module = AnsibleModule(argument_spec=argument_spec,
154 supports_check_mode=True)
155
156 wapi = WapiModule(module)
157 result = wapi.run(NIOS_DTC_MONITOR_TCP, ib_spec)
158
159 module.exit_json(**result)
160
161
162 if __name__ == '__main__':
163 main()