Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_group_dynamicmapping.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_user_group_dynamicmapping
15 short_description: Configure user groups.
16 version_added: "2.1.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 group:
29 description: The parameter (group) in requested url.
30 type: str
31 required: true
32 user_group_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _scope:
38 type: list
39 elements: dict
40 description: Scope.
41 suboptions:
42 name:
43 type: str
44 description: Name.
45 vdom:
46 type: str
47 description: Vdom.
48 auth_concurrent_override:
49 aliases: ['auth-concurrent-override']
50 type: str
51 description: Enable/disable overriding the global number of concurrent authentication sessions for this user group.
52 choices: ['disable', 'enable']
53 auth_concurrent_value:
54 aliases: ['auth-concurrent-value']
55 type: int
56 description: Maximum number of concurrent authenticated connections per user
57 authtimeout:
58 type: int
59 description: Authentication timeout in minutes for this user group.
60 company:
61 type: str
62 description: Set the action for the company guest user field.
63 choices: ['optional', 'mandatory', 'disabled']
64 email:
65 type: str
66 description: Enable/disable the guest user email address field.
67 choices: ['disable', 'enable']
68 expire:
69 type: int
70 description: Time in seconds before guest user accounts expire
71 expire_type:
72 aliases: ['expire-type']
73 type: str
74 description: Determine when the expiration countdown begins.
75 choices: ['immediately', 'first-successful-login']
76 group_type:
77 aliases: ['group-type']
78 type: str
79 description: Set the group to be for firewall authentication, FSSO, RSSO, or guest users.
80 choices: ['firewall', 'directory-service', 'fsso-service', 'guest', 'rsso']
81 guest:
82 type: list
83 elements: dict
84 description: Guest.
85 suboptions:
86 comment:
87 type: str
88 description: Comment.
89 company:
90 type: str
91 description: Set the action for the company guest user field.
92 email:
93 type: str
94 description: Email.
95 expiration:
96 type: str
97 description: Expire time.
98 group:
99 type: str
100 description: Group.
101 id:
102 type: int
103 description: Guest ID.
104 mobile_phone:
105 aliases: ['mobile-phone']
106 type: str
107 description: Mobile phone.
108 name:
109 type: str
110 description: Guest name.
111 password:
112 type: raw
113 description: (list) Guest password.
114 sponsor:
115 type: str
116 description: Set the action for the sponsor guest user field.
117 user_id:
118 aliases: ['user-id']
119 type: str
120 description: Guest ID.
121 http_digest_realm:
122 aliases: ['http-digest-realm']
123 type: str
124 description: Realm attribute for MD5-digest authentication.
125 id:
126 type: int
127 description: Group ID.
128 required: true
129 ldap_memberof:
130 aliases: ['ldap-memberof']
131 type: str
132 description: Ldap memberof.
133 logic_type:
134 aliases: ['logic-type']
135 type: str
136 description: Logic type.
137 choices: ['or', 'and']
138 match:
139 type: list
140 elements: dict
141 description: Match.
142 suboptions:
143 _gui_meta:
144 type: str
145 description: Gui meta.
146 group_name:
147 aliases: ['group-name']
148 type: str
149 description: Name of matching user or group on remote authentication server.
150 id:
151 type: int
152 description: ID.
153 server_name:
154 aliases: ['server-name']
155 type: str
156 description: Name of remote auth server.
157 max_accounts:
158 aliases: ['max-accounts']
159 type: int
160 description: Maximum number of guest accounts that can be created for this group
161 member:
162 type: raw
163 description: (list or str) Names of users, peers, LDAP severs, or RADIUS servers to add to the user group.
164 mobile_phone:
165 aliases: ['mobile-phone']
166 type: str
167 description: Enable/disable the guest user mobile phone number field.
168 choices: ['disable', 'enable']
169 multiple_guest_add:
170 aliases: ['multiple-guest-add']
171 type: str
172 description: Enable/disable addition of multiple guests.
173 choices: ['disable', 'enable']
174 password:
175 type: str
176 description: Guest user password type.
177 choices: ['auto-generate', 'specify', 'disable']
178 redir_url:
179 aliases: ['redir-url']
180 type: str
181 description: Redir url.
182 sms_custom_server:
183 aliases: ['sms-custom-server']
184 type: str
185 description: SMS server.
186 sms_server:
187 aliases: ['sms-server']
188 type: str
189 description: Send SMS through FortiGuard or other external server.
190 choices: ['fortiguard', 'custom']
191 sponsor:
192 type: str
193 description: Set the action for the sponsor guest user field.
194 choices: ['optional', 'mandatory', 'disabled']
195 sslvpn_bookmarks_group:
196 aliases: ['sslvpn-bookmarks-group']
197 type: raw
198 description: (list or str) Sslvpn bookmarks group.
199 sslvpn_cache_cleaner:
200 aliases: ['sslvpn-cache-cleaner']
201 type: str
202 description: Sslvpn cache cleaner.
203 choices: ['disable', 'enable']
204 sslvpn_client_check:
205 aliases: ['sslvpn-client-check']
206 type: list
207 elements: str
208 description: Sslvpn client check.
209 choices: ['forticlient', 'forticlient-av', 'forticlient-fw', '3rdAV', '3rdFW']
210 sslvpn_ftp:
211 aliases: ['sslvpn-ftp']
212 type: str
213 description: Sslvpn ftp.
214 choices: ['disable', 'enable']
215 sslvpn_http:
216 aliases: ['sslvpn-http']
217 type: str
218 description: Sslvpn http.
219 choices: ['disable', 'enable']
220 sslvpn_os_check:
221 aliases: ['sslvpn-os-check']
222 type: str
223 description: Sslvpn os check.
224 choices: ['disable', 'enable']
225 sslvpn_os_check_list:
226 aliases: ['sslvpn-os-check-list']
227 type: dict
228 description: Sslvpn os check list.
229 suboptions:
230 action:
231 type: str
232 description: Action.
233 choices: ['allow', 'check-up-to-date', 'deny']
234 latest_patch_level:
235 aliases: ['latest-patch-level']
236 type: str
237 description: Latest patch level.
238 name:
239 type: str
240 description: Name.
241 tolerance:
242 type: int
243 description: Tolerance.
244 sslvpn_portal:
245 aliases: ['sslvpn-portal']
246 type: raw
247 description: (list or str) Sslvpn portal.
248 sslvpn_portal_heading:
249 aliases: ['sslvpn-portal-heading']
250 type: str
251 description: Sslvpn portal heading.
252 sslvpn_rdp:
253 aliases: ['sslvpn-rdp']
254 type: str
255 description: Sslvpn rdp.
256 choices: ['disable', 'enable']
257 sslvpn_samba:
258 aliases: ['sslvpn-samba']
259 type: str
260 description: Sslvpn samba.
261 choices: ['disable', 'enable']
262 sslvpn_split_tunneling:
263 aliases: ['sslvpn-split-tunneling']
264 type: str
265 description: Sslvpn split tunneling.
266 choices: ['disable', 'enable']
267 sslvpn_ssh:
268 aliases: ['sslvpn-ssh']
269 type: str
270 description: Sslvpn ssh.
271 choices: ['disable', 'enable']
272 sslvpn_telnet:
273 aliases: ['sslvpn-telnet']
274 type: str
275 description: Sslvpn telnet.
276 choices: ['disable', 'enable']
277 sslvpn_tunnel:
278 aliases: ['sslvpn-tunnel']
279 type: str
280 description: Sslvpn tunnel.
281 choices: ['disable', 'enable']
282 sslvpn_tunnel_endip:
283 aliases: ['sslvpn-tunnel-endip']
284 type: str
285 description: Sslvpn tunnel endip.
286 sslvpn_tunnel_ip_mode:
287 aliases: ['sslvpn-tunnel-ip-mode']
288 type: str
289 description: Sslvpn tunnel ip mode.
290 choices: ['range', 'usrgrp']
291 sslvpn_tunnel_startip:
292 aliases: ['sslvpn-tunnel-startip']
293 type: str
294 description: Sslvpn tunnel startip.
295 sslvpn_virtual_desktop:
296 aliases: ['sslvpn-virtual-desktop']
297 type: str
298 description: Sslvpn virtual desktop.
299 choices: ['disable', 'enable']
300 sslvpn_vnc:
301 aliases: ['sslvpn-vnc']
302 type: str
303 description: Sslvpn vnc.
304 choices: ['disable', 'enable']
305 sslvpn_webapp:
306 aliases: ['sslvpn-webapp']
307 type: str
308 description: Sslvpn webapp.
309 choices: ['disable', 'enable']
310 sso_attribute_value:
311 aliases: ['sso-attribute-value']
312 type: str
313 description: Name of the RADIUS user group that this local user group represents.
314 user_id:
315 aliases: ['user-id']
316 type: str
317 description: Guest user ID type.
318 choices: ['email', 'auto-generate', 'specify']
319 user_name:
320 aliases: ['user-name']
321 type: str
322 description: Enable/disable the guest user name entry.
323 choices: ['disable', 'enable']
324 negate:
325 type: str
326 description: Negate.
327 choices: ['disable', 'enable']
328 '''
329
330 EXAMPLES = '''
331 - name: Example playbook (generated based on argument schema)
332 hosts: fortimanagers
333 connection: httpapi
334 gather_facts: false
335 tasks:
336 - name: Configure user groups.
337 fortinet.fortimanager.fmgr_user_group_dynamicmapping:
338 # workspace_locking_adom: <global or your adom name>
339 adom: <your own value>
340 group: <your own value>
341 state: present # <value in [present, absent]>
342 user_group_dynamicmapping:
343 id: 0 # Required variable, integer
344 # _scope:
345 # - name: <string>
346 # vdom: <string>
347 # auth_concurrent_override: <value in [disable, enable]>
348 # auth_concurrent_value: <integer>
349 # authtimeout: <integer>
350 # company: <value in [optional, mandatory, disabled]>
351 # email: <value in [disable, enable]>
352 # expire: <integer>
353 # expire_type: <value in [immediately, first-successful-login]>
354 # group_type: <value in [firewall, directory-service, fsso-service, ...]>
355 # guest:
356 # - comment: <string>
357 # company: <string>
358 # email: <string>
359 # expiration: <string>
360 # group: <string>
361 # id: <integer>
362 # mobile_phone: <string>
363 # name: <string>
364 # password: <list or string>
365 # sponsor: <string>
366 # user_id: <string>
367 # http_digest_realm: <string>
368 # ldap_memberof: <string>
369 # logic_type: <value in [or, and]>
370 # match:
371 # - _gui_meta: <string>
372 # group_name: <string>
373 # id: <integer>
374 # server_name: <string>
375 # max_accounts: <integer>
376 # member: <list or string>
377 # mobile_phone: <value in [disable, enable]>
378 # multiple_guest_add: <value in [disable, enable]>
379 # password: <value in [auto-generate, specify, disable]>
380 # redir_url: <string>
381 # sms_custom_server: <string>
382 # sms_server: <value in [fortiguard, custom]>
383 # sponsor: <value in [optional, mandatory, disabled]>
384 # sslvpn_bookmarks_group: <list or string>
385 # sslvpn_cache_cleaner: <value in [disable, enable]>
386 # sslvpn_client_check: ["forticlient", "forticlient-av", "forticlient-fw", "3rdAV",
387 # "3rdFW"]
388 # sslvpn_ftp: <value in [disable, enable]>
389 # sslvpn_http: <value in [disable, enable]>
390 # sslvpn_os_check: <value in [disable, enable]>
391 # sslvpn_os_check_list:
392 # action: <value in [allow, check-up-to-date, deny]>
393 # latest_patch_level: <string>
394 # name: <string>
395 # tolerance: <integer>
396 # sslvpn_portal: <list or string>
397 # sslvpn_portal_heading: <string>
398 # sslvpn_rdp: <value in [disable, enable]>
399 # sslvpn_samba: <value in [disable, enable]>
400 # sslvpn_split_tunneling: <value in [disable, enable]>
401 # sslvpn_ssh: <value in [disable, enable]>
402 # sslvpn_telnet: <value in [disable, enable]>
403 # sslvpn_tunnel: <value in [disable, enable]>
404 # sslvpn_tunnel_endip: <string>
405 # sslvpn_tunnel_ip_mode: <value in [range, usrgrp]>
406 # sslvpn_tunnel_startip: <string>
407 # sslvpn_virtual_desktop: <value in [disable, enable]>
408 # sslvpn_vnc: <value in [disable, enable]>
409 # sslvpn_webapp: <value in [disable, enable]>
410 # sso_attribute_value: <string>
411 # user_id: <value in [email, auto-generate, specify]>
412 # user_name: <value in [disable, enable]>
413 # negate: <value in [disable, enable]>
414 '''
415
416 RETURN = '''
417 meta:
418 description: The result of the request.
419 type: dict
420 returned: always
421 contains:
422 request_url:
423 description: The full url requested.
424 returned: always
425 type: str
426 sample: /sys/login/user
427 response_code:
428 description: The status of api request.
429 returned: always
430 type: int
431 sample: 0
432 response_data:
433 description: The api response.
434 type: list
435 returned: always
436 response_message:
437 description: The descriptive message of the api response.
438 type: str
439 returned: always
440 sample: OK.
441 system_information:
442 description: The information of the target system.
443 type: dict
444 returned: always
445 rc:
446 description: The status the request.
447 type: int
448 returned: always
449 sample: 0
450 version_check_warning:
451 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
452 type: list
453 returned: complex
454 '''
455 from ansible.module_utils.basic import AnsibleModule
456 from ansible.module_utils.connection import Connection
457 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
458 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
459
460
461 def main():
462 urls_list = [
463 '/pm/config/adom/{adom}/obj/user/group/{group}/dynamic_mapping',
464 '/pm/config/global/obj/user/group/{group}/dynamic_mapping'
465 ]
466 module_arg_spec = {
467 'adom': {'required': True, 'type': 'str'},
468 'group': {'required': True, 'type': 'str'},
469 'revision_note': {'type': 'str'},
470 'user_group_dynamicmapping': {
471 'type': 'dict', 'v_range': [['7.0.2', '']],
472 'options': {
473 '_scope': {
474 'v_range': [['7.0.2', '']],
475 'type': 'list',
476 'options': {'name': {'v_range': [['7.0.2', '']], 'type': 'str'}, 'vdom': {'v_range': [['7.0.2', '']], 'type': 'str'}},
477 'elements': 'dict'
478 },
479 'auth-concurrent-override': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
480 'auth-concurrent-value': {'v_range': [['7.0.2', '']], 'type': 'int'},
481 'authtimeout': {'v_range': [['7.0.2', '']], 'type': 'int'},
482 'company': {'v_range': [['7.0.2', '']], 'choices': ['optional', 'mandatory', 'disabled'], 'type': 'str'},
483 'email': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
484 'expire': {'v_range': [['7.0.2', '']], 'type': 'int'},
485 'expire-type': {'v_range': [['7.0.2', '']], 'choices': ['immediately', 'first-successful-login'], 'type': 'str'},
486 'group-type': {'v_range': [['7.0.2', '']], 'choices': ['firewall', 'directory-service', 'fsso-service', 'guest', 'rsso'], 'type': 'str'},
487 'guest': {
488 'v_range': [['7.0.2', '']],
489 'type': 'list',
490 'options': {
491 'comment': {'v_range': [['7.0.2', '']], 'type': 'str'},
492 'company': {'v_range': [['7.0.2', '']], 'type': 'str'},
493 'email': {'v_range': [['7.0.2', '']], 'type': 'str'},
494 'expiration': {'v_range': [['7.0.2', '']], 'type': 'str'},
495 'group': {'v_range': [['7.0.2', '']], 'type': 'str'},
496 'id': {'v_range': [['7.0.2', '']], 'type': 'int'},
497 'mobile-phone': {'v_range': [['7.0.2', '']], 'type': 'str'},
498 'name': {'v_range': [['7.0.2', '']], 'type': 'str'},
499 'password': {'v_range': [['7.0.2', '']], 'no_log': True, 'type': 'raw'},
500 'sponsor': {'v_range': [['7.0.2', '']], 'type': 'str'},
501 'user-id': {'v_range': [['7.0.2', '']], 'type': 'str'}
502 },
503 'elements': 'dict'
504 },
505 'http-digest-realm': {'v_range': [['7.0.2', '']], 'type': 'str'},
506 'id': {'v_range': [['7.0.2', '']], 'required': True, 'type': 'int'},
507 'ldap-memberof': {'v_range': [['7.0.2', '']], 'type': 'str'},
508 'logic-type': {'v_range': [['7.0.3', '']], 'choices': ['or', 'and'], 'type': 'str'},
509 'match': {
510 'v_range': [['7.0.2', '']],
511 'type': 'list',
512 'options': {
513 '_gui_meta': {'v_range': [['7.0.2', '']], 'type': 'str'},
514 'group-name': {'v_range': [['7.0.2', '']], 'type': 'str'},
515 'id': {'v_range': [['7.0.2', '']], 'type': 'int'},
516 'server-name': {'v_range': [['7.0.2', '']], 'type': 'str'}
517 },
518 'elements': 'dict'
519 },
520 'max-accounts': {'v_range': [['7.0.2', '']], 'type': 'int'},
521 'member': {'v_range': [['7.0.2', '']], 'type': 'raw'},
522 'mobile-phone': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
523 'multiple-guest-add': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
524 'password': {'v_range': [['7.0.2', '']], 'choices': ['auto-generate', 'specify', 'disable'], 'no_log': True, 'type': 'str'},
525 'redir-url': {'v_range': [['7.0.2', '']], 'type': 'str'},
526 'sms-custom-server': {'v_range': [['7.0.2', '']], 'type': 'str'},
527 'sms-server': {'v_range': [['7.0.2', '']], 'choices': ['fortiguard', 'custom'], 'type': 'str'},
528 'sponsor': {'v_range': [['7.0.2', '']], 'choices': ['optional', 'mandatory', 'disabled'], 'type': 'str'},
529 'sslvpn-bookmarks-group': {'v_range': [['7.0.2', '']], 'type': 'raw'},
530 'sslvpn-cache-cleaner': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
531 'sslvpn-client-check': {
532 'v_range': [['7.0.2', '']],
533 'type': 'list',
534 'choices': ['forticlient', 'forticlient-av', 'forticlient-fw', '3rdAV', '3rdFW'],
535 'elements': 'str'
536 },
537 'sslvpn-ftp': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
538 'sslvpn-http': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
539 'sslvpn-os-check': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
540 'sslvpn-os-check-list': {
541 'v_range': [['7.0.2', '']],
542 'type': 'dict',
543 'options': {
544 'action': {'v_range': [['7.0.2', '']], 'choices': ['allow', 'check-up-to-date', 'deny'], 'type': 'str'},
545 'latest-patch-level': {'v_range': [['7.0.2', '']], 'type': 'str'},
546 'name': {'v_range': [['7.0.2', '']], 'type': 'str'},
547 'tolerance': {'v_range': [['7.0.2', '']], 'type': 'int'}
548 }
549 },
550 'sslvpn-portal': {'v_range': [['7.0.2', '']], 'type': 'raw'},
551 'sslvpn-portal-heading': {'v_range': [['7.0.2', '']], 'type': 'str'},
552 'sslvpn-rdp': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
553 'sslvpn-samba': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
554 'sslvpn-split-tunneling': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
555 'sslvpn-ssh': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
556 'sslvpn-telnet': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
557 'sslvpn-tunnel': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
558 'sslvpn-tunnel-endip': {'v_range': [['7.0.2', '']], 'type': 'str'},
559 'sslvpn-tunnel-ip-mode': {'v_range': [['7.0.2', '']], 'choices': ['range', 'usrgrp'], 'type': 'str'},
560 'sslvpn-tunnel-startip': {'v_range': [['7.0.2', '']], 'type': 'str'},
561 'sslvpn-virtual-desktop': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
562 'sslvpn-vnc': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
563 'sslvpn-webapp': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
564 'sso-attribute-value': {'v_range': [['7.0.2', '']], 'type': 'str'},
565 'user-id': {'v_range': [['7.0.2', '']], 'choices': ['email', 'auto-generate', 'specify'], 'type': 'str'},
566 'user-name': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
567 'negate': {'v_range': [['7.4.9', '7.4.10'], ['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
568 }
569 }
570 }
571
572 module_option_spec = get_module_arg_spec('full crud')
573 module_arg_spec.update(module_option_spec)
574 check_galaxy_version(module_arg_spec)
575 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_group_dynamicmapping'),
576 supports_check_mode=True)
577 if not module._socket_path:
578 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
579 connection = Connection(module._socket_path)
580 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
581 'id', 'data', module, connection)
582 fmgr.process_crud()
583 module.exit_json(meta=module.params)
584
585
586 if __name__ == '__main__':
587 main()