Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_checkpoint_host.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_checkpoint_host
31 short_description: Manages checkpoint-host objects on Checkpoint over Web Services API
32 description:
33 - Manages checkpoint-host objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R80.40 JHF management version.
36 version_added: "5.0.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 name:
40 description:
41 - Object name.
42 type: str
43 required: True
44 ip_address:
45 description:
46 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
47 type: str
48 ipv4_address:
49 description:
50 - IPv4 address.
51 type: str
52 ipv6_address:
53 description:
54 - IPv6 address.
55 type: str
56 interfaces:
57 description:
58 - Check Point host interfaces.
59 type: list
60 elements: dict
61 suboptions:
62 name:
63 description:
64 - Interface name.
65 type: str
66 subnet:
67 description:
68 - IPv4 or IPv6 network address. If both addresses are required use subnet4 and subnet6 fields explicitly.
69 type: str
70 subnet4:
71 description:
72 - IPv4 network address.
73 type: str
74 subnet6:
75 description:
76 - IPv6 network address.
77 type: str
78 mask_length:
79 description:
80 - IPv4 or IPv6 network mask length. If both masks are required use mask-length4 and mask-length6 fields explicitly. Instead of IPv4 mask
81 length it is possible to specify IPv4 mask itself in subnet-mask field.
82 type: int
83 mask_length4:
84 description:
85 - IPv4 network mask length.
86 type: int
87 mask_length6:
88 description:
89 - IPv6 network mask length.
90 type: int
91 subnet_mask:
92 description:
93 - IPv4 network mask.
94 type: str
95 color:
96 description:
97 - Color of the object. Should be one of existing colors.
98 type: str
99 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange',
100 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray',
101 'light green', 'lemon chiffon', 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive',
102 'orange', 'red', 'sienna', 'yellow']
103 comments:
104 description:
105 - Comments string.
106 type: str
107 details_level:
108 description:
109 - 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
110 representation of the object.
111 type: str
112 choices: ['uid', 'standard', 'full']
113 ignore_warnings:
114 description:
115 - Apply changes ignoring warnings.
116 type: bool
117 ignore_errors:
118 description:
119 - 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.
120 type: bool
121 nat_settings:
122 description:
123 - NAT settings.
124 type: dict
125 suboptions:
126 auto_rule:
127 description:
128 - Whether to add automatic address translation rules.
129 type: bool
130 ip_address:
131 description:
132 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly. This parameter is not
133 required in case "method" parameter is "hide" and "hide-behind" parameter is "gateway".
134 type: str
135 ipv4_address:
136 description:
137 - IPv4 address.
138 type: str
139 ipv6_address:
140 description:
141 - IPv6 address.
142 type: str
143 hide_behind:
144 description:
145 - Hide behind method. This parameter is forbidden in case "method" parameter is "static".
146 type: str
147 choices: ['gateway', 'ip-address']
148 install_on:
149 description:
150 - Which gateway should apply the NAT translation.
151 type: str
152 method:
153 description:
154 - NAT translation method.
155 type: str
156 choices: ['hide', 'static']
157 one_time_password:
158 description:
159 - Secure internal connection one time password.
160 type: str
161 hardware:
162 description:
163 - Hardware name.
164 type: str
165 os:
166 description:
167 - Operating system name.
168 type: str
169 check_point_host_version:
170 description:
171 - Check Point host platform version.
172 type: str
173 management_blades:
174 description:
175 - Management blades.
176 type: dict
177 suboptions:
178 network_policy_management:
179 description:
180 - Enable Network Policy Management.
181 type: bool
182 logging_and_status:
183 description:
184 - Enable Logging & Status.
185 type: bool
186 smart_event_server:
187 description:
188 - Enable SmartEvent server. </br>When activating SmartEvent server, blades 'logging-and-status' and 'smart-event-correlation' should be
189 set to True. </br>To complete SmartEvent configuration, perform Install Database or Install Policy on your Security Management servers and Log
190 servers. </br>Activating SmartEvent Server is not recommended in Management High Availability environment. For more information refer to sk25164.
191 type: bool
192 smart_event_correlation:
193 description:
194 - Enable SmartEvent Correlation Unit.
195 type: bool
196 endpoint_policy:
197 description:
198 - Enable Endpoint Policy. </br>To complete Endpoint Security Management configuration, perform Install Database on your Endpoint
199 Management Server. </br>Field is not supported on Multi Domain Server environment.
200 type: bool
201 compliance:
202 description:
203 - Compliance blade. Can be set when 'network-policy-management' was selected to be True.
204 type: bool
205 user_directory:
206 description:
207 - Enable User Directory. Can be set when 'network-policy-management' was selected to be True.
208 type: bool
209 logs_settings:
210 description:
211 - Logs settings.
212 type: dict
213 suboptions:
214 free_disk_space_metrics:
215 description:
216 - Free disk space metrics.
217 type: str
218 choices: ['mbytes', 'percent']
219 accept_syslog_messages:
220 description:
221 - Enable accept syslog messages.
222 type: bool
223 alert_when_free_disk_space_below:
224 description:
225 - Enable alert when free disk space is below threshold.
226 type: bool
227 alert_when_free_disk_space_below_threshold:
228 description:
229 - Alert when free disk space below threshold.
230 type: int
231 alert_when_free_disk_space_below_type:
232 description:
233 - Alert when free disk space below type.
234 type: str
235 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
236 'user defined alert no.3']
237 before_delete_keep_logs_from_the_last_days:
238 description:
239 - Enable before delete keep logs from the last days.
240 type: bool
241 before_delete_keep_logs_from_the_last_days_threshold:
242 description:
243 - Before delete keep logs from the last days threshold.
244 type: int
245 before_delete_run_script:
246 description:
247 - Enable Before delete run script.
248 type: bool
249 before_delete_run_script_command:
250 description:
251 - Before delete run script command.
252 type: str
253 delete_index_files_older_than_days:
254 description:
255 - Enable delete index files older than days.
256 type: bool
257 delete_index_files_older_than_days_threshold:
258 description:
259 - Delete index files older than days threshold.
260 type: int
261 delete_when_free_disk_space_below:
262 description:
263 - Enable delete when free disk space below.
264 type: bool
265 delete_when_free_disk_space_below_threshold:
266 description:
267 - Delete when free disk space below threshold.
268 type: int
269 detect_new_citrix_ica_application_names:
270 description:
271 - Enable detect new Citrix ICA application names.
272 type: bool
273 distribute_logs_between_all_active_servers:
274 description:
275 - Distribute logs between all active servers.
276 - Available from R81.20 management version.
277 type: bool
278 enable_log_indexing:
279 description:
280 - Enable log indexing.
281 type: bool
282 forward_logs_to_log_server:
283 description:
284 - Enable forward logs to log server.
285 type: bool
286 forward_logs_to_log_server_name:
287 description:
288 - Forward logs to log server name.
289 type: str
290 forward_logs_to_log_server_schedule_name:
291 description:
292 - Forward logs to log server schedule name.
293 type: str
294 rotate_log_by_file_size:
295 description:
296 - Enable rotate log by file size.
297 type: bool
298 rotate_log_file_size_threshold:
299 description:
300 - Log file size threshold.
301 type: int
302 rotate_log_on_schedule:
303 description:
304 - Enable rotate log on schedule.
305 type: bool
306 rotate_log_schedule_name:
307 description:
308 - Rotate log schedule name.
309 type: str
310 smart_event_intro_correletion_unit:
311 description:
312 - Enable SmartEvent intro correlation unit.
313 type: bool
314 stop_logging_when_free_disk_space_below:
315 description:
316 - Enable stop logging when free disk space below.
317 type: bool
318 stop_logging_when_free_disk_space_below_threshold:
319 description:
320 - Stop logging when free disk space below threshold.
321 type: int
322 turn_on_qos_logging:
323 description:
324 - Enable turn on QoS Logging.
325 type: bool
326 update_account_log_every:
327 description:
328 - Update account log in every amount of seconds.
329 type: int
330 save_logs_locally:
331 description:
332 - Enable save logs locally.
333 type: bool
334 send_alerts_to_server:
335 description:
336 - Collection of Server(s) to send alerts to identified by the name or UID.
337 type: list
338 elements: str
339 send_logs_to_backup_server:
340 description:
341 - Collection of Backup server(s) to send logs to identified by the name or UID.
342 type: list
343 elements: str
344 send_logs_to_server:
345 description:
346 - Collection of Server(s) to send logs to identified by the name or UID.
347 type: list
348 elements: str
349 tags:
350 description:
351 - Collection of tag identifiers.
352 type: list
353 elements: str
354 color:
355 description:
356 - Color of the object. Should be one of existing colors.
357 type: str
358 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
359 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
360 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
361 comments:
362 description:
363 - Comments string.
364 type: str
365 details_level:
366 description:
367 - 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
368 representation of the object.
369 type: str
370 choices: ['uid', 'standard', 'full']
371 groups:
372 description:
373 - Collection of group identifiers.
374 type: list
375 elements: str
376 ignore_warnings:
377 description:
378 - Apply changes ignoring warnings.
379 type: bool
380 ignore_errors:
381 description:
382 - 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.
383 type: bool
384 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
385 """
386
387 EXAMPLES = """
388 - name: add-checkpoint-host
389 cp_mgmt_checkpoint_host:
390 ipv4_address: 5.5.5.5
391 management_blades:
392 logging_and_status: true
393 network_policy_management: true
394 name: secondarylogserver
395 state: present
396
397 - name: set-checkpoint-host
398 cp_mgmt_checkpoint_host:
399 hardware: Smart-1
400 management_blades:
401 compliance: true
402 network_policy_management: true
403 user_directory: true
404 name: secondarylogserver
405 os: Linux
406 state: present
407
408 - name: delete-checkpoint-host
409 cp_mgmt_checkpoint_host:
410 name: secondarylogserver
411 state: absent
412 """
413
414 RETURN = """
415 cp_mgmt_checkpoint_host:
416 description: The checkpoint object created or updated.
417 returned: always, except when deleting the object.
418 type: dict
419 """
420
421 from ansible.module_utils.basic import AnsibleModule
422 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
423
424
425 def main():
426 argument_spec = dict(
427 name=dict(type='str', required=True),
428 ip_address=dict(type='str'),
429 ipv4_address=dict(type='str'),
430 ipv6_address=dict(type='str'),
431 interfaces=dict(type='list', elements='dict', options=dict(
432 name=dict(type='str'),
433 subnet=dict(type='str'),
434 subnet4=dict(type='str'),
435 subnet6=dict(type='str'),
436 mask_length=dict(type='int'),
437 mask_length4=dict(type='int'),
438 mask_length6=dict(type='int'),
439 subnet_mask=dict(type='str'),
440 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan',
441 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick',
442 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral',
443 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red',
444 'sienna', 'yellow']),
445 comments=dict(type='str'),
446 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
447 ignore_warnings=dict(type='bool'),
448 ignore_errors=dict(type='bool')
449 )),
450 nat_settings=dict(type='dict', options=dict(
451 auto_rule=dict(type='bool'),
452 ip_address=dict(type='str'),
453 ipv4_address=dict(type='str'),
454 ipv6_address=dict(type='str'),
455 hide_behind=dict(type='str', choices=['gateway', 'ip-address']),
456 install_on=dict(type='str'),
457 method=dict(type='str', choices=['hide', 'static'])
458 )),
459 one_time_password=dict(type='str', no_log=True),
460 hardware=dict(type='str'),
461 os=dict(type='str'),
462 check_point_host_version=dict(type='str'),
463 management_blades=dict(type='dict', options=dict(
464 network_policy_management=dict(type='bool'),
465 logging_and_status=dict(type='bool'),
466 smart_event_server=dict(type='bool'),
467 smart_event_correlation=dict(type='bool'),
468 endpoint_policy=dict(type='bool'),
469 compliance=dict(type='bool'),
470 user_directory=dict(type='bool')
471 )),
472 logs_settings=dict(type='dict', options=dict(
473 free_disk_space_metrics=dict(type='str', choices=['mbytes', 'percent']),
474 accept_syslog_messages=dict(type='bool'),
475 alert_when_free_disk_space_below=dict(type='bool'),
476 alert_when_free_disk_space_below_threshold=dict(type='int'),
477 alert_when_free_disk_space_below_type=dict(type='str', choices=['none',
478 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1',
479 'user defined alert no.2', 'user defined alert no.3']),
480 before_delete_keep_logs_from_the_last_days=dict(type='bool'),
481 before_delete_keep_logs_from_the_last_days_threshold=dict(type='int'),
482 before_delete_run_script=dict(type='bool'),
483 before_delete_run_script_command=dict(type='str'),
484 delete_index_files_older_than_days=dict(type='bool'),
485 delete_index_files_older_than_days_threshold=dict(type='int'),
486 delete_when_free_disk_space_below=dict(type='bool'),
487 delete_when_free_disk_space_below_threshold=dict(type='int'),
488 detect_new_citrix_ica_application_names=dict(type='bool'),
489 distribute_logs_between_all_active_servers=dict(type='bool'),
490 enable_log_indexing=dict(type='bool'),
491 forward_logs_to_log_server=dict(type='bool'),
492 forward_logs_to_log_server_name=dict(type='str'),
493 forward_logs_to_log_server_schedule_name=dict(type='str'),
494 rotate_log_by_file_size=dict(type='bool'),
495 rotate_log_file_size_threshold=dict(type='int'),
496 rotate_log_on_schedule=dict(type='bool'),
497 rotate_log_schedule_name=dict(type='str'),
498 smart_event_intro_correletion_unit=dict(type='bool'),
499 stop_logging_when_free_disk_space_below=dict(type='bool'),
500 stop_logging_when_free_disk_space_below_threshold=dict(type='int'),
501 turn_on_qos_logging=dict(type='bool'),
502 update_account_log_every=dict(type='int')
503 )),
504 save_logs_locally=dict(type='bool'),
505 send_alerts_to_server=dict(type='list', elements='str'),
506 send_logs_to_backup_server=dict(type='list', elements='str'),
507 send_logs_to_server=dict(type='list', elements='str'),
508 tags=dict(type='list', elements='str'),
509 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
510 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
511 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
512 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
513 'yellow']),
514 comments=dict(type='str'),
515 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
516 groups=dict(type='list', elements='str'),
517 ignore_warnings=dict(type='bool'),
518 ignore_errors=dict(type='bool')
519 )
520 argument_spec.update(checkpoint_argument_spec_for_objects)
521
522 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
523 api_call_object = 'checkpoint-host'
524
525 result = api_call(module, api_call_object)
526 module.exit_json(**result)
527
528
529 if __name__ == '__main__':
530 main()