Debian Codegraph @

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