Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_vpn_community_meshed.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_vpn_community_meshed
33 short_description: Manages vpn-community-meshed objects on Check Point over Web Services API
34 description:
35 - Manages vpn-community-meshed 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 disable_nat:
47 description:
48 - Indicates whether to disable NAT inside the VPN Community.
49 - Available from R82 JHF management version.
50 type: bool
51 version_added: "6.5.0"
52 encrypted_traffic:
53 description:
54 - Encrypted traffic settings.
55 - Available from R82 JHF management version.
56 type: dict
57 version_added: "6.5.0"
58 suboptions:
59 enabled:
60 description:
61 - Indicates whether to accept all encrypted traffic.
62 type: bool
63 encryption_method:
64 description:
65 - The encryption method to be used.
66 - Available from R80.10 management version.
67 type: str
68 choices: ['prefer ikev2 but support ikev1', 'ikev2 only', 'ikev1 for ipv4 and ikev2 for ipv6 only']
69 encryption_suite:
70 description:
71 - The encryption suite to be used.
72 - Available from R80.10 management version.
73 type: str
74 choices: ['suite-b-gcm-256', 'custom', 'vpn b', 'vpn a', 'suite-b-gcm-128']
75 excluded_services:
76 description:
77 - Collection of services that are excluded from the community identified by the name or UID.<br> Connections with these services will not be
78 encrypted and will not match rules specifying the community in the VPN community.
79 - Available from R82 JHF management version.
80 type: list
81 elements: str
82 version_added: "6.5.0"
83 gateways:
84 description:
85 - Collection of Gateway objects identified by the name or UID.
86 type: list
87 elements: str
88 ike_phase_1:
89 description:
90 - Ike Phase 1 settings. Only applicable when the encryption-suite is set to [custom].
91 - Available from R80.10 management version.
92 type: dict
93 suboptions:
94 data_integrity:
95 description:
96 - The hash algorithm to be used.
97 type: str
98 choices: ['aes-xcbc', 'sha1', 'sha256', 'sha384', 'sha512', 'md5']
99 diffie_hellman_group:
100 description:
101 - The Diffie-Hellman group to be used.
102 type: str
103 choices: ['group-1', 'group-2', 'group-5', 'group-14', 'group-19', 'group-20']
104 encryption_algorithm:
105 description:
106 - The encryption algorithm to be used.
107 type: str
108 choices: ['cast', 'aes-256', 'des', 'aes-128', '3des']
109 ike_phase_2:
110 description:
111 - Ike Phase 2 settings. Only applicable when the encryption-suite is set to [custom].
112 - Available from R80.10 management version.
113 type: dict
114 suboptions:
115 data_integrity:
116 description:
117 - The hash algorithm to be used.
118 type: str
119 choices: ['aes-xcbc', 'sha1', 'sha256', 'sha384', 'sha512', 'md5']
120 encryption_algorithm:
121 description:
122 - The encryption algorithm to be used.
123 type: str
124 choices: ['cast', 'aes-gcm-256', 'cast-40', 'aes-256', 'des', 'aes-128', '3des', 'des-40cp', 'aes-gcm-128', 'none']
125 permanent_tunnels:
126 description:
127 - Permanent tunnels properties.
128 - Available from R82 JHF management version.
129 type: dict
130 version_added: "6.5.0"
131 suboptions:
132 set_permanent_tunnels:
133 description:
134 - Indicates which tunnels to set as permanent.
135 type: str
136 choices: ['on all tunnels in the community', 'on all tunnels of specific gateways', 'on specific tunnels in the community', 'off']
137 gateways:
138 description:
139 - List of gateways to set all their tunnels to permanent with specified track options. Will take effect only if set-permanent-tunnels-on
140 is set to all-tunnels-of-specific-gateways.
141 type: list
142 elements: dict
143 suboptions:
144 gateway:
145 description:
146 - Gateway to set all is tunnels to permanent with specified track options.<br> Identified by name or UID.
147 type: str
148 track_options:
149 description:
150 - Indicates whether to use the community track options or to override track options for the permanent tunnels.
151 type: str
152 choices: ['according to community track options', 'override track options']
153 override_tunnel_down_track:
154 description:
155 - Gateway tunnel down track option. Relevant only if the track-options is set to 'override track options'.
156 type: str
157 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
158 'user defined alert no.3']
159 override_tunnel_up_track:
160 description:
161 - Gateway tunnel up track option. Relevant only if the track-options is set to 'override track options'.
162 type: str
163 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
164 'user defined alert no.3']
165 tunnels:
166 description:
167 - List of tunnels to set as permanent with specified track options. Will take effect only if set-permanent-tunnels-on is set to
168 specific-tunnels-in-the-community.
169 type: list
170 elements: dict
171 suboptions:
172 first_tunnel_endpoint:
173 description:
174 - First tunnel endpoint (center gateway). Identified by name or UID.
175 type: str
176 second_tunnel_endpoint:
177 description:
178 - Second tunnel endpoint (center gateway for meshed VPN community and satellite gateway for star VPN community). Identified by name or UID.
179 type: str
180 track_options:
181 description:
182 - Indicates whether to use the community track options or to override track options for the permanent tunnels.
183 type: str
184 choices: ['according to community track options', 'override track options']
185 override_tunnel_down_track:
186 description:
187 - Gateway tunnel down track option. Relevant only if the track-options is set to 'override track options'.
188 type: str
189 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
190 'user defined alert no.3']
191 override_tunnel_up_track:
192 description:
193 - Gateway tunnel up track option. Relevant only if the track-options is set to 'override track options'.
194 type: str
195 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
196 'user defined alert no.3']
197 rim:
198 description:
199 - Route Injection Mechanism settings.
200 type: dict
201 suboptions:
202 enabled:
203 description:
204 - Indicates whether Route Injection Mechanism is enabled.
205 type: bool
206 enable_on_gateways:
207 description:
208 - Indicates whether to enable automatic Route Injection Mechanism for gateways.
209 type: bool
210 route_injection_track:
211 description:
212 - Route injection track method.
213 type: str
214 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
215 'user defined alert no.3']
216 tunnel_down_track:
217 description:
218 - VPN community permanent tunnels down track option.
219 type: str
220 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
221 'user defined alert no.3']
222 tunnel_up_track:
223 description:
224 - Permanent tunnels up track option.
225 type: str
226 choices: ['none', 'log', 'popup alert', 'mail alert', 'snmp trap alert', 'user defined alert no.1', 'user defined alert no.2',
227 'user defined alert no.3']
228 shared_secrets:
229 description:
230 - Shared secrets for external gateways.
231 - Available from R80.10 management version.
232 type: list
233 elements: dict
234 suboptions:
235 external_gateway:
236 description:
237 - External gateway identified by the name or UID.
238 type: str
239 shared_secret:
240 description:
241 - Shared secret.
242 type: str
243 tags:
244 description:
245 - Collection of tag identifiers.
246 type: list
247 elements: str
248 use_shared_secret:
249 description:
250 - Indicates whether the shared secret should be used for all external gateways.
251 - Available from R80.10 management version.
252 type: bool
253 wire_mode:
254 description:
255 - VPN Community Wire mode properties.
256 - Available from R82 JHF management version.
257 type: dict
258 version_added: "6.5.0"
259 suboptions:
260 allow_uninspected_encrypted_traffic:
261 description:
262 - Allow uninspected encrypted traffic between Wire mode interfaces of this Community members.
263 type: bool
264 allow_uninspected_encrypted_routing:
265 description:
266 - Allow members to route uninspected encrypted traffic in VPN routing configurations.
267 type: bool
268 routing_mode:
269 description:
270 - VPN Community Routing Mode.
271 - Available from R82 JHF management version.
272 type: str
273 choices: ['domain_based', 'route_based']
274 version_added: "6.5.0"
275 advanced_properties:
276 description:
277 - Advanced properties.
278 - Available from R82 JHF management version.
279 type: dict
280 version_added: "6.5.0"
281 suboptions:
282 support_ip_compression:
283 description:
284 - Indicates whether to support IP compression.
285 type: bool
286 use_aggressive_mode:
287 description:
288 - Indicates whether to use aggressive mode.
289 type: bool
290 color:
291 description:
292 - Color of the object. Should be one of existing colors.
293 type: str
294 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
295 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
296 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
297 comments:
298 description:
299 - Comments string.
300 type: str
301 details_level:
302 description:
303 - 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
304 representation of the object.
305 type: str
306 choices: ['uid', 'standard', 'full']
307 ignore_warnings:
308 description:
309 - Apply changes ignoring warnings.
310 type: bool
311 ignore_errors:
312 description:
313 - 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.
314 type: bool
315 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
316 """
317
318 EXAMPLES = """
319 - name: add-vpn-community-meshed
320 cp_mgmt_vpn_community_meshed:
321 encryption_method: prefer ikev2 but support ikev1
322 encryption_suite: custom
323 ike_phase_1:
324 data_integrity: sha1
325 diffie_hellman_group: group 19
326 encryption_algorithm: aes-128
327 ike_phase_2:
328 data_integrity: aes-xcbc
329 encryption_algorithm: aes-gcm-128
330 name: New_VPN_Community_Meshed_1
331 state: present
332
333 - name: set-vpn-community-meshed
334 cp_mgmt_vpn_community_meshed:
335 encryption_method: ikev2 only
336 encryption_suite: custom
337 ike_phase_1:
338 data_integrity: sha1
339 diffie_hellman_group: group 19
340 encryption_algorithm: aes-128
341 ike_phase_2:
342 data_integrity: aes-xcbc
343 encryption_algorithm: aes-gcm-128
344 name: New_VPN_Community_Meshed_1
345 state: present
346
347 - name: delete-vpn-community-meshed
348 cp_mgmt_vpn_community_meshed:
349 name: New_VPN_Community_Meshed_1
350 state: absent
351 """
352
353 RETURN = """
354 cp_mgmt_vpn_community_meshed:
355 description: The checkpoint object created or updated.
356 returned: always, except when deleting the object.
357 type: dict
358 """
359
360 from ansible.module_utils.basic import AnsibleModule
361 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
362 checkpoint_argument_spec_for_objects,
363 api_call,
364 )
365
366
367 def main():
368 argument_spec = dict(
369 name=dict(type="str", required=True),
370 disable_nat=dict(type="bool"),
371 encrypted_traffic=dict(
372 type="dict", options=dict(
373 enabled=dict(type="bool")
374 ),
375 ),
376
377 encryption_method=dict(
378 type="str",
379 choices=[
380 "prefer ikev2 but support ikev1",
381 "ikev2 only",
382 "ikev1 for ipv4 and ikev2 for ipv6 only",
383 ],
384 ),
385 encryption_suite=dict(
386 type="str",
387 choices=[
388 "suite-b-gcm-256",
389 "custom",
390 "vpn b",
391 "vpn a",
392 "suite-b-gcm-128",
393 ],
394 ),
395 excluded_services=dict(type="list", elements="str"),
396 gateways=dict(type="list", elements="str"),
397 ike_phase_1=dict(
398 type="dict",
399 options=dict(
400 data_integrity=dict(
401 type="str",
402 choices=["aes-xcbc", "sha1", "sha256", "sha384", "sha512", "md5"],
403 ),
404 diffie_hellman_group=dict(
405 type="str",
406 choices=[
407 "group-1",
408 "group-2",
409 "group-5",
410 "group-14",
411 "group-19",
412 "group-20",
413 ],
414 ),
415 encryption_algorithm=dict(
416 type="str",
417 choices=["cast", "aes-256", "des", "aes-128", "3des"],
418 ),
419 ),
420 ),
421 ike_phase_2=dict(
422 type="dict",
423 options=dict(
424 data_integrity=dict(
425 type="str",
426 choices=["aes-xcbc", "sha1", "sha256", "sha384", "sha512", "md5"],
427 ),
428 encryption_algorithm=dict(
429 type="str",
430 choices=[
431 "cast",
432 "aes-gcm-256",
433 "cast-40",
434 "aes-256",
435 "des",
436 "aes-128",
437 "3des",
438 "des-40cp",
439 "aes-gcm-128",
440 "none",
441 ],
442 ),
443 ),
444 ),
445 permanent_tunnels=dict(
446 type="dict",
447 options=dict(
448 set_permanent_tunnels=dict(
449 type="str",
450 choices=[
451 "on all tunnels in the community",
452 "on all tunnels of specific gateways",
453 "on specific tunnels in the community",
454 "off",
455 ],
456 ),
457 gateways=dict(
458 type="list",
459 elements="dict",
460 options=dict(
461 gateway=dict(type="str"),
462 track_options=dict(
463 type="str",
464 choices=[
465 "according to community track options",
466 "override track options",
467 ],
468 ),
469 override_tunnel_down_track=dict(
470 type="str",
471 choices=[
472 "none",
473 "log",
474 "popup alert",
475 "mail alert",
476 "snmp trap alert",
477 "user defined alert no.1",
478 "user defined alert no.2",
479 "user defined alert no.3",
480 ],
481 ),
482 override_tunnel_up_track=dict(
483 type="str",
484 choices=[
485 "none",
486 "log",
487 "popup alert",
488 "mail alert",
489 "snmp trap alert",
490 "user defined alert no.1",
491 "user defined alert no.2",
492 "user defined alert no.3",
493 ],
494 ),
495 ),
496 ),
497 tunnels=dict(
498 type="list",
499 elements="dict",
500 options=dict(
501 first_tunnel_endpoint=dict(type="str"),
502 second_tunnel_endpoint=dict(type="str"),
503 track_options=dict(
504 type="str",
505 choices=[
506 "according to community track options",
507 "override track options",
508 ],
509 ),
510 override_tunnel_down_track=dict(
511 type="str",
512 choices=[
513 "none",
514 "log",
515 "popup alert",
516 "mail alert",
517 "snmp trap alert",
518 "user defined alert no.1",
519 "user defined alert no.2",
520 "user defined alert no.3",
521 ],
522 ),
523 override_tunnel_up_track=dict(
524 type="str",
525 choices=[
526 "none",
527 "log",
528 "popup alert",
529 "mail alert",
530 "snmp trap alert",
531 "user defined alert no.1",
532 "user defined alert no.2",
533 "user defined alert no.3",
534 ],
535 ),
536 ),
537 ),
538 rim=dict(
539 type="dict",
540 options=dict(
541 enabled=dict(type="bool"),
542 enable_on_gateways=dict(type="bool"),
543 route_injection_track=dict(
544 type="str",
545 choices=[
546 "none",
547 "log",
548 "popup alert",
549 "mail alert",
550 "snmp trap alert",
551 "user defined alert no.1",
552 "user defined alert no.2",
553 "user defined alert no.3",
554 ],
555 ),
556 ),
557 ),
558 tunnel_down_track=dict(
559 type="str",
560 choices=[
561 "none",
562 "log",
563 "popup alert",
564 "mail alert",
565 "snmp trap alert",
566 "user defined alert no.1",
567 "user defined alert no.2",
568 "user defined alert no.3",
569 ],
570 ),
571 tunnel_up_track=dict(
572 type="str",
573 choices=[
574 "none",
575 "log",
576 "popup alert",
577 "mail alert",
578 "snmp trap alert",
579 "user defined alert no.1",
580 "user defined alert no.2",
581 "user defined alert no.3",
582 ],
583 ),
584 ),
585 ),
586 shared_secrets=dict(
587 type="list",
588 elements="dict",
589 no_log=True,
590 options=dict(
591 external_gateway=dict(type="str"),
592 shared_secret=dict(type="str", no_log=True),
593 ),
594 ),
595 tags=dict(type="list", elements="str"),
596 use_shared_secret=dict(type="bool"),
597 wire_mode=dict(
598 type="dict",
599 options=dict(
600 allow_uninspected_encrypted_traffic=dict(type="bool"),
601 allow_uninspected_encrypted_routing=dict(type="bool"),
602 ),
603 ),
604 routing_mode=dict(
605 type="str",
606 choices=["domain_based", "route_based"],
607 ),
608 advanced_properties=dict(
609 type="dict",
610 options=dict(
611 support_ip_compression=dict(type="bool"),
612 use_aggressive_mode=dict(type="bool"),
613 ),
614 ),
615 color=dict(
616 type="str",
617 choices=[
618 "aquamarine",
619 "black",
620 "blue",
621 "crete blue",
622 "burlywood",
623 "cyan",
624 "dark green",
625 "khaki",
626 "orchid",
627 "dark orange",
628 "dark sea green",
629 "pink",
630 "turquoise",
631 "dark blue",
632 "firebrick",
633 "brown",
634 "forest green",
635 "gold",
636 "dark gold",
637 "gray",
638 "dark gray",
639 "light green",
640 "lemon chiffon",
641 "coral",
642 "sea green",
643 "sky blue",
644 "magenta",
645 "purple",
646 "slate blue",
647 "violet red",
648 "navy blue",
649 "olive",
650 "orange",
651 "red",
652 "sienna",
653 "yellow",
654 ],
655 ),
656 comments=dict(type="str"),
657 details_level=dict(type="str", choices=["uid", "standard", "full"]),
658 ignore_warnings=dict(type="bool"),
659 ignore_errors=dict(type="bool"),
660 )
661 argument_spec.update(checkpoint_argument_spec_for_objects)
662
663 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
664
665 api_call_object = "vpn-community-meshed"
666
667 result = api_call(module, api_call_object)
668 module.exit_json(**result)
669
670
671 if __name__ == "__main__":
672 main()