Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_fsso.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_fsso
15 short_description: Configure Fortinet Single Sign On
16 version_added: "2.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 user_fsso:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 _gui_meta:
34 type: str
35 description: Gui meta.
36 dynamic_mapping:
37 type: list
38 elements: dict
39 description: Dynamic mapping.
40 suboptions:
41 _gui_meta:
42 type: str
43 description: Gui meta.
44 _scope:
45 type: list
46 elements: dict
47 description: Scope.
48 suboptions:
49 name:
50 type: str
51 description: Name.
52 vdom:
53 type: str
54 description: Vdom.
55 ldap_server:
56 aliases: ['ldap-server']
57 type: str
58 description: Ldap server.
59 password:
60 type: raw
61 description: (list) Password.
62 password2:
63 type: raw
64 description: (list) Password2.
65 password3:
66 type: raw
67 description: (list) Password3.
68 password4:
69 type: raw
70 description: (list) Password4.
71 password5:
72 type: raw
73 description: (list) Password5.
74 port:
75 type: int
76 description: Port.
77 port2:
78 type: int
79 description: Port2.
80 port3:
81 type: int
82 description: Port3.
83 port4:
84 type: int
85 description: Port4.
86 port5:
87 type: int
88 description: Port5.
89 server:
90 type: str
91 description: Server.
92 server2:
93 type: str
94 description: Server2.
95 server3:
96 type: str
97 description: Server3.
98 server4:
99 type: str
100 description: Server4.
101 server5:
102 type: str
103 description: Server5.
104 source_ip:
105 aliases: ['source-ip']
106 type: str
107 description: Source ip.
108 source_ip6:
109 aliases: ['source-ip6']
110 type: str
111 description: Source ip6.
112 ssl:
113 type: str
114 description: Ssl.
115 choices: ['disable', 'enable']
116 ssl_trusted_cert:
117 aliases: ['ssl-trusted-cert']
118 type: str
119 description: Ssl trusted cert.
120 type:
121 type: str
122 description: Type.
123 choices: ['default', 'fortiems', 'fortinac', 'fortiems-cloud']
124 user_info_server:
125 aliases: ['user-info-server']
126 type: raw
127 description: (list or str) User info server.
128 ldap_poll:
129 aliases: ['ldap-poll']
130 type: str
131 description: Ldap poll.
132 choices: ['disable', 'enable']
133 ldap_poll_filter:
134 aliases: ['ldap-poll-filter']
135 type: str
136 description: Ldap poll filter.
137 ldap_poll_interval:
138 aliases: ['ldap-poll-interval']
139 type: int
140 description: Ldap poll interval.
141 group_poll_interval:
142 aliases: ['group-poll-interval']
143 type: int
144 description: Group poll interval.
145 interface:
146 type: str
147 description: Interface.
148 interface_select_method:
149 aliases: ['interface-select-method']
150 type: str
151 description: Interface select method.
152 choices: ['auto', 'sdwan', 'specify']
153 logon_timeout:
154 aliases: ['logon-timeout']
155 type: int
156 description: Interval in minutes to keep logons after FSSO server down.
157 sni:
158 type: str
159 description: Server Name Indication.
160 ssl_server_host_ip_check:
161 aliases: ['ssl-server-host-ip-check']
162 type: str
163 description: Enable/disable server host/IP verification.
164 choices: ['disable', 'enable']
165 vrf_select:
166 aliases: ['vrf-select']
167 type: int
168 description: VRF ID used for connection to server.
169 ldap_server:
170 aliases: ['ldap-server']
171 type: str
172 description: LDAP server to get group information.
173 name:
174 type: str
175 description: Name.
176 required: true
177 password:
178 type: raw
179 description: (list) Password of the first FSSO collector agent.
180 password2:
181 type: raw
182 description: (list) Password of the second FSSO collector agent.
183 password3:
184 type: raw
185 description: (list) Password of the third FSSO collector agent.
186 password4:
187 type: raw
188 description: (list) Password of the fourth FSSO collector agent.
189 password5:
190 type: raw
191 description: (list) Password of the fifth FSSO collector agent.
192 port:
193 type: int
194 description: Port of the first FSSO collector agent.
195 port2:
196 type: int
197 description: Port of the second FSSO collector agent.
198 port3:
199 type: int
200 description: Port of the third FSSO collector agent.
201 port4:
202 type: int
203 description: Port of the fourth FSSO collector agent.
204 port5:
205 type: int
206 description: Port of the fifth FSSO collector agent.
207 server:
208 type: str
209 description: Domain name or IP address of the first FSSO collector agent.
210 server2:
211 type: str
212 description: Domain name or IP address of the second FSSO collector agent.
213 server3:
214 type: str
215 description: Domain name or IP address of the third FSSO collector agent.
216 server4:
217 type: str
218 description: Domain name or IP address of the fourth FSSO collector agent.
219 server5:
220 type: str
221 description: Domain name or IP address of the fifth FSSO collector agent.
222 source_ip:
223 aliases: ['source-ip']
224 type: str
225 description: Source IP for communications to FSSO agent.
226 source_ip6:
227 aliases: ['source-ip6']
228 type: str
229 description: IPv6 source for communications to FSSO agent.
230 ldap_poll:
231 aliases: ['ldap-poll']
232 type: str
233 description: Enable/disable automatic fetching of groups from LDAP server.
234 choices: ['disable', 'enable']
235 ldap_poll_filter:
236 aliases: ['ldap-poll-filter']
237 type: str
238 description: Filter used to fetch groups.
239 ldap_poll_interval:
240 aliases: ['ldap-poll-interval']
241 type: int
242 description: Interval in minutes within to fetch groups from LDAP server.
243 ssl:
244 type: str
245 description: Enable/disable use of SSL.
246 choices: ['disable', 'enable']
247 ssl_trusted_cert:
248 aliases: ['ssl-trusted-cert']
249 type: str
250 description: Trusted server certificate or CA certificate.
251 type:
252 type: str
253 description: Server type.
254 choices: ['default', 'fortiems', 'fortinac', 'fortiems-cloud']
255 user_info_server:
256 aliases: ['user-info-server']
257 type: str
258 description: LDAP server to get user information.
259 group_poll_interval:
260 aliases: ['group-poll-interval']
261 type: int
262 description: Interval in minutes within to fetch groups from FSSO server, or unset to disable.
263 interface:
264 type: str
265 description: Specify outgoing interface to reach server.
266 interface_select_method:
267 aliases: ['interface-select-method']
268 type: str
269 description: Specify how to select outgoing interface to reach server.
270 choices: ['auto', 'sdwan', 'specify']
271 logon_timeout:
272 aliases: ['logon-timeout']
273 type: int
274 description: Interval in minutes to keep logons after FSSO server down.
275 sni:
276 type: str
277 description: Server Name Indication.
278 ssl_server_host_ip_check:
279 aliases: ['ssl-server-host-ip-check']
280 type: str
281 description: Enable/disable server host/IP verification.
282 choices: ['disable', 'enable']
283 vrf_select:
284 aliases: ['vrf-select']
285 type: int
286 description: VRF ID used for connection to server.
287 '''
288
289 EXAMPLES = '''
290 - name: Example playbook
291 hosts: fortimanagers
292 gather_facts: false
293 connection: httpapi
294 vars:
295 ansible_httpapi_use_ssl: true
296 ansible_httpapi_validate_certs: false
297 ansible_httpapi_port: 443
298 tasks:
299 - name: Configure Fortinet Single Sign On (FSSO) agents.
300 fortinet.fortimanager.fmgr_user_fsso:
301 bypass_validation: false
302 adom: ansible
303 state: present
304 user_fsso:
305 name: ansible-test-fsso
306 password: fortinet
307 port: 9000
308 server: ansible
309
310 - name: Gathering fortimanager facts
311 hosts: fortimanagers
312 gather_facts: false
313 connection: httpapi
314 vars:
315 ansible_httpapi_use_ssl: true
316 ansible_httpapi_validate_certs: false
317 ansible_httpapi_port: 443
318 tasks:
319 - name: Retrieve all the Fortinet Single Sign On (FSSO) agents
320 fortinet.fortimanager.fmgr_fact:
321 facts:
322 selector: "user_fsso"
323 params:
324 adom: "ansible"
325 fsso: "your_value"
326 '''
327
328 RETURN = '''
329 meta:
330 description: The result of the request.
331 type: dict
332 returned: always
333 contains:
334 request_url:
335 description: The full url requested.
336 returned: always
337 type: str
338 sample: /sys/login/user
339 response_code:
340 description: The status of api request.
341 returned: always
342 type: int
343 sample: 0
344 response_data:
345 description: The api response.
346 type: list
347 returned: always
348 response_message:
349 description: The descriptive message of the api response.
350 type: str
351 returned: always
352 sample: OK.
353 system_information:
354 description: The information of the target system.
355 type: dict
356 returned: always
357 rc:
358 description: The status the request.
359 type: int
360 returned: always
361 sample: 0
362 version_check_warning:
363 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
364 type: list
365 returned: complex
366 '''
367 from ansible.module_utils.basic import AnsibleModule
368 from ansible.module_utils.connection import Connection
369 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
370 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
371
372
373 def main():
374 urls_list = [
375 '/pm/config/adom/{adom}/obj/user/fsso',
376 '/pm/config/global/obj/user/fsso'
377 ]
378 module_arg_spec = {
379 'adom': {'required': True, 'type': 'str'},
380 'revision_note': {'type': 'str'},
381 'user_fsso': {
382 'type': 'dict', 'v_range': [['6.0.0', '']],
383 'options': {
384 '_gui_meta': {'type': 'str'},
385 'dynamic_mapping': {
386 'type': 'list',
387 'options': {
388 '_gui_meta': {'type': 'str'},
389 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
390 'ldap-server': {'type': 'str'},
391 'password': {'no_log': True, 'type': 'raw'},
392 'password2': {'no_log': True, 'type': 'raw'},
393 'password3': {'no_log': True, 'type': 'raw'},
394 'password4': {'no_log': True, 'type': 'raw'},
395 'password5': {'no_log': True, 'type': 'raw'},
396 'port': {'type': 'int'},
397 'port2': {'type': 'int'},
398 'port3': {'type': 'int'},
399 'port4': {'type': 'int'},
400 'port5': {'type': 'int'},
401 'server': {'type': 'str'},
402 'server2': {'type': 'str'},
403 'server3': {'type': 'str'},
404 'server4': {'type': 'str'},
405 'server5': {'type': 'str'},
406 'source-ip': {'type': 'str'},
407 'source-ip6': {'type': 'str'},
408 'ssl': {'choices': ['disable', 'enable'], 'type': 'str'},
409 'ssl-trusted-cert': {'type': 'str'},
410 'type': {'choices': ['default', 'fortiems', 'fortinac', 'fortiems-cloud'], 'type': 'str'},
411 'user-info-server': {'type': 'raw'},
412 'ldap-poll': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
413 'ldap-poll-filter': {'v_range': [['6.2.1', '']], 'type': 'str'},
414 'ldap-poll-interval': {'v_range': [['6.2.1', '']], 'type': 'int'},
415 'group-poll-interval': {'v_range': [['6.2.2', '']], 'type': 'int'},
416 'interface': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
417 'interface-select-method': {
418 'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']],
419 'choices': ['auto', 'sdwan', 'specify'],
420 'type': 'str'
421 },
422 'logon-timeout': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'},
423 'sni': {'v_range': [['7.2.0', '']], 'type': 'str'},
424 'ssl-server-host-ip-check': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
425 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'}
426 },
427 'elements': 'dict'
428 },
429 'ldap-server': {'type': 'str'},
430 'name': {'required': True, 'type': 'str'},
431 'password': {'no_log': True, 'type': 'raw'},
432 'password2': {'no_log': True, 'type': 'raw'},
433 'password3': {'no_log': True, 'type': 'raw'},
434 'password4': {'no_log': True, 'type': 'raw'},
435 'password5': {'no_log': True, 'type': 'raw'},
436 'port': {'type': 'int'},
437 'port2': {'type': 'int'},
438 'port3': {'type': 'int'},
439 'port4': {'type': 'int'},
440 'port5': {'type': 'int'},
441 'server': {'type': 'str'},
442 'server2': {'type': 'str'},
443 'server3': {'type': 'str'},
444 'server4': {'type': 'str'},
445 'server5': {'type': 'str'},
446 'source-ip': {'type': 'str'},
447 'source-ip6': {'type': 'str'},
448 'ldap-poll': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
449 'ldap-poll-filter': {'v_range': [['6.2.1', '']], 'type': 'str'},
450 'ldap-poll-interval': {'v_range': [['6.2.1', '']], 'type': 'int'},
451 'ssl': {'v_range': [['6.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
452 'ssl-trusted-cert': {'v_range': [['6.2.0', '']], 'type': 'str'},
453 'type': {'v_range': [['6.2.0', '']], 'choices': ['default', 'fortiems', 'fortinac', 'fortiems-cloud'], 'type': 'str'},
454 'user-info-server': {'v_range': [['6.2.0', '']], 'type': 'str'},
455 'group-poll-interval': {'v_range': [['6.2.2', '']], 'type': 'int'},
456 'interface': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
457 'interface-select-method': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
458 'logon-timeout': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'},
459 'sni': {'v_range': [['7.2.0', '']], 'type': 'str'},
460 'ssl-server-host-ip-check': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
461 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'}
462 }
463 }
464 }
465
466 module_option_spec = get_module_arg_spec('full crud')
467 module_arg_spec.update(module_option_spec)
468 check_galaxy_version(module_arg_spec)
469 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_fsso'),
470 supports_check_mode=True)
471 if not module._socket_path:
472 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
473 connection = Connection(module._socket_path)
474 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
475 'name', 'data', module, connection)
476 fmgr.process_crud()
477 module.exit_json(meta=module.params)
478
479
480 if __name__ == '__main__':
481 main()