Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_sslsshprofile_ssl.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_firewall_sslsshprofile_ssl
15 short_description: Configure SSL options.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_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 ssl-ssh-profile:
29 description: Deprecated, please use "ssl_ssh_profile"
30 type: str
31 ssl_ssh_profile:
32 description: The parameter (ssl-ssh-profile) in requested url.
33 type: str
34 firewall_sslsshprofile_ssl:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 allow_invalid_server_cert:
40 aliases: ['allow-invalid-server-cert']
41 type: str
42 description: When enabled, allows SSL sessions whose server certificate validation failed.
43 choices: ['disable', 'enable']
44 client_cert_request:
45 aliases: ['client-cert-request']
46 type: str
47 description: Action based on client certificate request.
48 choices: ['bypass', 'inspect', 'block']
49 inspect_all:
50 aliases: ['inspect-all']
51 type: str
52 description: Level of SSL inspection.
53 choices: ['disable', 'certificate-inspection', 'deep-inspection']
54 unsupported_ssl:
55 aliases: ['unsupported-ssl']
56 type: str
57 description: Action based on the SSL encryption used being unsupported.
58 choices: ['bypass', 'inspect', 'block']
59 untrusted_cert:
60 aliases: ['untrusted-cert']
61 type: str
62 description: Allow, ignore, or block the untrusted SSL session server certificate.
63 choices: ['allow', 'block', 'ignore']
64 invalid_server_cert:
65 aliases: ['invalid-server-cert']
66 type: str
67 description: Allow or block the invalid SSL session server certificate.
68 choices: ['allow', 'block']
69 sni_server_cert_check:
70 aliases: ['sni-server-cert-check']
71 type: str
72 description: Check the SNI in the client hello message with the CN or SAN fields in the returned server certificate.
73 choices: ['disable', 'enable', 'strict']
74 untrusted_server_cert:
75 aliases: ['untrusted-server-cert']
76 type: str
77 description: Allow, ignore, or block the untrusted SSL session server certificate.
78 choices: ['allow', 'block', 'ignore']
79 cert_validation_failure:
80 aliases: ['cert-validation-failure']
81 type: str
82 description: Action based on certificate validation failure.
83 choices: ['allow', 'block', 'ignore']
84 cert_validation_timeout:
85 aliases: ['cert-validation-timeout']
86 type: str
87 description: Action based on certificate validation timeout.
88 choices: ['allow', 'block', 'ignore']
89 client_certificate:
90 aliases: ['client-certificate']
91 type: str
92 description: Action based on received client certificate.
93 choices: ['bypass', 'inspect', 'block', 'bypass-on-cert-req']
94 expired_server_cert:
95 aliases: ['expired-server-cert']
96 type: str
97 description: Action based on server certificate is expired.
98 choices: ['allow', 'block', 'ignore']
99 revoked_server_cert:
100 aliases: ['revoked-server-cert']
101 type: str
102 description: Action based on server certificate is revoked.
103 choices: ['allow', 'block', 'ignore']
104 unsupported_ssl_cipher:
105 aliases: ['unsupported-ssl-cipher']
106 type: str
107 description: Action based on the SSL cipher used being unsupported.
108 choices: ['allow', 'block']
109 unsupported_ssl_negotiation:
110 aliases: ['unsupported-ssl-negotiation']
111 type: str
112 description: Action based on the SSL negotiation used being unsupported.
113 choices: ['allow', 'block']
114 cert_probe_failure:
115 aliases: ['cert-probe-failure']
116 type: str
117 description: Action based on certificate probe failure.
118 choices: ['block', 'allow']
119 min_allowed_ssl_version:
120 aliases: ['min-allowed-ssl-version']
121 type: str
122 description: Minimum SSL version to be allowed.
123 choices: ['ssl-3.0', 'tls-1.0', 'tls-1.1', 'tls-1.2', 'tls-1.3']
124 unsupported_ssl_version:
125 aliases: ['unsupported-ssl-version']
126 type: str
127 description: Action based on the SSL version used being unsupported.
128 choices: ['block', 'allow', 'inspect']
129 encrypted_client_hello:
130 aliases: ['encrypted-client-hello']
131 type: str
132 description: Block/allow session based on existence of encrypted-client-hello.
133 choices: ['block', 'allow']
134 '''
135
136 EXAMPLES = '''
137 - name: Example playbook (generated based on argument schema)
138 hosts: fortimanagers
139 connection: httpapi
140 gather_facts: false
141 tasks:
142 - name: Configure SSL options.
143 fortinet.fortimanager.fmgr_firewall_sslsshprofile_ssl:
144 # workspace_locking_adom: <global or your adom name>
145 adom: <your own value>
146 ssl_ssh_profile: <your own value>
147 firewall_sslsshprofile_ssl:
148 # allow_invalid_server_cert: <value in [disable, enable]>
149 # client_cert_request: <value in [bypass, inspect, block]>
150 # inspect_all: <value in [disable, certificate-inspection, deep-inspection]>
151 # unsupported_ssl: <value in [bypass, inspect, block]>
152 # untrusted_cert: <value in [allow, block, ignore]>
153 # invalid_server_cert: <value in [allow, block]>
154 # sni_server_cert_check: <value in [disable, enable, strict]>
155 # untrusted_server_cert: <value in [allow, block, ignore]>
156 # cert_validation_failure: <value in [allow, block, ignore]>
157 # cert_validation_timeout: <value in [allow, block, ignore]>
158 # client_certificate: <value in [bypass, inspect, block, ...]>
159 # expired_server_cert: <value in [allow, block, ignore]>
160 # revoked_server_cert: <value in [allow, block, ignore]>
161 # unsupported_ssl_cipher: <value in [allow, block]>
162 # unsupported_ssl_negotiation: <value in [allow, block]>
163 # cert_probe_failure: <value in [block, allow]>
164 # min_allowed_ssl_version: <value in [ssl-3.0, tls-1.0, tls-1.1, ...]>
165 # unsupported_ssl_version: <value in [block, allow, inspect]>
166 # encrypted_client_hello: <value in [block, allow]>
167 '''
168
169 RETURN = '''
170 meta:
171 description: The result of the request.
172 type: dict
173 returned: always
174 contains:
175 request_url:
176 description: The full url requested.
177 returned: always
178 type: str
179 sample: /sys/login/user
180 response_code:
181 description: The status of api request.
182 returned: always
183 type: int
184 sample: 0
185 response_data:
186 description: The api response.
187 type: list
188 returned: always
189 response_message:
190 description: The descriptive message of the api response.
191 type: str
192 returned: always
193 sample: OK.
194 system_information:
195 description: The information of the target system.
196 type: dict
197 returned: always
198 rc:
199 description: The status the request.
200 type: int
201 returned: always
202 sample: 0
203 version_check_warning:
204 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
205 type: list
206 returned: complex
207 '''
208 from ansible.module_utils.basic import AnsibleModule
209 from ansible.module_utils.connection import Connection
210 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
211 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
212
213
214 def main():
215 urls_list = [
216 '/pm/config/adom/{adom}/obj/firewall/ssl-ssh-profile/{ssl-ssh-profile}/ssl',
217 '/pm/config/global/obj/firewall/ssl-ssh-profile/{ssl-ssh-profile}/ssl'
218 ]
219 module_arg_spec = {
220 'adom': {'required': True, 'type': 'str'},
221 'ssl-ssh-profile': {'type': 'str', 'api_name': 'ssl_ssh_profile'},
222 'ssl_ssh_profile': {'type': 'str'},
223 'revision_note': {'type': 'str'},
224 'firewall_sslsshprofile_ssl': {
225 'type': 'dict', 'v_range': [['6.0.0', '']],
226 'options': {
227 'allow-invalid-server-cert': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'choices': ['disable', 'enable'], 'type': 'str'},
228 'client-cert-request': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['bypass', 'inspect', 'block'], 'type': 'str'},
229 'inspect-all': {'choices': ['disable', 'certificate-inspection', 'deep-inspection'], 'type': 'str'},
230 'unsupported-ssl': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['bypass', 'inspect', 'block'], 'type': 'str'},
231 'untrusted-cert': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
232 'invalid-server-cert': {'v_range': [['6.2.0', '7.6.2']], 'choices': ['allow', 'block'], 'type': 'str'},
233 'sni-server-cert-check': {'v_range': [['6.2.0', '']], 'choices': ['disable', 'enable', 'strict'], 'type': 'str'},
234 'untrusted-server-cert': {'v_range': [['6.2.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
235 'cert-validation-failure': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
236 'cert-validation-timeout': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
237 'client-certificate': {'v_range': [['6.4.0', '']], 'choices': ['bypass', 'inspect', 'block', 'bypass-on-cert-req'], 'type': 'str'},
238 'expired-server-cert': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
239 'revoked-server-cert': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
240 'unsupported-ssl-cipher': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block'], 'type': 'str'},
241 'unsupported-ssl-negotiation': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block'], 'type': 'str'},
242 'cert-probe-failure': {'v_range': [['7.0.1', '']], 'choices': ['block', 'allow'], 'type': 'str'},
243 'min-allowed-ssl-version': {'v_range': [['7.0.3', '']], 'choices': ['ssl-3.0', 'tls-1.0', 'tls-1.1', 'tls-1.2', 'tls-1.3'], 'type': 'str'},
244 'unsupported-ssl-version': {'v_range': [['7.0.1', '']], 'choices': ['block', 'allow', 'inspect'], 'type': 'str'},
245 'encrypted-client-hello': {'v_range': [['7.4.3', '']], 'choices': ['block', 'allow'], 'type': 'str'}
246 }
247 }
248 }
249
250 module_option_spec = get_module_arg_spec('partial crud')
251 module_arg_spec.update(module_option_spec)
252 check_galaxy_version(module_arg_spec)
253 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_sslsshprofile_ssl'),
254 supports_check_mode=True)
255 if not module._socket_path:
256 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
257 connection = Connection(module._socket_path)
258 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
259 None, 'data', module, connection)
260 fmgr.process_partial_crud()
261 module.exit_json(meta=module.params)
262
263
264 if __name__ == '__main__':
265 main()