Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_resource_smtp.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage CheckPoint Firewall (c) 2019
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 from __future__ import (absolute_import, division, print_function)
21
22 __metaclass__ = type
23
24 ANSIBLE_METADATA = {'metadata_version': '1.1',
25 'status': ['preview'],
26 'supported_by': 'community'}
27
28 DOCUMENTATION = """
29 ---
30 module: cp_mgmt_resource_smtp
31 short_description: Manages resource-smtp objects on Checkpoint over Web Services API
32 description:
33 - Manages resource-smtp objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82 management version.
36 version_added: "6.0.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 mail_delivery_server:
45 description:
46 - Specify the server to which mail is forwarded.
47 type: str
48 deliver_messages_using_dns_mx_records:
49 description:
50 - MX record resolving is used to set the destination IP address of the connection.
51 type: bool
52 check_rulebase_with_new_destination:
53 description:
54 - The Rule Base will be rechecked with the new resolved IP address for mail delivery.
55 type: bool
56 notify_sender_on_error:
57 description:
58 - Enable error mail delivery.
59 type: bool
60 error_mail_delivery_server:
61 description:
62 - Error mail delivery happens if the SMTP security server is unable to deliver the message within the abandon time, and Notify Sender on Error
63 is checked.
64 type: str
65 error_deliver_messages_using_dns_mx_records:
66 description:
67 - MX record resolving will be used to set the source IP address of the connection used to send the error message.
68 type: bool
69 error_check_rulebase_with_new_destination:
70 description:
71 - The Rule Base will be rechecked with the new resolved IP address for error mail delivery.
72 type: bool
73 exception_track:
74 description:
75 - Determines if an action specified in the Action 2 and CVP categories taken as a result of a resource definition is logged.
76 type: str
77 choices: ['none', 'exception log', 'exception alert']
78 match:
79 description:
80 - Set the Match properties for the SMTP resource.
81 type: dict
82 suboptions:
83 sender:
84 description:
85 - Set the Match sender property for the SMTP resource.
86 type: str
87 recipient:
88 description:
89 - Set the Match recipient property for the SMTP resource.
90 type: str
91 action_1:
92 description:
93 - Use the Rewriting Rules to rewrite Sender and Recipient headers in emails, you can also rewrite other email headers by using the custom header field.
94 type: dict
95 suboptions:
96 sender:
97 description:
98 - Rewrite Sender header.
99 type: dict
100 suboptions:
101 original:
102 description:
103 - Original field.
104 type: str
105 rewritten:
106 description:
107 - Replacement field.
108 type: str
109 recipient:
110 description:
111 - Rewrite Recipient header.
112 type: dict
113 suboptions:
114 original:
115 description:
116 - Original field.
117 type: str
118 rewritten:
119 description:
120 - Replacement field.
121 type: str
122 custom_field:
123 description:
124 - The name of the header.
125 type: dict
126 suboptions:
127 original:
128 description:
129 - Original field.
130 type: str
131 rewritten:
132 description:
133 - Replacement field.
134 type: str
135 field:
136 description:
137 - The name of the header.
138 type: str
139 action_2:
140 description:
141 - Use this window to configure mail inspection for the SMTP Resource.
142 type: dict
143 suboptions:
144 strip_mime_of_type:
145 description:
146 - Specifies the MIME type to strip from the message.
147 type: str
148 strip_file_by_name:
149 description:
150 - Strips file attachments of the specified name from the message.
151 type: str
152 mail_capacity:
153 description:
154 - Restrict the size (in kb) of incoming email attachments.
155 type: int
156 allowed_characters:
157 description:
158 - The MIME email headers can consist of 8 or 7 bit characters (7 ASCII and 8 for sending Binary characters) in order to encode mail data.
159 type: str
160 choices: ['8_bit', '7_bit']
161 strip_script_tags:
162 description:
163 - Strip JAVA scripts.
164 type: bool
165 strip_applet_tags:
166 description:
167 - Strip JAVA applets.
168 type: bool
169 strip_activex_tags:
170 description:
171 - Strip activeX tags.
172 type: bool
173 strip_ftp_links:
174 description:
175 - Strip ftp links.
176 type: bool
177 strip_port_strings:
178 description:
179 - Strip ports.
180 type: bool
181 cvp:
182 description:
183 - Configure CVP inspection on mail messages.
184 type: dict
185 suboptions:
186 enable_cvp:
187 description:
188 - Select to enable the Content Vectoring Protocol.
189 type: bool
190 server:
191 description:
192 - The UID or Name of the CVP server, make sure the CVP server is already be defined as an OPSEC Application.
193 type: str
194 allowed_to_modify_content:
195 description:
196 - Configures the CVP server to inspect but not modify content.
197 type: bool
198 reply_order:
199 description:
200 - Designates when the CVP server returns data to the Security Gateway security server.
201 type: str
202 choices: ['return_data_after_content_is_approved', 'return_data_before_content_is_approved']
203 tags:
204 description:
205 - Collection of tag identifiers.
206 type: list
207 elements: str
208 color:
209 description:
210 - Color of the object. Should be one of existing colors.
211 type: str
212 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
213 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
214 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
215 comments:
216 description:
217 - Comments string.
218 type: str
219 details_level:
220 description:
221 - The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed
222 representation of the object.
223 type: str
224 choices: ['uid', 'standard', 'full']
225 ignore_warnings:
226 description:
227 - Apply changes ignoring warnings.
228 type: bool
229 ignore_errors:
230 description:
231 - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
232 type: bool
233 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
234 """
235
236 EXAMPLES = """
237 - name: add-resource-smtp
238 cp_mgmt_resource_smtp:
239 deliver_messages_using_dns_mx_records: 'true'
240 exception_track: exception log
241 mail_delivery_server: deliverServer
242 match:
243 recipient: recipientName
244 sender: senderName
245 name: newSmtpResource
246 state: present
247
248 - name: set-resource-smtp
249 cp_mgmt_resource_smtp:
250 mail_delivery_server: newServer
251 name: newSmtpResource
252 state: present
253
254 - name: delete-resource-smtp
255 cp_mgmt_resource_smtp:
256 name: newSmtpResource
257 state: absent
258 """
259
260 RETURN = """
261 cp_mgmt_resource_smtp:
262 description: The checkpoint object created or updated.
263 returned: always, except when deleting the object.
264 type: dict
265 """
266
267 from ansible.module_utils.basic import AnsibleModule
268 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
269
270
271 def main():
272 argument_spec = dict(
273 name=dict(type='str', required=True),
274 mail_delivery_server=dict(type='str'),
275 deliver_messages_using_dns_mx_records=dict(type='bool'),
276 check_rulebase_with_new_destination=dict(type='bool'),
277 notify_sender_on_error=dict(type='bool'),
278 error_mail_delivery_server=dict(type='str'),
279 error_deliver_messages_using_dns_mx_records=dict(type='bool'),
280 error_check_rulebase_with_new_destination=dict(type='bool'),
281 exception_track=dict(type='str', choices=['none', 'exception log', 'exception alert']),
282 match=dict(type='dict', options=dict(
283 sender=dict(type='str'),
284 recipient=dict(type='str')
285 )),
286 action_1=dict(type='dict', options=dict(
287 sender=dict(type='dict', options=dict(
288 original=dict(type='str'),
289 rewritten=dict(type='str')
290 )),
291 recipient=dict(type='dict', options=dict(
292 original=dict(type='str'),
293 rewritten=dict(type='str')
294 )),
295 custom_field=dict(type='dict', options=dict(
296 original=dict(type='str'),
297 rewritten=dict(type='str'),
298 field=dict(type='str')
299 ))
300 )),
301 action_2=dict(type='dict', options=dict(
302 strip_mime_of_type=dict(type='str'),
303 strip_file_by_name=dict(type='str'),
304 mail_capacity=dict(type='int'),
305 allowed_characters=dict(type='str', choices=['8_bit', '7_bit']),
306 strip_script_tags=dict(type='bool'),
307 strip_applet_tags=dict(type='bool'),
308 strip_activex_tags=dict(type='bool'),
309 strip_ftp_links=dict(type='bool'),
310 strip_port_strings=dict(type='bool')
311 )),
312 cvp=dict(type='dict', options=dict(
313 enable_cvp=dict(type='bool'),
314 server=dict(type='str'),
315 allowed_to_modify_content=dict(type='bool'),
316 reply_order=dict(type='str', choices=['return_data_after_content_is_approved', 'return_data_before_content_is_approved'])
317 )),
318 tags=dict(type='list', elements='str'),
319 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
320 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
321 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
322 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
323 'yellow']),
324 comments=dict(type='str'),
325 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
326 ignore_warnings=dict(type='bool'),
327 ignore_errors=dict(type='bool')
328 )
329 argument_spec.update(checkpoint_argument_spec_for_objects)
330
331 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
332 api_call_object = 'resource-smtp'
333
334 result = api_call(module, api_call_object)
335 module.exit_json(**result)
336
337
338 if __name__ == '__main__':
339 main()