Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_user_fsso_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_fsso_dynamicmapping
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 fsso:
29 description: The parameter (fsso) in requested url.
30 type: str
31 required: true
32 user_fsso_dynamicmapping:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 _gui_meta:
38 type: str
39 description: Gui meta.
40 _scope:
41 type: list
42 elements: dict
43 description: Scope.
44 suboptions:
45 name:
46 type: str
47 description: Name.
48 vdom:
49 type: str
50 description: Vdom.
51 ldap_server:
52 aliases: ['ldap-server']
53 type: str
54 description: Ldap server.
55 password:
56 type: raw
57 description: (list) Password.
58 password2:
59 type: raw
60 description: (list) Password2.
61 password3:
62 type: raw
63 description: (list) Password3.
64 password4:
65 type: raw
66 description: (list) Password4.
67 password5:
68 type: raw
69 description: (list) Password5.
70 port:
71 type: int
72 description: Port.
73 port2:
74 type: int
75 description: Port2.
76 port3:
77 type: int
78 description: Port3.
79 port4:
80 type: int
81 description: Port4.
82 port5:
83 type: int
84 description: Port5.
85 server:
86 type: str
87 description: Server.
88 server2:
89 type: str
90 description: Server2.
91 server3:
92 type: str
93 description: Server3.
94 server4:
95 type: str
96 description: Server4.
97 server5:
98 type: str
99 description: Server5.
100 source_ip:
101 aliases: ['source-ip']
102 type: str
103 description: Source ip.
104 source_ip6:
105 aliases: ['source-ip6']
106 type: str
107 description: Source ip6.
108 ssl:
109 type: str
110 description: Ssl.
111 choices: ['disable', 'enable']
112 ssl_trusted_cert:
113 aliases: ['ssl-trusted-cert']
114 type: str
115 description: Ssl trusted cert.
116 type:
117 type: str
118 description: Type.
119 choices: ['default', 'fortiems', 'fortinac', 'fortiems-cloud']
120 user_info_server:
121 aliases: ['user-info-server']
122 type: raw
123 description: (list or str) User info server.
124 ldap_poll:
125 aliases: ['ldap-poll']
126 type: str
127 description: Ldap poll.
128 choices: ['disable', 'enable']
129 ldap_poll_filter:
130 aliases: ['ldap-poll-filter']
131 type: str
132 description: Ldap poll filter.
133 ldap_poll_interval:
134 aliases: ['ldap-poll-interval']
135 type: int
136 description: Ldap poll interval.
137 group_poll_interval:
138 aliases: ['group-poll-interval']
139 type: int
140 description: Group poll interval.
141 interface:
142 type: str
143 description: Interface.
144 interface_select_method:
145 aliases: ['interface-select-method']
146 type: str
147 description: Interface select method.
148 choices: ['auto', 'sdwan', 'specify']
149 logon_timeout:
150 aliases: ['logon-timeout']
151 type: int
152 description: Interval in minutes to keep logons after FSSO server down.
153 sni:
154 type: str
155 description: Server Name Indication.
156 ssl_server_host_ip_check:
157 aliases: ['ssl-server-host-ip-check']
158 type: str
159 description: Enable/disable server host/IP verification.
160 choices: ['disable', 'enable']
161 vrf_select:
162 aliases: ['vrf-select']
163 type: int
164 description: VRF ID used for connection to server.
165 '''
166
167 EXAMPLES = '''
168 - name: Example playbook
169 hosts: fortimanagers
170 gather_facts: false
171 connection: httpapi
172 vars:
173 ansible_httpapi_use_ssl: true
174 ansible_httpapi_validate_certs: false
175 ansible_httpapi_port: 443
176 tasks:
177 - name: Configure dynamic mappings of Fortinet Single Sign On (FSSO) agent
178 fortinet.fortimanager.fmgr_user_fsso_dynamicmapping:
179 bypass_validation: false
180 adom: ansible
181 fsso: ansible-test-fsso # name
182 state: present
183 user_fsso_dynamicmapping:
184 _scope:
185 - name: FGT_AWS # need a valid device name
186 vdom: root # need a valid vdom name under the device
187 password: fortinet
188 port: 9000
189 server: ansible
190
191 - name: Gathering fortimanager facts
192 hosts: fortimanagers
193 gather_facts: false
194 connection: httpapi
195 vars:
196 ansible_httpapi_use_ssl: true
197 ansible_httpapi_validate_certs: false
198 ansible_httpapi_port: 443
199 tasks:
200 - name: Retrieve all the dynamic mappings of Fortinet Single Sign On (FSSO) agent
201 fortinet.fortimanager.fmgr_fact:
202 facts:
203 selector: "user_fsso_dynamicmapping"
204 params:
205 adom: "ansible"
206 fsso: "ansible-test-fsso" # name
207 dynamic_mapping: "your_value"
208 '''
209
210 RETURN = '''
211 meta:
212 description: The result of the request.
213 type: dict
214 returned: always
215 contains:
216 request_url:
217 description: The full url requested.
218 returned: always
219 type: str
220 sample: /sys/login/user
221 response_code:
222 description: The status of api request.
223 returned: always
224 type: int
225 sample: 0
226 response_data:
227 description: The api response.
228 type: list
229 returned: always
230 response_message:
231 description: The descriptive message of the api response.
232 type: str
233 returned: always
234 sample: OK.
235 system_information:
236 description: The information of the target system.
237 type: dict
238 returned: always
239 rc:
240 description: The status the request.
241 type: int
242 returned: always
243 sample: 0
244 version_check_warning:
245 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
246 type: list
247 returned: complex
248 '''
249 from ansible.module_utils.basic import AnsibleModule
250 from ansible.module_utils.connection import Connection
251 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
252 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
253
254
255 def main():
256 urls_list = [
257 '/pm/config/adom/{adom}/obj/user/fsso/{fsso}/dynamic_mapping',
258 '/pm/config/global/obj/user/fsso/{fsso}/dynamic_mapping'
259 ]
260 module_arg_spec = {
261 'adom': {'required': True, 'type': 'str'},
262 'fsso': {'required': True, 'type': 'str'},
263 'revision_note': {'type': 'str'},
264 'user_fsso_dynamicmapping': {
265 'type': 'dict', 'v_range': [['6.0.0', '']],
266 'options': {
267 '_gui_meta': {'type': 'str'},
268 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
269 'ldap-server': {'type': 'str'},
270 'password': {'no_log': True, 'type': 'raw'},
271 'password2': {'no_log': True, 'type': 'raw'},
272 'password3': {'no_log': True, 'type': 'raw'},
273 'password4': {'no_log': True, 'type': 'raw'},
274 'password5': {'no_log': True, 'type': 'raw'},
275 'port': {'type': 'int'},
276 'port2': {'type': 'int'},
277 'port3': {'type': 'int'},
278 'port4': {'type': 'int'},
279 'port5': {'type': 'int'},
280 'server': {'type': 'str'},
281 'server2': {'type': 'str'},
282 'server3': {'type': 'str'},
283 'server4': {'type': 'str'},
284 'server5': {'type': 'str'},
285 'source-ip': {'type': 'str'},
286 'source-ip6': {'type': 'str'},
287 'ssl': {'choices': ['disable', 'enable'], 'type': 'str'},
288 'ssl-trusted-cert': {'type': 'str'},
289 'type': {'choices': ['default', 'fortiems', 'fortinac', 'fortiems-cloud'], 'type': 'str'},
290 'user-info-server': {'type': 'raw'},
291 'ldap-poll': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
292 'ldap-poll-filter': {'v_range': [['6.2.1', '']], 'type': 'str'},
293 'ldap-poll-interval': {'v_range': [['6.2.1', '']], 'type': 'int'},
294 'group-poll-interval': {'v_range': [['6.2.2', '']], 'type': 'int'},
295 'interface': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
296 'interface-select-method': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['auto', 'sdwan', 'specify'], 'type': 'str'},
297 'logon-timeout': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'int'},
298 'sni': {'v_range': [['7.2.0', '']], 'type': 'str'},
299 'ssl-server-host-ip-check': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
300 'vrf-select': {'v_range': [['7.6.2', '']], 'type': 'int'}
301 }
302 }
303 }
304
305 module_option_spec = get_module_arg_spec('full crud')
306 module_arg_spec.update(module_option_spec)
307 check_galaxy_version(module_arg_spec)
308 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'user_fsso_dynamicmapping'),
309 supports_check_mode=True)
310 if not module._socket_path:
311 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
312 connection = Connection(module._socket_path)
313 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
314 'complex:{{module}}["_scope"][0]["name"]+"/"+{{module}}["_scope"][0]["vdom"]', 'data', module, connection)
315 fmgr.process_crud()
316 module.exit_json(meta=module.params)
317
318
319 if __name__ == '__main__':
320 main()