Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_webproxy_explicitproxy.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_webproxy_explicitproxy
15 short_description: Web proxy explicit proxy
16 version_added: "2.12.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 webproxy_explicitproxy:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 detect_https_in_http_request:
34 aliases: ['detect-https-in-http-request']
35 type: str
36 description: Detect https in http request.
37 choices: ['disable', 'enable']
38 dns_mode:
39 aliases: ['dns-mode']
40 type: str
41 description: Dns mode.
42 choices: ['recursive', 'non-recursive', 'forward-only']
43 dstport_from_incoming:
44 aliases: ['dstport-from-incoming']
45 type: str
46 description: Dstport from incoming.
47 choices: ['disable', 'enable']
48 ftp_incoming_port:
49 aliases: ['ftp-incoming-port']
50 type: list
51 elements: str
52 description: Ftp incoming port.
53 ftp_over_http:
54 aliases: ['ftp-over-http']
55 type: str
56 description: Ftp over http.
57 choices: ['disable', 'enable']
58 header_proxy_agent:
59 aliases: ['header-proxy-agent']
60 type: str
61 description: Header proxy agent.
62 choices: ['disable', 'enable']
63 http:
64 type: str
65 description: Http.
66 choices: ['disable', 'enable']
67 http_connection_mode:
68 aliases: ['http-connection-mode']
69 type: str
70 description: Http connection mode.
71 choices: ['static', 'multiplex', 'serverpool']
72 http_incoming_port:
73 aliases: ['http-incoming-port']
74 type: list
75 elements: str
76 description: Http incoming port.
77 https_incoming_port:
78 aliases: ['https-incoming-port']
79 type: list
80 elements: str
81 description: Https incoming port.
82 incoming_ip6:
83 aliases: ['incoming-ip6']
84 type: str
85 description: Incoming ip6.
86 interface:
87 type: list
88 elements: str
89 description: Interface.
90 ipv6_status:
91 aliases: ['ipv6-status']
92 type: str
93 description: Ipv6 status.
94 choices: ['disable', 'enable']
95 learn_dst_from_sni:
96 aliases: ['learn-dst-from-sni']
97 type: str
98 description: Learn dst from sni.
99 choices: ['disable', 'enable']
100 name:
101 type: str
102 description: Name.
103 required: true
104 pac_file_data:
105 aliases: ['pac-file-data']
106 type: str
107 description: Pac file data.
108 pac_file_name:
109 aliases: ['pac-file-name']
110 type: str
111 description: Pac file name.
112 pac_file_server_port:
113 aliases: ['pac-file-server-port']
114 type: str
115 description: Pac file server port.
116 pac_file_server_status:
117 aliases: ['pac-file-server-status']
118 type: str
119 description: Pac file server status.
120 choices: ['disable', 'enable']
121 pac_file_through_https:
122 aliases: ['pac-file-through-https']
123 type: str
124 description: Pac file through https.
125 choices: ['disable', 'enable']
126 pac_file_url:
127 aliases: ['pac-file-url']
128 type: str
129 description: Pac file url.
130 pref_dns_result:
131 aliases: ['pref-dns-result']
132 type: str
133 description: Pref dns result.
134 choices: ['ipv4', 'ipv6', 'ipv4-strict', 'ipv6-strict']
135 realm:
136 type: str
137 description: Realm.
138 return_to_sender:
139 aliases: ['return-to-sender']
140 type: str
141 description: Return to sender.
142 choices: ['disable', 'enable']
143 sec_default_action:
144 aliases: ['sec-default-action']
145 type: str
146 description: Sec default action.
147 choices: ['deny', 'accept']
148 secure_web_proxy:
149 aliases: ['secure-web-proxy']
150 type: str
151 description: Secure web proxy.
152 choices: ['disable', 'enable', 'secure']
153 secure_web_proxy_cert:
154 aliases: ['secure-web-proxy-cert']
155 type: list
156 elements: str
157 description: Secure web proxy cert.
158 socks:
159 type: str
160 description: Socks.
161 choices: ['disable', 'enable']
162 socks_incoming_port:
163 aliases: ['socks-incoming-port']
164 type: list
165 elements: str
166 description: Socks incoming port.
167 ssl_algorithm:
168 aliases: ['ssl-algorithm']
169 type: str
170 description: Ssl algorithm.
171 choices: ['high', 'low', 'medium']
172 ssl_dh_bits:
173 aliases: ['ssl-dh-bits']
174 type: str
175 description: Ssl dh bits.
176 choices: ['768', '1024', '1536', '2048']
177 status:
178 type: str
179 description: Status.
180 choices: ['disable', 'enable']
181 unknown_http_version:
182 aliases: ['unknown-http-version']
183 type: str
184 description: Unknown http version.
185 choices: ['best-effort', 'reject']
186 incoming_ip:
187 aliases: ['incoming-ip']
188 type: str
189 description: Incoming ip.
190 client_cert:
191 aliases: ['client-cert']
192 type: str
193 description: Client cert.
194 choices: ['disable', 'enable']
195 empty_cert_action:
196 aliases: ['empty-cert-action']
197 type: str
198 description: Empty cert action.
199 choices: ['block', 'accept', 'accept-unmanageable']
200 user_agent_detect:
201 aliases: ['user-agent-detect']
202 type: str
203 description: User agent detect.
204 choices: ['disable', 'enable']
205 '''
206
207 EXAMPLES = '''
208 - name: Example playbook (generated based on argument schema)
209 hosts: fortimanagers
210 connection: httpapi
211 gather_facts: false
212 tasks:
213 - name: Web proxy explicit proxy
214 fortinet.fortimanager.fmgr_webproxy_explicitproxy:
215 # workspace_locking_adom: <global or your adom name>
216 adom: <your own value>
217 state: present # <value in [present, absent]>
218 webproxy_explicitproxy:
219 name: "your value" # Required variable, string
220 # detect_https_in_http_request: <value in [disable, enable]>
221 # dns_mode: <value in [recursive, non-recursive, forward-only]>
222 # dstport_from_incoming: <value in [disable, enable]>
223 # ftp_incoming_port: <list or string>
224 # ftp_over_http: <value in [disable, enable]>
225 # header_proxy_agent: <value in [disable, enable]>
226 # http: <value in [disable, enable]>
227 # http_connection_mode: <value in [static, multiplex, serverpool]>
228 # http_incoming_port: <list or string>
229 # https_incoming_port: <list or string>
230 # incoming_ip6: <string>
231 # interface: <list or string>
232 # ipv6_status: <value in [disable, enable]>
233 # learn_dst_from_sni: <value in [disable, enable]>
234 # pac_file_data: <string>
235 # pac_file_name: <string>
236 # pac_file_server_port: <string>
237 # pac_file_server_status: <value in [disable, enable]>
238 # pac_file_through_https: <value in [disable, enable]>
239 # pac_file_url: <string>
240 # pref_dns_result: <value in [ipv4, ipv6, ipv4-strict, ...]>
241 # realm: <string>
242 # return_to_sender: <value in [disable, enable]>
243 # sec_default_action: <value in [deny, accept]>
244 # secure_web_proxy: <value in [disable, enable, secure]>
245 # secure_web_proxy_cert: <list or string>
246 # socks: <value in [disable, enable]>
247 # socks_incoming_port: <list or string>
248 # ssl_algorithm: <value in [high, low, medium]>
249 # ssl_dh_bits: <value in [768, 1024, 1536, ...]>
250 # status: <value in [disable, enable]>
251 # unknown_http_version: <value in [best-effort, reject]>
252 # incoming_ip: <string>
253 # client_cert: <value in [disable, enable]>
254 # empty_cert_action: <value in [block, accept, accept-unmanageable]>
255 # user_agent_detect: <value in [disable, enable]>
256 '''
257
258 RETURN = '''
259 meta:
260 description: The result of the request.
261 type: dict
262 returned: always
263 contains:
264 request_url:
265 description: The full url requested.
266 returned: always
267 type: str
268 sample: /sys/login/user
269 response_code:
270 description: The status of api request.
271 returned: always
272 type: int
273 sample: 0
274 response_data:
275 description: The api response.
276 type: list
277 returned: always
278 response_message:
279 description: The descriptive message of the api response.
280 type: str
281 returned: always
282 sample: OK.
283 system_information:
284 description: The information of the target system.
285 type: dict
286 returned: always
287 rc:
288 description: The status the request.
289 type: int
290 returned: always
291 sample: 0
292 version_check_warning:
293 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
294 type: list
295 returned: complex
296 '''
297 from ansible.module_utils.basic import AnsibleModule
298 from ansible.module_utils.connection import Connection
299 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
300 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
301
302
303 def main():
304 urls_list = [
305 '/pm/config/adom/{adom}/obj/web-proxy/explicit-proxy',
306 '/pm/config/global/obj/web-proxy/explicit-proxy'
307 ]
308 module_arg_spec = {
309 'adom': {'required': True, 'type': 'str'},
310 'revision_note': {'type': 'str'},
311 'webproxy_explicitproxy': {
312 'type': 'dict', 'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']],
313 'options': {
314 'detect-https-in-http-request': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
315 'dns-mode': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['recursive', 'non-recursive', 'forward-only'], 'type': 'str'},
316 'dstport-from-incoming': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
317 'ftp-incoming-port': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
318 'ftp-over-http': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
319 'header-proxy-agent': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
320 'http': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
321 'http-connection-mode': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['static', 'multiplex', 'serverpool'], 'type': 'str'},
322 'http-incoming-port': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
323 'https-incoming-port': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
324 'incoming-ip6': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
325 'interface': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
326 'ipv6-status': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
327 'learn-dst-from-sni': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
328 'name': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'required': True, 'type': 'str'},
329 'pac-file-data': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
330 'pac-file-name': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
331 'pac-file-server-port': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
332 'pac-file-server-status': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
333 'pac-file-through-https': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
334 'pac-file-url': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
335 'pref-dns-result': {
336 'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']],
337 'choices': ['ipv4', 'ipv6', 'ipv4-strict', 'ipv6-strict'],
338 'type': 'str'
339 },
340 'realm': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
341 'return-to-sender': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
342 'sec-default-action': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['deny', 'accept'], 'type': 'str'},
343 'secure-web-proxy': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable', 'secure'], 'type': 'str'},
344 'secure-web-proxy-cert': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
345 'socks': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
346 'socks-incoming-port': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'list', 'elements': 'str'},
347 'ssl-algorithm': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['high', 'low', 'medium'], 'type': 'str'},
348 'ssl-dh-bits': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['768', '1024', '1536', '2048'], 'type': 'str'},
349 'status': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
350 'unknown-http-version': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['best-effort', 'reject'], 'type': 'str'},
351 'incoming-ip': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
352 'client-cert': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
353 'empty-cert-action': {'v_range': [['7.6.4', '']], 'choices': ['block', 'accept', 'accept-unmanageable'], 'type': 'str'},
354 'user-agent-detect': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
355 }
356 }
357 }
358
359 module_option_spec = get_module_arg_spec('full crud')
360 module_arg_spec.update(module_option_spec)
361 check_galaxy_version(module_arg_spec)
362 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'webproxy_explicitproxy'),
363 supports_check_mode=True)
364 if not module._socket_path:
365 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
366 connection = Connection(module._socket_path)
367 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
368 'name', 'data', module, connection)
369 fmgr.process_crud()
370 module.exit_json(meta=module.params)
371
372
373 if __name__ == '__main__':
374 main()