Debian Codegraph @

ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_http.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_http
12 author: "Joachim Buyse (@jbisabel)"
13 version_added: "1.6.0"
14 short_description: Configure Infoblox NIOS DTC HTTP monitors
15 description:
16 - Adds and/or removes instances of DTC HTTP monitor objects from Infoblox NIOS
17 servers. This module manages C(dtc:monitor:http) 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 HTTP requests.
34 type: int
35 default: 80
36 ciphers:
37 description:
38 - Configures an optional cipher list for the secure HTTP/S connection.
39 type: str
40 client_cert:
41 description:
42 - Configures an optional client certificate, supplied in a secure HTTP/S
43 mode if present.
44 type: str
45 content_check:
46 description:
47 - Configures the content check type
48 type: str
49 choices:
50 - EXTRACT
51 - MATCH
52 - NONE
53 default: NONE
54 content_check_input:
55 description:
56 - Configures the portion of the response to use as input for content check.
57 type: str
58 choices:
59 - ALL
60 - BODY
61 - HEADERS
62 default: ALL
63 content_check_op:
64 description:
65 - Configures the content check success criteria operator.
66 type: str
67 choices:
68 - EQ
69 - GEQ
70 - LEQ
71 - NEQ
72 content_check_regex:
73 description:
74 - Configures the content check regular expression. Values with leading
75 or trailing white space are not valid for this field.
76 type: str
77 content_extract_group:
78 description:
79 - Configures the content extraction sub-expression to extract.
80 type: int
81 default: 0
82 content_extract_type:
83 description:
84 - Configures the content extraction expected type for the extracted data.
85 type: str
86 choices:
87 - INTEGER
88 - STRING
89 default: STRING
90 content_extract_value:
91 description:
92 - Configures the content extraction value to compare with the extracted
93 result. Values with leading or trailing white space are not valid for
94 this field.
95 type: str
96 request:
97 description:
98 - Configures the HTTP request to send
99 type: str
100 default: GET /
101 result:
102 description:
103 - Configures the type of the expected result
104 type: str
105 choices:
106 - ANY
107 - CODE_IS
108 - CODE_IS_NOT
109 default: ANY
110 result_code:
111 description:
112 - Configures the expected return code
113 type: int
114 default: 200
115 enable_sni:
116 description:
117 - Configures whether or not Server Name Indication (SNI) for the HTTPS
118 monitor is enabled.
119 type: bool
120 default: false
121 secure:
122 description:
123 - Configures the security status of the connection.
124 type: bool
125 default: false
126 validate_cert:
127 description:
128 - Configures whether the validation of the remote server's certificate is
129 enabled.
130 type: bool
131 default: true
132 interval:
133 description:
134 - Configures the interval for HTTP health check.
135 type: int
136 default: 5
137 retry_down:
138 description:
139 - Configures the value of how many times the server should appear as
140 down to be treated as dead after it was alive.
141 type: int
142 default: 1
143 retry_up:
144 description:
145 - Configures the value of how many times the server should appear as up
146 to be treated as alive after it was dead.
147 type: int
148 default: 1
149 timeout:
150 description:
151 - Configures the timeout for HTTP health check in seconds.
152 type: int
153 default: 15
154 extattrs:
155 description:
156 - Allows for the configuration of Extensible Attributes on the
157 instance of the object. This argument accepts a set of key / value
158 pairs for configuration.
159 type: dict
160 comment:
161 description:
162 - Configures a text string comment to be associated with the instance
163 of this object. The provided text string will be configured on the
164 object instance.
165 type: str
166 state:
167 description:
168 - Configures the intended state of the instance of the object on
169 the NIOS server. When this value is set to C(present), the object
170 is configured on the device and when this value is set to C(absent)
171 the value is removed (if necessary) from the device.
172 default: present
173 choices:
174 - present
175 - absent
176 type: str
177 '''
178
179 EXAMPLES = '''
180 - name: Configure a DTC HTTPS monitor
181 infoblox.nios_modules.nios_dtc_monitor_http:
182 name: https_monitor
183 port: 443
184 secure: true
185 state: present
186 provider:
187 host: "{{ inventory_hostname_short }}"
188 username: admin
189 password: admin
190 connection: local
191
192 - name: Add a comment to an existing DTC HTTPS monitor
193 infoblox.nios_modules.nios_dtc_monitor_http:
194 name: https_monitor
195 comment: this is a test comment
196 state: present
197 provider:
198 host: "{{ inventory_hostname_short }}"
199 username: admin
200 password: admin
201 connection: local
202
203 - name: Remove a DTC HTTPS monitor from the system
204 infoblox.nios_modules.nios_dtc_monitor_http:
205 name: https_monitor
206 state: absent
207 provider:
208 host: "{{ inventory_hostname_short }}"
209 username: admin
210 password: admin
211 connection: local
212 '''
213
214 RETURN = ''' # '''
215
216 from ansible.module_utils.basic import AnsibleModule
217 from ..module_utils.api import WapiModule
218 from ..module_utils.api import NIOS_DTC_MONITOR_HTTP
219 from ..module_utils.api import normalize_ib_spec
220
221
222 def main():
223 ''' Main entry point for module execution
224 '''
225
226 ib_spec = dict(
227 name=dict(required=True, ib_req=True),
228
229 port=dict(type='int', default=80),
230 ciphers=dict(type='str'),
231 client_cert=dict(type='str'),
232 content_check=dict(default='NONE', choices=['EXTRACT', 'MATCH', 'NONE']),
233 content_check_input=dict(default='ALL', choices=['ALL', 'BODY', 'HEADERS']),
234 content_check_op=dict(choices=['EQ', 'GEQ', 'LEQ', 'NEQ']),
235 content_check_regex=dict(type='str'),
236 content_extract_group=dict(type='int', default=0),
237 content_extract_type=dict(default='STRING', choices=['INTEGER', 'STRING']),
238 content_extract_value=dict(type='str'),
239 request=dict(type='str', default='GET /'),
240 result=dict(default='ANY', choices=['ANY', 'CODE_IS', 'CODE_IS_NOT']),
241 result_code=dict(type='int', default=200),
242 enable_sni=dict(type='bool', default=False),
243 secure=dict(type='bool', default=False),
244 validate_cert=dict(type='bool', default=True),
245 interval=dict(type='int', default=5),
246 retry_down=dict(type='int', default=1),
247 retry_up=dict(type='int', default=1),
248 timeout=dict(type='int', default=15),
249
250 extattrs=dict(type='dict'),
251 comment=dict(),
252 )
253
254 argument_spec = dict(
255 provider=dict(required=True),
256 state=dict(default='present', choices=['present', 'absent'])
257 )
258
259 argument_spec.update(normalize_ib_spec(ib_spec))
260 argument_spec.update(WapiModule.provider_spec)
261
262 module = AnsibleModule(argument_spec=argument_spec,
263 supports_check_mode=True)
264
265 wapi = WapiModule(module)
266 result = wapi.run(NIOS_DTC_MONITOR_HTTP, ib_spec)
267
268 module.exit_json(**result)
269
270
271 if __name__ == '__main__':
272 main()