Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage Check Point 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 = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_simple_gateway
33 short_description: Manages simple-gateway objects on Check Point over Web Services API
34 description:
35 - Manages simple-gateway objects on Check Point devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R80 management version.
38 version_added: "1.0.0"
39 author: "Or Soffer (@chkp-orso)"
40 options:
41 name:
42 description:
43 - Object name.
44 type: str
45 required: True
46 ip_address:
47 description:
48 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
49 type: str
50 ipv4_address:
51 description:
52 - IPv4 address.
53 type: str
54 ipv6_address:
55 description:
56 - IPv6 address.
57 type: str
58 anti_bot:
59 description:
60 - Anti-Bot blade enabled.
61 type: bool
62 anti_virus:
63 description:
64 - Anti-Virus blade enabled.
65 type: bool
66 application_control:
67 description:
68 - Application Control blade enabled.
69 type: bool
70 content_awareness:
71 description:
72 - Content Awareness blade enabled.
73 - Available from R80.10 management version.
74 type: bool
75 enable_https_inspection:
76 description:
77 - Enable HTTPS Inspection after defining an outbound inspection certificate. <br>To define the outbound certificate use outbound inspection
78 certificate API.
79 type: bool
80 firewall:
81 description:
82 - Firewall blade enabled.
83 type: bool
84 firewall_settings:
85 description:
86 - N/A
87 type: dict
88 suboptions:
89 auto_calculate_connections_hash_table_size_and_memory_pool:
90 description:
91 - N/A
92 type: bool
93 auto_maximum_limit_for_concurrent_connections:
94 description:
95 - N/A
96 type: bool
97 connections_hash_size:
98 description:
99 - N/A
100 type: int
101 maximum_limit_for_concurrent_connections:
102 description:
103 - N/A
104 type: int
105 maximum_memory_pool_size:
106 description:
107 - N/A
108 type: int
109 memory_pool_size:
110 description:
111 - N/A
112 type: int
113 interfaces:
114 description:
115 - Network interfaces. When a gateway is updated with a new interfaces, the existing interfaces are removed.
116 type: list
117 elements: dict
118 suboptions:
119 name:
120 description:
121 - Object name.
122 type: str
123 anti_spoofing:
124 description:
125 - N/A
126 type: bool
127 anti_spoofing_settings:
128 description:
129 - N/A
130 type: dict
131 suboptions:
132 action:
133 description:
134 - If packets will be rejected (the Prevent option) or whether the packets will be monitored (the Detect option).
135 type: str
136 choices: ['prevent', 'detect']
137 ip_address:
138 description:
139 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
140 type: str
141 ipv4_address:
142 description:
143 - IPv4 address.
144 type: str
145 ipv6_address:
146 description:
147 - IPv6 address.
148 type: str
149 network_mask:
150 description:
151 - IPv4 or IPv6 network mask. If both masks are required use ipv4-network-mask and ipv6-network-mask fields explicitly. Instead of
152 providing mask itself it is possible to specify IPv4 or IPv6 mask length in mask-length field. If both masks length are required use
153 ipv4-mask-length and ipv6-mask-length fields explicitly.
154 type: str
155 ipv4_network_mask:
156 description:
157 - IPv4 network address.
158 type: str
159 ipv6_network_mask:
160 description:
161 - IPv6 network address.
162 type: str
163 mask_length:
164 description:
165 - IPv4 or IPv6 network mask length.
166 type: str
167 ipv4_mask_length:
168 description:
169 - IPv4 network mask length.
170 type: str
171 ipv6_mask_length:
172 description:
173 - IPv6 network mask length.
174 type: str
175 security_zone:
176 description:
177 - N/A
178 type: bool
179 security_zone_settings:
180 description:
181 - N/A
182 type: dict
183 suboptions:
184 auto_calculated:
185 description:
186 - Security Zone is calculated according to where the interface leads to.
187 type: bool
188 specific_zone:
189 description:
190 - Security Zone specified manually.
191 type: str
192 tags:
193 description:
194 - Collection of tag identifiers.
195 type: list
196 elements: str
197 topology:
198 description:
199 - N/A
200 type: str
201 choices: ['automatic', 'external', 'internal']
202 topology_settings:
203 description:
204 - N/A
205 type: dict
206 suboptions:
207 interface_leads_to_dmz:
208 description:
209 - Whether this interface leads to demilitarized zone (perimeter network).
210 type: bool
211 ip_address_behind_this_interface:
212 description:
213 - N/A
214 type: str
215 choices: ['not defined', 'network defined by the interface ip and net mask', 'network defined by routing', 'specific']
216 specific_network:
217 description:
218 - Network behind this interface.
219 type: str
220 color:
221 description:
222 - Color of the object. Should be one of existing colors.
223 type: str
224 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange',
225 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray',
226 'light green', 'lemon chiffon', 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive',
227 'orange', 'red', 'sienna', 'yellow']
228 comments:
229 description:
230 - Comments string.
231 type: str
232 details_level:
233 description:
234 - 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
235 representation of the object.
236 type: str
237 choices: ['uid', 'standard', 'full']
238 ignore_warnings:
239 description:
240 - Apply changes ignoring warnings.
241 type: bool
242 ignore_errors:
243 description:
244 - 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.
245 type: bool
246 ips:
247 description:
248 - Intrusion Prevention System blade enabled.
249 type: bool
250 ips_settings:
251 description:
252 - Gateway IPS settings.
253 - Available from R82 JHF management version.
254 type: dict
255 version_added: "6.5.0"
256 suboptions:
257 bypass_all_under_load:
258 description:
259 - Disable/enable all IPS protections until CPU and memory levels are back to normal.
260 type: bool
261 bypass_track_method:
262 description:
263 - Track options when all IPS protections are disabled until CPU/memory levels are back to normal.
264 type: str
265 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
266 'user defined alert no.3']
267 activation_mode:
268 description:
269 - Defines whether the IPS blade operates in Detect Only mode or enforces the configured IPS Policy.
270 type: str
271 choices: ['according-to-policy', 'detect-only']
272 cpu_usage_low_threshold:
273 description:
274 - CPU usage low threshold percentage (1-99).
275 type: int
276 cpu_usage_high_threshold:
277 description:
278 - CPU usage high threshold percentage (1-99).
279 type: int
280 memory_usage_low_threshold:
281 description:
282 - Memory usage low threshold percentage (1-99).
283 type: int
284 memory_usage_high_threshold:
285 description:
286 - Memory usage high threshold percentage (1-99).
287 type: int
288 send_threat_cloud_info:
289 description:
290 - Help improve Check Point Threat Prevention product by sending anonymous information.
291 type: bool
292 logs_settings:
293 description:
294 - N/A
295 type: dict
296 suboptions:
297 alert_when_free_disk_space_below:
298 description:
299 - N/A
300 type: bool
301 alert_when_free_disk_space_below_threshold:
302 description:
303 - N/A
304 type: int
305 alert_when_free_disk_space_below_type:
306 description:
307 - N/A
308 type: str
309 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
310 'user defined alert no.3']
311 before_delete_keep_logs_from_the_last_days:
312 description:
313 - N/A
314 type: bool
315 before_delete_keep_logs_from_the_last_days_threshold:
316 description:
317 - N/A
318 type: int
319 before_delete_run_script:
320 description:
321 - N/A
322 type: bool
323 before_delete_run_script_command:
324 description:
325 - N/A
326 type: str
327 delete_index_files_older_than_days:
328 description:
329 - N/A
330 type: bool
331 delete_index_files_older_than_days_threshold:
332 description:
333 - N/A
334 type: int
335 delete_index_files_when_index_size_above:
336 description:
337 - N/A
338 type: bool
339 delete_index_files_when_index_size_above_threshold:
340 description:
341 - N/A
342 type: int
343 delete_when_free_disk_space_below:
344 description:
345 - N/A
346 type: bool
347 delete_when_free_disk_space_below_threshold:
348 description:
349 - N/A
350 type: int
351 detect_new_citrix_ica_application_names:
352 description:
353 - N/A
354 type: bool
355 forward_logs_to_log_server:
356 description:
357 - N/A
358 type: bool
359 forward_logs_to_log_server_name:
360 description:
361 - N/A
362 type: str
363 forward_logs_to_log_server_schedule_name:
364 description:
365 - N/A
366 type: str
367 free_disk_space_metrics:
368 description:
369 - N/A
370 type: str
371 choices: ['mbytes', 'percent']
372 perform_log_rotate_before_log_forwarding:
373 description:
374 - N/A
375 type: bool
376 reject_connections_when_free_disk_space_below_threshold:
377 description:
378 - N/A
379 type: bool
380 reserve_for_packet_capture_metrics:
381 description:
382 - N/A
383 type: str
384 choices: ['percent', 'mbytes']
385 reserve_for_packet_capture_threshold:
386 description:
387 - N/A
388 type: int
389 rotate_log_by_file_size:
390 description:
391 - N/A
392 type: bool
393 rotate_log_file_size_threshold:
394 description:
395 - N/A
396 type: int
397 rotate_log_on_schedule:
398 description:
399 - N/A
400 type: bool
401 rotate_log_schedule_name:
402 description:
403 - N/A
404 type: str
405 stop_logging_when_free_disk_space_below:
406 description:
407 - N/A
408 type: bool
409 stop_logging_when_free_disk_space_below_threshold:
410 description:
411 - N/A
412 type: int
413 turn_on_qos_logging:
414 description:
415 - N/A
416 type: bool
417 update_account_log_every:
418 description:
419 - N/A
420 type: int
421 one_time_password:
422 description:
423 - N/A
424 type: str
425 os_name:
426 description:
427 - Gateway platform operating system.
428 type: str
429 save_logs_locally:
430 description:
431 - Save logs locally on the gateway.
432 type: bool
433 send_alerts_to_server:
434 description:
435 - Server(s) to send alerts to.
436 type: list
437 elements: str
438 send_logs_to_backup_server:
439 description:
440 - Backup server(s) to send logs to.
441 type: list
442 elements: str
443 send_logs_to_server:
444 description:
445 - Server(s) to send logs to.
446 type: list
447 elements: str
448 tags:
449 description:
450 - Collection of tag identifiers.
451 type: list
452 elements: str
453 threat_emulation:
454 description:
455 - Threat Emulation blade enabled.
456 type: bool
457 threat_extraction:
458 description:
459 - Threat Extraction blade enabled.
460 - Available from R80.20.M2 management version.
461 type: bool
462 url_filtering:
463 description:
464 - URL Filtering blade enabled.
465 type: bool
466 gateway_version:
467 description:
468 - Gateway platform version.
469 type: str
470 vpn:
471 description:
472 - VPN blade enabled.
473 type: bool
474 vpn_settings:
475 description:
476 - Gateway VPN settings.
477 type: dict
478 suboptions:
479 maximum_concurrent_ike_negotiations:
480 description:
481 - N/A
482 type: int
483 maximum_concurrent_tunnels:
484 description:
485 - N/A
486 type: int
487 color:
488 description:
489 - Color of the object. Should be one of existing colors.
490 type: str
491 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
492 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
493 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
494 comments:
495 description:
496 - Comments string.
497 type: str
498 details_level:
499 description:
500 - 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
501 representation of the object.
502 type: str
503 choices: ['uid', 'standard', 'full']
504 groups:
505 description:
506 - Collection of group identifiers.
507 type: list
508 elements: str
509 ignore_warnings:
510 description:
511 - Apply changes ignoring warnings.
512 type: bool
513 ignore_errors:
514 description:
515 - 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.
516 type: bool
517 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
518 """
519
520 EXAMPLES = """
521 - name: add-simple-gateway
522 cp_mgmt_simple_gateway:
523 ip_address: 192.0.2.1
524 name: gw1
525 state: present
526
527 - name: set-simple-gateway
528 cp_mgmt_simple_gateway:
529 anti_bot: true
530 anti_virus: true
531 application_control: true
532 ips: true
533 name: test_gateway
534 state: present
535 threat_emulation: true
536 url_filtering: true
537
538 - name: delete-simple-gateway
539 cp_mgmt_simple_gateway:
540 name: gw1
541 state: absent
542 """
543
544 RETURN = """
545 cp_mgmt_simple_gateway:
546 description: The checkpoint object created or updated.
547 returned: always, except when deleting the object.
548 type: dict
549 """
550
551 from ansible.module_utils.basic import AnsibleModule
552 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
553 checkpoint_argument_spec_for_objects,
554 api_call,
555 )
556
557
558 def main():
559 argument_spec = dict(
560 name=dict(type="str", required=True),
561 ip_address=dict(type="str"),
562 ipv4_address=dict(type="str"),
563 ipv6_address=dict(type="str"),
564 anti_bot=dict(type="bool"),
565 anti_virus=dict(type="bool"),
566 application_control=dict(type="bool"),
567 content_awareness=dict(type="bool"),
568 enable_https_inspection=dict(type="bool"),
569 firewall=dict(type="bool"),
570 firewall_settings=dict(
571 type="dict",
572 options=dict(
573 auto_calculate_connections_hash_table_size_and_memory_pool=dict(
574 type="bool"
575 ),
576 auto_maximum_limit_for_concurrent_connections=dict(
577 type="bool"
578 ),
579 connections_hash_size=dict(type="int"),
580 maximum_limit_for_concurrent_connections=dict(type="int"),
581 maximum_memory_pool_size=dict(type="int"),
582 memory_pool_size=dict(type="int"),
583 ),
584 ),
585 interfaces=dict(
586 type="list",
587 elements="dict",
588 options=dict(
589 name=dict(type="str"),
590 anti_spoofing=dict(type="bool"),
591 anti_spoofing_settings=dict(
592 type="dict",
593 options=dict(
594 action=dict(type="str", choices=["prevent", "detect"])
595 ),
596 ),
597 ip_address=dict(type="str"),
598 ipv4_address=dict(type="str"),
599 ipv6_address=dict(type="str"),
600 network_mask=dict(type="str"),
601 ipv4_network_mask=dict(type="str"),
602 ipv6_network_mask=dict(type="str"),
603 mask_length=dict(type="str"),
604 ipv4_mask_length=dict(type="str"),
605 ipv6_mask_length=dict(type="str"),
606 security_zone=dict(type="bool"),
607 security_zone_settings=dict(
608 type="dict",
609 options=dict(
610 auto_calculated=dict(type="bool"),
611 specific_zone=dict(type="str"),
612 ),
613 ),
614 tags=dict(type="list", elements="str"),
615 topology=dict(
616 type="str", choices=["automatic", "external", "internal"]
617 ),
618 topology_settings=dict(
619 type="dict",
620 options=dict(
621 interface_leads_to_dmz=dict(type="bool"),
622 ip_address_behind_this_interface=dict(
623 type="str",
624 choices=[
625 "not defined",
626 "network defined by the interface ip and net mask",
627 "network defined by routing",
628 "specific",
629 ],
630 ),
631 specific_network=dict(type="str"),
632 ),
633 ),
634 color=dict(
635 type="str",
636 choices=[
637 "aquamarine",
638 "black",
639 "blue",
640 "crete blue",
641 "burlywood",
642 "cyan",
643 "dark green",
644 "khaki",
645 "orchid",
646 "dark orange",
647 "dark sea green",
648 "pink",
649 "turquoise",
650 "dark blue",
651 "firebrick",
652 "brown",
653 "forest green",
654 "gold",
655 "dark gold",
656 "gray",
657 "dark gray",
658 "light green",
659 "lemon chiffon",
660 "coral",
661 "sea green",
662 "sky blue",
663 "magenta",
664 "purple",
665 "slate blue",
666 "violet red",
667 "navy blue",
668 "olive",
669 "orange",
670 "red",
671 "sienna",
672 "yellow",
673 ],
674 ),
675 comments=dict(type="str"),
676 details_level=dict(
677 type="str", choices=["uid", "standard", "full"]
678 ),
679 ignore_warnings=dict(type="bool"),
680 ignore_errors=dict(type="bool"),
681 ),
682 ),
683 ips=dict(type="bool"),
684 ips_settings=dict(
685 type="dict",
686 options=dict(
687 bypass_all_under_load=dict(type="bool"),
688 bypass_track_method=dict(type="str",
689 choices=[
690 "none",
691 "log",
692 "popup alert",
693 "mail alert",
694 "snmp trap alert",
695 "user defined alert no.1",
696 "user defined alert no.2",
697 "user defined alert no.3",
698 ],
699 ),
700 activation_mode=dict(
701 type="str",
702 choices=["according-to-policy", "detect-only"],
703 ),
704 cpu_usage_low_threshold=dict(type="int"),
705 cpu_usage_high_threshold=dict(type="int"),
706 memory_usage_low_threshold=dict(type="int"),
707 memory_usage_high_threshold=dict(type="int"),
708 send_threat_cloud_info=dict(type="bool"),
709 ),
710 ),
711 logs_settings=dict(
712 type="dict",
713 options=dict(
714 alert_when_free_disk_space_below=dict(type="bool"),
715 alert_when_free_disk_space_below_threshold=dict(type="int"),
716 alert_when_free_disk_space_below_type=dict(
717 type="str",
718 choices=[
719 "none",
720 "log",
721 "popup alert",
722 "mail alert",
723 "snmp trap alert",
724 "user defined alert no.1",
725 "user defined alert no.2",
726 "user defined alert no.3",
727 ],
728 ),
729 before_delete_keep_logs_from_the_last_days=dict(type="bool"),
730 before_delete_keep_logs_from_the_last_days_threshold=dict(
731 type="int"
732 ),
733 before_delete_run_script=dict(type="bool"),
734 before_delete_run_script_command=dict(type="str"),
735 delete_index_files_older_than_days=dict(type="bool"),
736 delete_index_files_older_than_days_threshold=dict(type="int"),
737 delete_index_files_when_index_size_above=dict(type="bool"),
738 delete_index_files_when_index_size_above_threshold=dict(
739 type="int"
740 ),
741 delete_when_free_disk_space_below=dict(type="bool"),
742 delete_when_free_disk_space_below_threshold=dict(type="int"),
743 detect_new_citrix_ica_application_names=dict(type="bool"),
744 forward_logs_to_log_server=dict(type="bool"),
745 forward_logs_to_log_server_name=dict(type="str"),
746 forward_logs_to_log_server_schedule_name=dict(type="str"),
747 free_disk_space_metrics=dict(
748 type="str", choices=["mbytes", "percent"]
749 ),
750 perform_log_rotate_before_log_forwarding=dict(type="bool"),
751 reject_connections_when_free_disk_space_below_threshold=dict(
752 type="bool"
753 ),
754 reserve_for_packet_capture_metrics=dict(
755 type="str", choices=["percent", "mbytes"]
756 ),
757 reserve_for_packet_capture_threshold=dict(type="int"),
758 rotate_log_by_file_size=dict(type="bool"),
759 rotate_log_file_size_threshold=dict(type="int"),
760 rotate_log_on_schedule=dict(type="bool"),
761 rotate_log_schedule_name=dict(type="str"),
762 stop_logging_when_free_disk_space_below=dict(type="bool"),
763 stop_logging_when_free_disk_space_below_threshold=dict(
764 type="int"
765 ),
766 turn_on_qos_logging=dict(type="bool"),
767 update_account_log_every=dict(type="int"),
768 ),
769 ),
770 one_time_password=dict(type="str", no_log=True),
771 os_name=dict(type="str"),
772 save_logs_locally=dict(type="bool"),
773 send_alerts_to_server=dict(type="list", elements="str"),
774 send_logs_to_backup_server=dict(type="list", elements="str"),
775 send_logs_to_server=dict(type="list", elements="str"),
776 tags=dict(type="list", elements="str"),
777 threat_emulation=dict(type="bool"),
778 threat_extraction=dict(type="bool"),
779 url_filtering=dict(type="bool"),
780 gateway_version=dict(type="str"),
781 vpn=dict(type="bool"),
782 vpn_settings=dict(
783 type="dict",
784 options=dict(
785 maximum_concurrent_ike_negotiations=dict(type="int"),
786 maximum_concurrent_tunnels=dict(type="int"),
787 ),
788 ),
789 color=dict(
790 type="str",
791 choices=[
792 "aquamarine",
793 "black",
794 "blue",
795 "crete blue",
796 "burlywood",
797 "cyan",
798 "dark green",
799 "khaki",
800 "orchid",
801 "dark orange",
802 "dark sea green",
803 "pink",
804 "turquoise",
805 "dark blue",
806 "firebrick",
807 "brown",
808 "forest green",
809 "gold",
810 "dark gold",
811 "gray",
812 "dark gray",
813 "light green",
814 "lemon chiffon",
815 "coral",
816 "sea green",
817 "sky blue",
818 "magenta",
819 "purple",
820 "slate blue",
821 "violet red",
822 "navy blue",
823 "olive",
824 "orange",
825 "red",
826 "sienna",
827 "yellow",
828 ],
829 ),
830 comments=dict(type="str"),
831 details_level=dict(type="str", choices=["uid", "standard", "full"]),
832 groups=dict(type="list", elements="str"),
833 ignore_warnings=dict(type="bool"),
834 ignore_errors=dict(type="bool"),
835 )
836 argument_spec.update(checkpoint_argument_spec_for_objects)
837
838 module = AnsibleModule(
839 argument_spec=argument_spec, supports_check_mode=True
840 )
841 api_call_object = "simple-gateway"
842
843 result = api_call(module, api_call_object)
844 module.exit_json(**result)
845
846
847 if __name__ == "__main__":
848 main()