Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_sql.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_system_sql
15 short_description: SQL settings.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_crud
20 options:
21 system_sql:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 background_rebuild:
27 aliases: ['background-rebuild']
28 type: str
29 description:
30 - Disable/Enable rebuild SQL database in the background.
31 - disable - Rebuild SQL database not in the background.
32 - enable - Rebuild SQL database in the background.
33 choices: ['disable', 'enable']
34 custom_index:
35 aliases: ['custom-index']
36 type: list
37 elements: dict
38 description: Custom index.
39 suboptions:
40 case_sensitive:
41 aliases: ['case-sensitive']
42 type: str
43 description:
44 - Disable/Enable case sensitive index.
45 - disable - Build a case insensitive index.
46 - enable - Build a case sensitive index.
47 choices: ['disable', 'enable']
48 device_type:
49 aliases: ['device-type']
50 type: str
51 description:
52 - Device type.
53 - FortiGate - Device type to FortiGate.
54 - FortiManager - Set device type to FortiManager
55 - FortiClient - Set device type to FortiClient
56 - FortiMail - Device type to FortiMail.
57 - FortiWeb - Device type to FortiWeb.
58 - FortiCache - Set device type to FortiCache
59 - FortiSandbox - Set device type to FortiSandbox
60 - FortiDDoS - Set device type to FortiDDoS
61 - FortiAuthenticator - Set device type to FortiAuthenticator
62 - FortiProxy - Set device type to FortiProxy
63 choices: ['FortiGate', 'FortiManager', 'FortiClient', 'FortiMail',
64 'FortiWeb', 'FortiCache', 'FortiSandbox', 'FortiDDoS',
65 'FortiAuthenticator', 'FortiProxy']
66 id:
67 type: int
68 description: Add or Edit log index fields.
69 index_field:
70 aliases: ['index-field']
71 type: str
72 description: Log field name to be indexed.
73 log_type:
74 aliases: ['log-type']
75 type: str
76 description:
77 - Log type.
78 - none - none
79 - app-ctrl
80 - attack
81 - content
82 - dlp
83 - emailfilter
84 - event
85 - generic
86 - history
87 - traffic
88 - virus
89 - voip
90 - webfilter
91 - netscan
92 - fct-event
93 - fct-traffic
94 - fct-netscan
95 - waf
96 - gtp
97 - dns
98 - ssh
99 - ssl
100 choices: ['none', 'app-ctrl', 'attack', 'content', 'dlp', 'emailfilter',
101 'event', 'generic', 'history', 'traffic', 'virus', 'voip',
102 'webfilter', 'netscan', 'fct-event', 'fct-traffic',
103 'fct-netscan', 'waf', 'gtp', 'dns', 'ssh', 'ssl', 'file-filter',
104 'asset', 'protocol', 'siem', 'ztna', 'security']
105 database_name:
106 aliases: ['database-name']
107 type: str
108 description: Database name.
109 database_type:
110 aliases: ['database-type']
111 type: str
112 description:
113 - Database type.
114 - mysql - MySQL database.
115 - postgres - PostgreSQL local database.
116 choices: ['mysql', 'postgres']
117 device_count_high:
118 aliases: ['device-count-high']
119 type: str
120 description:
121 - Must set to enable if the count of registered devices is greater than 8000.
122 - disable - Set to disable if device count is less than 8000.
123 - enable - Set to enable if device count is equal to or greater than 8000.
124 choices: ['disable', 'enable']
125 event_table_partition_time:
126 aliases: ['event-table-partition-time']
127 type: int
128 description: Maximum SQL database table partitioning time range in minute
129 fct_table_partition_time:
130 aliases: ['fct-table-partition-time']
131 type: int
132 description: Maximum SQL database table partitioning time range in minute
133 logtype:
134 type: list
135 elements: str
136 description:
137 - Log type.
138 - none - None.
139 - app-ctrl
140 - attack
141 - content
142 - dlp
143 - emailfilter
144 - event
145 - generic
146 - history
147 - traffic
148 - virus
149 - voip
150 - webfilter
151 - netscan
152 - fct-event
153 - fct-traffic
154 - fct-netscan
155 - waf
156 - gtp
157 - dns
158 - ssh
159 - ssl
160 choices: ['none', 'app-ctrl', 'attack', 'content', 'dlp', 'emailfilter', 'event',
161 'generic', 'history', 'traffic', 'virus', 'voip', 'webfilter',
162 'netscan', 'fct-event', 'fct-traffic', 'fct-netscan', 'waf', 'gtp',
163 'dns', 'ssh', 'ssl', 'file-filter', 'asset', 'protocol', 'siem', 'ztna',
164 'security']
165 password:
166 type: raw
167 description: (list) Password for login remote database.
168 prompt_sql_upgrade:
169 aliases: ['prompt-sql-upgrade']
170 type: str
171 description:
172 - Prompt to convert log database into SQL database at start time on GUI.
173 - disable - Do not prompt to upgrade log database to SQL database at start time on GUI.
174 - enable - Prompt to upgrade log database to SQL database at start time on GUI.
175 choices: ['disable', 'enable']
176 rebuild_event:
177 aliases: ['rebuild-event']
178 type: str
179 description:
180 - Disable/Enable rebuild event during SQL database rebuilding.
181 - disable - Do not rebuild event during SQL database rebuilding.
182 - enable - Rebuild event during SQL database rebuilding.
183 choices: ['disable', 'enable']
184 rebuild_event_start_time:
185 aliases: ['rebuild-event-start-time']
186 type: raw
187 description: (list) Rebuild event starting date and time
188 server:
189 type: str
190 description: Database IP or hostname.
191 start_time:
192 aliases: ['start-time']
193 type: raw
194 description: (list) Start date and time
195 status:
196 type: str
197 description:
198 - SQL database status.
199 - disable - Disable SQL database.
200 - local - Enable local database.
201 choices: ['disable', 'local']
202 text_search_index:
203 aliases: ['text-search-index']
204 type: str
205 description:
206 - Disable/Enable text search index.
207 - disable - Do not create text search index.
208 - enable - Create text search index.
209 choices: ['disable', 'enable']
210 traffic_table_partition_time:
211 aliases: ['traffic-table-partition-time']
212 type: int
213 description: Maximum SQL database table partitioning time range in minute
214 ts_index_field:
215 aliases: ['ts-index-field']
216 type: list
217 elements: dict
218 description: Ts index field.
219 suboptions:
220 category:
221 type: str
222 description: Category of text search index fields.
223 value:
224 type: str
225 description: Fields of text search index.
226 username:
227 type: str
228 description: User name for login remote database.
229 utm_table_partition_time:
230 aliases: ['utm-table-partition-time']
231 type: int
232 description: Maximum SQL database table partitioning time range in minute
233 custom_skipidx:
234 aliases: ['custom-skipidx']
235 type: list
236 elements: dict
237 description: Custom skipidx.
238 suboptions:
239 device_type:
240 aliases: ['device-type']
241 type: str
242 description:
243 - Device type.
244 - FortiGate - Set device type to FortiGate.
245 - FortiManager - Set device type to FortiManager
246 - FortiClient - Set device type to FortiClient.
247 - FortiMail - Set device type to FortiMail.
248 - FortiWeb - Set device type to FortiWeb.
249 - FortiSandbox - Set device type to FortiSandbox
250 - FortiProxy - Set device type to FortiProxy
251 choices: ['FortiGate', 'FortiManager', 'FortiClient', 'FortiMail',
252 'FortiWeb', 'FortiSandbox', 'FortiProxy']
253 id:
254 type: int
255 description: Add or Edit log index fields.
256 index_field:
257 aliases: ['index-field']
258 type: str
259 description: Field to be added to skip index.
260 log_type:
261 aliases: ['log-type']
262 type: str
263 description:
264 - Log type.
265 - app-ctrl
266 - attack
267 - content
268 - dlp
269 - emailfilter
270 - event
271 - generic
272 - history
273 - traffic
274 - virus
275 - voip
276 - webfilter
277 - netscan
278 - fct-event
279 - fct-traffic
280 - fct-netscan
281 - waf
282 - gtp
283 - dns
284 - ssh
285 - ssl
286 - file-filter
287 - asset
288 choices: ['app-ctrl', 'attack', 'content', 'dlp', 'emailfilter', 'event',
289 'generic', 'history', 'traffic', 'virus', 'voip', 'webfilter',
290 'netscan', 'fct-event', 'fct-traffic', 'fct-netscan', 'waf',
291 'gtp', 'dns', 'ssh', 'ssl', 'file-filter', 'asset', 'protocol',
292 'siem', 'ztna', 'security']
293 compress_table_min_age:
294 aliases: ['compress-table-min-age']
295 type: int
296 description: Minimum age in days for SQL tables to be compressed.
297 '''
298
299 EXAMPLES = '''
300 - name: Example playbook (generated based on argument schema)
301 hosts: fortimanagers
302 connection: httpapi
303 gather_facts: false
304 tasks:
305 - name: SQL settings.
306 fortinet.fortimanager.fmgr_system_sql:
307 # workspace_locking_adom: <global or your adom name>
308 system_sql:
309 # background_rebuild: <value in [disable, enable]>
310 # custom_index:
311 # - case_sensitive: <value in [disable, enable]>
312 # device_type: <value in [FortiGate, FortiManager, FortiClient, ...]>
313 # id: <integer>
314 # index_field: <string>
315 # log_type: <value in [none, app-ctrl, attack, ...]>
316 # database_name: <string>
317 # database_type: <value in [mysql, postgres]>
318 # device_count_high: <value in [disable, enable]>
319 # event_table_partition_time: <integer>
320 # fct_table_partition_time: <integer>
321 # logtype: ["none", "app-ctrl", "attack", "content", "dlp", "emailfilter", "event",
322 # "generic", "history", "traffic", "virus", "voip", "webfilter", "netscan",
323 # "fct-event", "fct-traffic", "fct-netscan", "waf", "gtp", "dns", "ssh",
324 # "ssl", "file-filter", "asset", "protocol", "siem", "ztna", "security"]
325 # password: <list or string>
326 # prompt_sql_upgrade: <value in [disable, enable]>
327 # rebuild_event: <value in [disable, enable]>
328 # rebuild_event_start_time: <list or string>
329 # server: <string>
330 # start_time: <list or string>
331 # status: <value in [disable, local]>
332 # text_search_index: <value in [disable, enable]>
333 # traffic_table_partition_time: <integer>
334 # ts_index_field:
335 # - category: <string>
336 # value: <string>
337 # username: <string>
338 # utm_table_partition_time: <integer>
339 # custom_skipidx:
340 # - device_type: <value in [FortiGate, FortiManager, FortiClient, ...]>
341 # id: <integer>
342 # index_field: <string>
343 # log_type: <value in [app-ctrl, attack, content, ...]>
344 # compress_table_min_age: <integer>
345 '''
346
347 RETURN = '''
348 meta:
349 description: The result of the request.
350 type: dict
351 returned: always
352 contains:
353 request_url:
354 description: The full url requested.
355 returned: always
356 type: str
357 sample: /sys/login/user
358 response_code:
359 description: The status of api request.
360 returned: always
361 type: int
362 sample: 0
363 response_data:
364 description: The api response.
365 type: list
366 returned: always
367 response_message:
368 description: The descriptive message of the api response.
369 type: str
370 returned: always
371 sample: OK.
372 system_information:
373 description: The information of the target system.
374 type: dict
375 returned: always
376 rc:
377 description: The status the request.
378 type: int
379 returned: always
380 sample: 0
381 version_check_warning:
382 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
383 type: list
384 returned: complex
385 '''
386 from ansible.module_utils.basic import AnsibleModule
387 from ansible.module_utils.connection import Connection
388 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
389 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
390
391
392 def main():
393 urls_list = [
394 '/cli/global/system/sql'
395 ]
396 module_arg_spec = {
397 'system_sql': {
398 'type': 'dict', 'v_range': [['6.0.0', '']],
399 'options': {
400 'background-rebuild': {'choices': ['disable', 'enable'], 'type': 'str'},
401 'custom-index': {
402 'type': 'list',
403 'options': {
404 'case-sensitive': {'choices': ['disable', 'enable'], 'type': 'str'},
405 'device-type': {
406 'choices': [
407 'FortiGate', 'FortiManager', 'FortiClient', 'FortiMail', 'FortiWeb', 'FortiCache', 'FortiSandbox', 'FortiDDoS',
408 'FortiAuthenticator', 'FortiProxy'
409 ],
410 'type': 'str'
411 },
412 'id': {'type': 'int'},
413 'index-field': {'type': 'str'},
414 'log-type': {
415 'choices': [
416 'none', 'app-ctrl', 'attack', 'content', 'dlp', 'emailfilter', 'event', 'generic', 'history', 'traffic', 'virus', 'voip',
417 'webfilter', 'netscan', 'fct-event', 'fct-traffic', 'fct-netscan', 'waf', 'gtp', 'dns', 'ssh', 'ssl', 'file-filter',
418 'asset', 'protocol', 'siem', 'ztna', 'security'
419 ],
420 'type': 'str'
421 }
422 },
423 'elements': 'dict'
424 },
425 'database-name': {'type': 'str'},
426 'database-type': {'choices': ['mysql', 'postgres'], 'type': 'str'},
427 'device-count-high': {'choices': ['disable', 'enable'], 'type': 'str'},
428 'event-table-partition-time': {'type': 'int'},
429 'fct-table-partition-time': {'type': 'int'},
430 'logtype': {
431 'type': 'list',
432 'choices': [
433 'none', 'app-ctrl', 'attack', 'content', 'dlp', 'emailfilter', 'event', 'generic', 'history', 'traffic', 'virus', 'voip',
434 'webfilter', 'netscan', 'fct-event', 'fct-traffic', 'fct-netscan', 'waf', 'gtp', 'dns', 'ssh', 'ssl', 'file-filter', 'asset',
435 'protocol', 'siem', 'ztna', 'security'
436 ],
437 'elements': 'str'
438 },
439 'password': {'no_log': True, 'type': 'raw'},
440 'prompt-sql-upgrade': {'choices': ['disable', 'enable'], 'type': 'str'},
441 'rebuild-event': {'v_range': [['6.0.0', '7.4.0']], 'choices': ['disable', 'enable'], 'type': 'str'},
442 'rebuild-event-start-time': {'v_range': [['6.0.0', '7.4.0']], 'type': 'raw'},
443 'server': {'type': 'str'},
444 'start-time': {'type': 'raw'},
445 'status': {'choices': ['disable', 'local'], 'type': 'str'},
446 'text-search-index': {'choices': ['disable', 'enable'], 'type': 'str'},
447 'traffic-table-partition-time': {'type': 'int'},
448 'ts-index-field': {'type': 'list', 'options': {'category': {'type': 'str'}, 'value': {'type': 'str'}}, 'elements': 'dict'},
449 'username': {'type': 'str'},
450 'utm-table-partition-time': {'type': 'int'},
451 'custom-skipidx': {
452 'v_range': [['6.2.3', '']],
453 'type': 'list',
454 'options': {
455 'device-type': {
456 'v_range': [['6.2.3', '']],
457 'choices': ['FortiGate', 'FortiManager', 'FortiClient', 'FortiMail', 'FortiWeb', 'FortiSandbox', 'FortiProxy'],
458 'type': 'str'
459 },
460 'id': {'v_range': [['6.2.3', '']], 'type': 'int'},
461 'index-field': {'v_range': [['6.2.3', '']], 'type': 'str'},
462 'log-type': {
463 'v_range': [['6.2.3', '']],
464 'choices': [
465 'app-ctrl', 'attack', 'content', 'dlp', 'emailfilter', 'event', 'generic', 'history', 'traffic', 'virus', 'voip',
466 'webfilter', 'netscan', 'fct-event', 'fct-traffic', 'fct-netscan', 'waf', 'gtp', 'dns', 'ssh', 'ssl', 'file-filter',
467 'asset', 'protocol', 'siem', 'ztna', 'security'
468 ],
469 'type': 'str'
470 }
471 },
472 'elements': 'dict'
473 },
474 'compress-table-min-age': {'v_range': [['6.4.3', '']], 'type': 'int'}
475 }
476 }
477 }
478
479 module_option_spec = get_module_arg_spec('partial crud')
480 module_arg_spec.update(module_option_spec)
481 check_galaxy_version(module_arg_spec)
482 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_sql'),
483 supports_check_mode=True)
484 if not module._socket_path:
485 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
486 connection = Connection(module._socket_path)
487 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
488 None, 'data', module, connection)
489 fmgr.process_partial_crud()
490 module.exit_json(meta=module.params)
491
492
493 if __name__ == '__main__':
494 main()