Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_interface.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_interface
31 short_description: Manages interface objects on Checkpoint over Web Services API
32 description:
33 - Manages interface 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.2.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 name:
40 description:
41 - Network interface name.
42 type: str
43 required: True
44 gateway_uid:
45 description:
46 - Gateway or cluster object uid that the interface belongs to.
47 type: str
48 required: True
49 anti_spoofing:
50 description:
51 - Enable anti-spoofing.
52 type: bool
53 anti_spoofing_settings:
54 description:
55 - Anti Spoofing Settings.
56 type: dict
57 suboptions:
58 action:
59 description:
60 - If packets will be rejected (the Prevent option) or whether the packets will be monitored (the Detect option).
61 type: str
62 choices: ['prevent', 'detect']
63 exclude_packets:
64 description:
65 - Don't check packets from excluded network.
66 type: bool
67 excluded_network_name:
68 description:
69 - Excluded network name.
70 type: str
71 excluded_network_uid:
72 description:
73 - Excluded network UID.
74 type: str
75 spoof_tracking:
76 description:
77 - Spoof tracking.
78 type: str
79 choices: ['none', 'log', 'alert']
80 cluster_members:
81 description:
82 - Network interface settings for cluster members.
83 type: list
84 elements: dict
85 suboptions:
86 name:
87 description:
88 - Cluster member network interface name.
89 type: str
90 member_name:
91 description:
92 - Cluster member object name.
93 type: str
94 ip_address:
95 description:
96 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
97 type: str
98 ipv4_address:
99 description:
100 - IPv4 address.
101 type: str
102 ipv6_address:
103 description:
104 - IPv6 address.
105 type: str
106 network_mask:
107 description:
108 - IPv4 or IPv6 network mask. If both masks are required use ipv4-network-mask and ipv6-network-mask fields explicitly. Instead of
109 providing mask itself it is possible to specify IPv4 or IPv6 mask length in mask-length field. If both masks length are required use
110 ipv4-mask-length and ipv6-mask-length fields explicitly.
111 type: str
112 ipv4_network_mask:
113 description:
114 - IPv4 network address.
115 type: str
116 ipv6_network_mask:
117 description:
118 - IPv6 network address.
119 type: str
120 mask_length:
121 description:
122 - IPv4 or IPv6 network mask length.
123 type: str
124 ipv4_mask_length:
125 description:
126 - IPv4 network mask length.
127 type: str
128 ipv6_mask_length:
129 description:
130 - IPv6 network mask length.
131 type: str
132 tags:
133 description:
134 - Collection of tag identifiers.
135 type: list
136 elements: str
137 color:
138 description:
139 - Color of the object. Should be one of existing colors.
140 type: str
141 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange',
142 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray',
143 'light green', 'lemon chiffon', 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive',
144 'orange', 'red', 'sienna', 'yellow']
145 comments:
146 description:
147 - Comments string.
148 type: str
149 details_level:
150 description:
151 - 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
152 representation of the object.
153 type: str
154 choices: ['uid', 'standard', 'full']
155 ignore_warnings:
156 description:
157 - Apply changes ignoring warnings.
158 type: bool
159 ignore_errors:
160 description:
161 - 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.
162 type: bool
163 cluster_network_type:
164 description:
165 - Cluster interface type.
166 type: str
167 choices: ['cluster', 'sync', 'cluster + sync', 'private']
168 dynamic_ip:
169 description:
170 - Enable dynamic interface.
171 type: bool
172 ipv4_address:
173 description:
174 - IPv4 network address.
175 type: str
176 ipv4_mask_length:
177 description:
178 - IPv4 mask length.
179 type: int
180 ipv4_network_mask:
181 description:
182 - IPv4 network mask.
183 type: str
184 ipv6_address:
185 description:
186 - IPv6 address.
187 type: str
188 ipv6_mask_length:
189 description:
190 - IPv6 mask length.
191 type: int
192 ipv6_network_mask:
193 description:
194 - IPv6 network mask.
195 type: str
196 monitored_by_cluster:
197 description:
198 - When Private is selected as the Cluster interface type, cluster can monitor or not monitor the interface.
199 type: bool
200 network_interface_type:
201 description:
202 - Network Interface Type.
203 type: str
204 choices: ['alias', 'bond', 'bridge', 'bridge member', 'ethernet', 'loopback', '6 in 4 tunnel', 'pppoe', 'vpn tunnel', 'vlan']
205 security_zone_settings:
206 description:
207 - Security Zone Settings.
208 type: dict
209 suboptions:
210 auto_calculated:
211 description:
212 - Security Zone is calculated according to where the interface leads to.
213 type: bool
214 specific_zone:
215 description:
216 - Security Zone specified manually.
217 type: str
218 specific_security_zone_enabled:
219 description:
220 - Indicates whether to enable specific security zone.
221 type: bool
222 version_added: "6.8.0"
223 tags:
224 description:
225 - Collection of tag identifiers.
226 type: list
227 elements: str
228 topology:
229 description:
230 - Topology configuration.
231 type: str
232 choices: ['automatic', 'external', 'internal']
233 topology_settings:
234 description:
235 - Topology Settings.
236 type: dict
237 suboptions:
238 interface_leads_to_dmz:
239 description:
240 - Whether this interface leads to demilitarized zone (perimeter network).
241 type: bool
242 ip_address_behind_this_interface:
243 description:
244 - Network settings behind this interface.
245 type: str
246 choices: ['not defined', 'network defined by the interface ip and net mask', 'network defined by routing', 'specific']
247 specific_network:
248 description:
249 - Network behind this interface.
250 type: str
251 specific_network_uid:
252 description:
253 - N/A
254 type: str
255 color:
256 description:
257 - Color of the object. Should be one of existing colors.
258 type: str
259 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
260 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
261 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
262 comments:
263 description:
264 - Comments string.
265 type: str
266 details_level:
267 description:
268 - 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
269 representation of the object.
270 type: str
271 choices: ['uid', 'standard', 'full']
272 domains_to_process:
273 description:
274 - Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain only and
275 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
276 type: list
277 elements: str
278 ignore_warnings:
279 description:
280 - Apply changes ignoring warnings.
281 type: bool
282 ignore_errors:
283 description:
284 - 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.
285 type: bool
286 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
287 """
288
289 EXAMPLES = """
290 - name: add-interface
291 cp_mgmt_interface:
292 anti_spoofing: true
293 anti_spoofing_settings:
294 action: detect
295 exclude_packets: false
296 spoof_tracking: log
297 cluster_members:
298 - ipv4_address: 2.2.2.1
299 ipv4_mask_length: 24
300 ipv4_network_mask: 255.255.255.0
301 member_name: member1
302 name: eth4
303 - ipv4_address: 2.2.2.2
304 ipv4_mask_length: 24
305 ipv4_network_mask: 255.255.255.0
306 member_name: member2
307 name: eth4
308 cluster_network_type: cluster
309 gateway_uid: 20ec49e8-8cd8-4ad4-b204-0de8ae4e0e17
310 ignore_warnings: false
311 ipv4_address: 1.1.1.111
312 ipv4_mask_length: 24
313 name: eth0
314 security_zone_settings:
315 auto_calculated: false
316 specific_zone: InternalZone
317 state: present
318 topology: internal
319 topology_settings:
320 interface_leads_to_dmz: false
321 ip_address_behind_this_interface: network defined by routing
322
323 - name: set-interface
324 cp_mgmt_interface:
325 cluster_members:
326 - ipv4_address: 4.4.4.1
327 ipv4_mask_length: 22
328 member_name: memberReal1
329 uid: db4f8a63-5a94-46d8-b9e0-a63870bded3d
330 - ipv4_address: 4.4.4.2
331 ipv4_mask_length: 22
332 member_name: memberReal2
333 uid: baca571e-8ada-4be9-8966-145388f8e238
334 cluster_network_type: cluster + sync
335 ipv4_address: 4.4.4.111
336 ipv4_mask_length: 22
337 state: present
338 topology: internal
339 topology_settings:
340 ip_address_behind_this_interface: network defined by routing
341 name: eth0
342 gateway_uid: 20ec49e8-8cd8-4ad4-b204-0de8ae4e0e17
343
344 - name: delete-interface
345 cp_mgmt_interface:
346 state: absent
347 name: eth0
348 gateway_uid: 20ec49e8-8cd8-4ad4-b204-0de8ae4e0e17
349 """
350
351 RETURN = """
352 cp_mgmt_interface:
353 description: The checkpoint object created or updated.
354 returned: always, except when deleting the object.
355 type: dict
356 """
357
358 from ansible.module_utils.basic import AnsibleModule
359 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call
360
361
362 def main():
363 argument_spec = dict(
364 name=dict(type='str', required=True),
365 gateway_uid=dict(type='str', required=True),
366 anti_spoofing=dict(type='bool'),
367 anti_spoofing_settings=dict(type='dict', options=dict(
368 action=dict(type='str', choices=['prevent', 'detect']),
369 exclude_packets=dict(type='bool'),
370 excluded_network_name=dict(type='str'),
371 excluded_network_uid=dict(type='str'),
372 spoof_tracking=dict(type='str', choices=['none', 'log', 'alert'])
373 )),
374 cluster_members=dict(type='list', elements='dict', options=dict(
375 name=dict(type='str'),
376 member_name=dict(type='str'),
377 ip_address=dict(type='str'),
378 ipv4_address=dict(type='str'),
379 ipv6_address=dict(type='str'),
380 network_mask=dict(type='str'),
381 ipv4_network_mask=dict(type='str'),
382 ipv6_network_mask=dict(type='str'),
383 mask_length=dict(type='str'),
384 ipv4_mask_length=dict(type='str'),
385 ipv6_mask_length=dict(type='str'),
386 tags=dict(type='list', elements='str'),
387 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan',
388 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick',
389 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral',
390 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red',
391 'sienna', 'yellow']),
392 comments=dict(type='str'),
393 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
394 ignore_warnings=dict(type='bool'),
395 ignore_errors=dict(type='bool')
396 )),
397 cluster_network_type=dict(type='str', choices=['cluster', 'sync', 'cluster + sync', 'private']),
398 dynamic_ip=dict(type='bool'),
399 ipv4_address=dict(type='str'),
400 ipv4_mask_length=dict(type='int'),
401 ipv4_network_mask=dict(type='str'),
402 ipv6_address=dict(type='str'),
403 ipv6_mask_length=dict(type='int'),
404 ipv6_network_mask=dict(type='str'),
405 monitored_by_cluster=dict(type='bool'),
406 network_interface_type=dict(type='str', choices=['alias', 'bond', 'bridge', 'bridge member',
407 'ethernet', 'loopback', '6 in 4 tunnel', 'pppoe', 'vpn tunnel', 'vlan']),
408 security_zone_settings=dict(type='dict', options=dict(
409 auto_calculated=dict(type='bool'),
410 specific_zone=dict(type='str'),
411 specific_security_zone_enabled=dict(type='bool')
412 )),
413 tags=dict(type='list', elements='str'),
414 topology=dict(type='str', choices=['automatic', 'external', 'internal']),
415 topology_settings=dict(type='dict', options=dict(
416 interface_leads_to_dmz=dict(type='bool'),
417 ip_address_behind_this_interface=dict(type='str', choices=['not defined',
418 'network defined by the interface ip and net mask', 'network defined by routing',
419 'specific']),
420 specific_network=dict(type='str'),
421 specific_network_uid=dict(type='str')
422 )),
423 color=dict(type='str', choices=['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green',
424 'khaki', 'orchid', 'dark orange', 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown',
425 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon', 'coral', 'sea green',
426 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna',
427 'yellow']),
428 comments=dict(type='str'),
429 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
430 domains_to_process=dict(type='list', elements='str'),
431 ignore_warnings=dict(type='bool'),
432 ignore_errors=dict(type='bool')
433 )
434 argument_spec.update(checkpoint_argument_spec_for_objects)
435
436 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
437 api_call_object = 'interface'
438
439 result = api_call(module, api_call_object)
440 module.exit_json(**result)
441
442
443 if __name__ == '__main__':
444 main()