Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_wanopt_profile.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_wanopt_profile
15 short_description: Configure WAN optimization profiles.
16 version_added: "1.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 wanopt_profile:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 auth_group:
34 aliases: ['auth-group']
35 type: str
36 description: Optionally add an authentication group to restrict access to the WAN Optimization tunnel to peers in the authentication group.
37 comments:
38 type: str
39 description: Comment.
40 name:
41 type: str
42 description: Profile name.
43 required: true
44 transparent:
45 type: str
46 description: Enable/disable transparent mode.
47 choices: ['disable', 'enable']
48 cifs:
49 type: dict
50 description: Cifs.
51 suboptions:
52 byte_caching:
53 aliases: ['byte-caching']
54 type: str
55 description: Enable/disable byte-caching.
56 choices: ['disable', 'enable']
57 log_traffic:
58 aliases: ['log-traffic']
59 type: str
60 description: Enable/disable logging.
61 choices: ['disable', 'enable']
62 prefer_chunking:
63 aliases: ['prefer-chunking']
64 type: str
65 description: Select dynamic or fixed-size data chunking for WAN Optimization.
66 choices: ['dynamic', 'fix']
67 protocol_opt:
68 aliases: ['protocol-opt']
69 type: str
70 description: Select Protocol specific optimitation or generic TCP optimization.
71 choices: ['protocol', 'tcp']
72 secure_tunnel:
73 aliases: ['secure-tunnel']
74 type: str
75 description: Enable/disable securing the WAN Opt tunnel using SSL.
76 choices: ['disable', 'enable']
77 status:
78 type: str
79 description: Enable/disable WAN Optimization.
80 choices: ['disable', 'enable']
81 tunnel_sharing:
82 aliases: ['tunnel-sharing']
83 type: str
84 description: Tunnel sharing mode for aggressive/non-aggressive and/or interactive/non-interactive protocols.
85 choices: ['private', 'shared', 'express-shared']
86 port:
87 type: raw
88 description: (list) Single port number or port number range for CIFS.
89 ftp:
90 type: dict
91 description: Ftp.
92 suboptions:
93 byte_caching:
94 aliases: ['byte-caching']
95 type: str
96 description: Enable/disable byte-caching.
97 choices: ['disable', 'enable']
98 log_traffic:
99 aliases: ['log-traffic']
100 type: str
101 description: Enable/disable logging.
102 choices: ['disable', 'enable']
103 prefer_chunking:
104 aliases: ['prefer-chunking']
105 type: str
106 description: Select dynamic or fixed-size data chunking for WAN Optimization.
107 choices: ['dynamic', 'fix']
108 protocol_opt:
109 aliases: ['protocol-opt']
110 type: str
111 description: Select Protocol specific optimitation or generic TCP optimization.
112 choices: ['protocol', 'tcp']
113 secure_tunnel:
114 aliases: ['secure-tunnel']
115 type: str
116 description: Enable/disable securing the WAN Opt tunnel using SSL.
117 choices: ['disable', 'enable']
118 ssl:
119 type: str
120 description: Enable/disable SSL/TLS offloading
121 choices: ['disable', 'enable']
122 status:
123 type: str
124 description: Enable/disable WAN Optimization.
125 choices: ['disable', 'enable']
126 tunnel_sharing:
127 aliases: ['tunnel-sharing']
128 type: str
129 description: Tunnel sharing mode for aggressive/non-aggressive and/or interactive/non-interactive protocols.
130 choices: ['private', 'shared', 'express-shared']
131 port:
132 type: raw
133 description: (list) Single port number or port number range for FTP.
134 http:
135 type: dict
136 description: Http.
137 suboptions:
138 byte_caching:
139 aliases: ['byte-caching']
140 type: str
141 description: Enable/disable byte-caching.
142 choices: ['disable', 'enable']
143 log_traffic:
144 aliases: ['log-traffic']
145 type: str
146 description: Enable/disable logging.
147 choices: ['disable', 'enable']
148 prefer_chunking:
149 aliases: ['prefer-chunking']
150 type: str
151 description: Select dynamic or fixed-size data chunking for WAN Optimization.
152 choices: ['dynamic', 'fix']
153 protocol_opt:
154 aliases: ['protocol-opt']
155 type: str
156 description: Select Protocol specific optimitation or generic TCP optimization.
157 choices: ['protocol', 'tcp']
158 secure_tunnel:
159 aliases: ['secure-tunnel']
160 type: str
161 description: Enable/disable securing the WAN Opt tunnel using SSL.
162 choices: ['disable', 'enable']
163 ssl:
164 type: str
165 description: Enable/disable SSL/TLS offloading
166 choices: ['disable', 'enable']
167 status:
168 type: str
169 description: Enable/disable WAN Optimization.
170 choices: ['disable', 'enable']
171 tunnel_sharing:
172 aliases: ['tunnel-sharing']
173 type: str
174 description: Tunnel sharing mode for aggressive/non-aggressive and/or interactive/non-interactive protocols.
175 choices: ['private', 'shared', 'express-shared']
176 tunnel_non_http:
177 aliases: ['tunnel-non-http']
178 type: str
179 description: Configure how to process non-HTTP traffic when a profile configured for HTTP traffic accepts a non-HTTP session.
180 choices: ['disable', 'enable']
181 unknown_http_version:
182 aliases: ['unknown-http-version']
183 type: str
184 description: How to handle HTTP sessions that do not comply with HTTP 0.
185 choices: ['best-effort', 'reject', 'tunnel']
186 port:
187 type: raw
188 description: (list) Single port number or port number range for HTTP.
189 ssl_port:
190 aliases: ['ssl-port']
191 type: raw
192 description: (list) Port on which to expect HTTPS traffic for SSL/TLS offloading.
193 mapi:
194 type: dict
195 description: Mapi.
196 suboptions:
197 byte_caching:
198 aliases: ['byte-caching']
199 type: str
200 description: Enable/disable byte-caching.
201 choices: ['disable', 'enable']
202 log_traffic:
203 aliases: ['log-traffic']
204 type: str
205 description: Enable/disable logging.
206 choices: ['disable', 'enable']
207 secure_tunnel:
208 aliases: ['secure-tunnel']
209 type: str
210 description: Enable/disable securing the WAN Opt tunnel using SSL.
211 choices: ['disable', 'enable']
212 status:
213 type: str
214 description: Enable/disable WAN Optimization.
215 choices: ['disable', 'enable']
216 tunnel_sharing:
217 aliases: ['tunnel-sharing']
218 type: str
219 description: Tunnel sharing mode for aggressive/non-aggressive and/or interactive/non-interactive protocols.
220 choices: ['private', 'shared', 'express-shared']
221 port:
222 type: raw
223 description: (list) Single port number or port number range for MAPI.
224 tcp:
225 type: dict
226 description: Tcp.
227 suboptions:
228 byte_caching:
229 aliases: ['byte-caching']
230 type: str
231 description: Enable/disable byte-caching.
232 choices: ['disable', 'enable']
233 byte_caching_opt:
234 aliases: ['byte-caching-opt']
235 type: str
236 description: Select whether TCP byte-caching uses system memory only or both memory and disk space.
237 choices: ['mem-only', 'mem-disk']
238 log_traffic:
239 aliases: ['log-traffic']
240 type: str
241 description: Enable/disable logging.
242 choices: ['disable', 'enable']
243 port:
244 type: str
245 description: Port numbers or port number ranges for TCP.
246 secure_tunnel:
247 aliases: ['secure-tunnel']
248 type: str
249 description: Enable/disable securing the WAN Opt tunnel using SSL.
250 choices: ['disable', 'enable']
251 ssl:
252 type: str
253 description: Enable/disable SSL/TLS offloading
254 choices: ['disable', 'enable']
255 ssl_port:
256 aliases: ['ssl-port']
257 type: raw
258 description: (list) Port numbers or port number ranges on which to expect HTTPS traffic for SSL/TLS offloading.
259 status:
260 type: str
261 description: Enable/disable WAN Optimization.
262 choices: ['disable', 'enable']
263 tunnel_sharing:
264 aliases: ['tunnel-sharing']
265 type: str
266 description: Tunnel sharing mode for aggressive/non-aggressive and/or interactive/non-interactive protocols.
267 choices: ['private', 'shared', 'express-shared']
268 '''
269
270 EXAMPLES = '''
271 - name: Example playbook (generated based on argument schema)
272 hosts: fortimanagers
273 connection: httpapi
274 gather_facts: false
275 tasks:
276 - name: Configure WAN optimization profiles.
277 fortinet.fortimanager.fmgr_wanopt_profile:
278 # workspace_locking_adom: <global or your adom name>
279 adom: <your own value>
280 state: present # <value in [present, absent]>
281 wanopt_profile:
282 name: "your value" # Required variable, string
283 # auth_group: <string>
284 # comments: <string>
285 # transparent: <value in [disable, enable]>
286 # cifs:
287 # byte_caching: <value in [disable, enable]>
288 # log_traffic: <value in [disable, enable]>
289 # prefer_chunking: <value in [dynamic, fix]>
290 # protocol_opt: <value in [protocol, tcp]>
291 # secure_tunnel: <value in [disable, enable]>
292 # status: <value in [disable, enable]>
293 # tunnel_sharing: <value in [private, shared, express-shared]>
294 # port: <list or integer>
295 # ftp:
296 # byte_caching: <value in [disable, enable]>
297 # log_traffic: <value in [disable, enable]>
298 # prefer_chunking: <value in [dynamic, fix]>
299 # protocol_opt: <value in [protocol, tcp]>
300 # secure_tunnel: <value in [disable, enable]>
301 # ssl: <value in [disable, enable]>
302 # status: <value in [disable, enable]>
303 # tunnel_sharing: <value in [private, shared, express-shared]>
304 # port: <list or integer>
305 # http:
306 # byte_caching: <value in [disable, enable]>
307 # log_traffic: <value in [disable, enable]>
308 # prefer_chunking: <value in [dynamic, fix]>
309 # protocol_opt: <value in [protocol, tcp]>
310 # secure_tunnel: <value in [disable, enable]>
311 # ssl: <value in [disable, enable]>
312 # status: <value in [disable, enable]>
313 # tunnel_sharing: <value in [private, shared, express-shared]>
314 # tunnel_non_http: <value in [disable, enable]>
315 # unknown_http_version: <value in [best-effort, reject, tunnel]>
316 # port: <list or integer>
317 # ssl_port: <list or integer>
318 # mapi:
319 # byte_caching: <value in [disable, enable]>
320 # log_traffic: <value in [disable, enable]>
321 # secure_tunnel: <value in [disable, enable]>
322 # status: <value in [disable, enable]>
323 # tunnel_sharing: <value in [private, shared, express-shared]>
324 # port: <list or integer>
325 # tcp:
326 # byte_caching: <value in [disable, enable]>
327 # byte_caching_opt: <value in [mem-only, mem-disk]>
328 # log_traffic: <value in [disable, enable]>
329 # port: <string>
330 # secure_tunnel: <value in [disable, enable]>
331 # ssl: <value in [disable, enable]>
332 # ssl_port: <list or integer>
333 # status: <value in [disable, enable]>
334 # tunnel_sharing: <value in [private, shared, express-shared]>
335 '''
336
337 RETURN = '''
338 meta:
339 description: The result of the request.
340 type: dict
341 returned: always
342 contains:
343 request_url:
344 description: The full url requested.
345 returned: always
346 type: str
347 sample: /sys/login/user
348 response_code:
349 description: The status of api request.
350 returned: always
351 type: int
352 sample: 0
353 response_data:
354 description: The api response.
355 type: list
356 returned: always
357 response_message:
358 description: The descriptive message of the api response.
359 type: str
360 returned: always
361 sample: OK.
362 system_information:
363 description: The information of the target system.
364 type: dict
365 returned: always
366 rc:
367 description: The status the request.
368 type: int
369 returned: always
370 sample: 0
371 version_check_warning:
372 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
373 type: list
374 returned: complex
375 '''
376 from ansible.module_utils.basic import AnsibleModule
377 from ansible.module_utils.connection import Connection
378 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
379 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
380
381
382 def main():
383 urls_list = [
384 '/pm/config/adom/{adom}/obj/wanopt/profile',
385 '/pm/config/global/obj/wanopt/profile'
386 ]
387 module_arg_spec = {
388 'adom': {'required': True, 'type': 'str'},
389 'revision_note': {'type': 'str'},
390 'wanopt_profile': {
391 'type': 'dict', 'v_range': [['6.0.0', '']],
392 'options': {
393 'auth-group': {'type': 'str'},
394 'comments': {'type': 'str'},
395 'name': {'required': True, 'type': 'str'},
396 'transparent': {'choices': ['disable', 'enable'], 'type': 'str'},
397 'cifs': {
398 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
399 'type': 'dict',
400 'options': {
401 'byte-caching': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
402 'log-traffic': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
403 'prefer-chunking': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['dynamic', 'fix'], 'type': 'str'},
404 'protocol-opt': {'v_range': [['6.4.5', '']], 'choices': ['protocol', 'tcp'], 'type': 'str'},
405 'secure-tunnel': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
406 'status': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
407 'tunnel-sharing': {
408 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
409 'choices': ['private', 'shared', 'express-shared'],
410 'type': 'str'
411 },
412 'port': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'raw'}
413 }
414 },
415 'ftp': {
416 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
417 'type': 'dict',
418 'options': {
419 'byte-caching': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
420 'log-traffic': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
421 'prefer-chunking': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['dynamic', 'fix'], 'type': 'str'},
422 'protocol-opt': {'v_range': [['6.4.5', '']], 'choices': ['protocol', 'tcp'], 'type': 'str'},
423 'secure-tunnel': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
424 'ssl': {'v_range': [['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
425 'status': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
426 'tunnel-sharing': {
427 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
428 'choices': ['private', 'shared', 'express-shared'],
429 'type': 'str'
430 },
431 'port': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'raw'}
432 }
433 },
434 'http': {
435 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
436 'type': 'dict',
437 'options': {
438 'byte-caching': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
439 'log-traffic': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
440 'prefer-chunking': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['dynamic', 'fix'], 'type': 'str'},
441 'protocol-opt': {'v_range': [['6.4.5', '']], 'choices': ['protocol', 'tcp'], 'type': 'str'},
442 'secure-tunnel': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
443 'ssl': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
444 'status': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
445 'tunnel-sharing': {
446 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
447 'choices': ['private', 'shared', 'express-shared'],
448 'type': 'str'
449 },
450 'tunnel-non-http': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
451 'unknown-http-version': {
452 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']],
453 'choices': ['best-effort', 'reject', 'tunnel'],
454 'type': 'str'
455 },
456 'port': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'raw'},
457 'ssl-port': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'raw'}
458 }
459 },
460 'mapi': {
461 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
462 'type': 'dict',
463 'options': {
464 'byte-caching': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
465 'log-traffic': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
466 'secure-tunnel': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
467 'status': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
468 'tunnel-sharing': {
469 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
470 'choices': ['private', 'shared', 'express-shared'],
471 'type': 'str'
472 },
473 'port': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '7.6.2']], 'type': 'raw'}
474 }
475 },
476 'tcp': {
477 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
478 'type': 'dict',
479 'options': {
480 'byte-caching': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
481 'byte-caching-opt': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['mem-only', 'mem-disk'], 'type': 'str'},
482 'log-traffic': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
483 'port': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'type': 'str'},
484 'secure-tunnel': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
485 'ssl': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
486 'ssl-port': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'type': 'raw'},
487 'status': {'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
488 'tunnel-sharing': {
489 'v_range': [['6.2.8', '6.2.13'], ['6.4.5', '']],
490 'choices': ['private', 'shared', 'express-shared'],
491 'type': 'str'
492 }
493 }
494 }
495 }
496 }
497 }
498
499 module_option_spec = get_module_arg_spec('full crud')
500 module_arg_spec.update(module_option_spec)
501 check_galaxy_version(module_arg_spec)
502 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'wanopt_profile'),
503 supports_check_mode=True)
504 if not module._socket_path:
505 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
506 connection = Connection(module._socket_path)
507 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
508 'name', 'data', module, connection)
509 fmgr.process_crud()
510 module.exit_json(meta=module.params)
511
512
513 if __name__ == '__main__':
514 main()