Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_lsm_cluster.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 = {
25 "metadata_version": "1.1",
26 "status": ["preview"],
27 "supported_by": "community",
28 }
29
30 DOCUMENTATION = """
31 ---
32 module: cp_mgmt_lsm_cluster
33 short_description: Manages lsm-cluster objects on Checkpoint over Web Services API
34 description:
35 - Manages lsm-cluster objects on Checkpoint devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R81.10 management version.
38 version_added: "2.3.0"
39 author: "Shiran Golzar (@chkp-shirango)"
40 options:
41 main_ip_address:
42 description:
43 - Main IP address.
44 type: str
45 name_prefix:
46 description:
47 - A prefix added to the profile name and creates the LSM cluster name.
48 type: str
49 name_suffix:
50 description:
51 - A suffix added to the profile name and creates the LSM cluster name.
52 type: str
53 security_profile:
54 description:
55 - LSM profile.
56 type: str
57 required: True
58 dynamic_objects:
59 description:
60 - Dynamic Objects.
61 - Available from R81.20 management version.
62 type: list
63 elements: dict
64 version_added: "6.3.0"
65 suboptions:
66 name:
67 description:
68 - Object name. Must be unique in the domain.
69 type: str
70 resolved_ip_addresses:
71 description:
72 - Single IP-address or a range of addresses.
73 type: list
74 elements: dict
75 suboptions:
76 ipv4_address:
77 description:
78 - IPv4 Address.
79 type: str
80 ipv4_address_range:
81 description:
82 - IPv4 Address range.
83 type: dict
84 suboptions:
85 from_ipv4_address:
86 description:
87 - First IPv4 address of the IP address range.
88 type: str
89 to_ipv4_address:
90 description:
91 - Last IPv4 address of the IP address range.
92 type: str
93 interfaces:
94 description:
95 - Interfaces.
96 type: list
97 elements: dict
98 suboptions:
99 name:
100 description:
101 - Interface name.
102 type: str
103 ip_address_override:
104 description:
105 - IP address override. Net mask is defined by the attached LSM profile.
106 type: str
107 member_network_override:
108 description:
109 - Member network override. Net mask is defined by the attached LSM profile.
110 type: str
111 members:
112 description:
113 - Members.
114 type: list
115 elements: dict
116 suboptions:
117 name:
118 description:
119 - Object name.
120 type: str
121 provisioning_settings:
122 description:
123 - Provisioning settings. This field is relevant just for SMB clusters.
124 type: dict
125 suboptions:
126 provisioning_profile:
127 description:
128 - Provisioning profile.
129 type: str
130 provisioning_state:
131 description:
132 - Provisioning state. This field is relevant just for SMB clusters. By default the state is 'manual'- enable provisioning but not attach
133 to profile.If 'using-profile' state is provided a provisioning profile must be provided in provisioning-settings.
134 type: str
135 choices: ['off', 'manual', 'using-profile']
136 sic:
137 description:
138 - Secure Internal Communication.
139 type: dict
140 suboptions:
141 ip_address:
142 description:
143 - IP address. When IP address is provided- initiate trusted communication immediately using this IP address.
144 type: str
145 one_time_password:
146 description:
147 - One-time password. When one-time password is provided without ip-address- trusted communication is
148 automatically initiated when the gateway connects to the Security Management server for the first time.
149 type: str
150 tags:
151 description:
152 - Collection of tag identifiers.
153 type: list
154 elements: str
155 color:
156 description:
157 - Color of the object. Should be one of existing colors.
158 type: str
159 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange',
160 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray',
161 'light green', 'lemon chiffon', 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive',
162 'orange', 'red', 'sienna', 'yellow']
163 comments:
164 description:
165 - Comments string.
166 type: str
167 topology:
168 description:
169 - Topology.
170 - Available from R81.20 management version.
171 type: dict
172 version_added: "6.3.0"
173 suboptions:
174 manual_vpn_domain:
175 description:
176 - A list of IP-addresses ranges, defined the VPN community network.
177 This field is relevant only when 'manual' option of vpn-domain is checked.
178 type: list
179 elements: dict
180 suboptions:
181 comments:
182 description:
183 - Comments string.
184 type: str
185 from_ipv4_address:
186 description:
187 - First IPv4 address of the IP address range.
188 type: str
189 to_ipv4_address:
190 description:
191 - Last IPv4 address of the IP address range.
192 type: str
193 vpn_domain:
194 description:
195 - VPN Domain type. 'external-interfaces-only' is relevant only for Gaia devices.
196 'hide-behind-gateway-external-ip-address' is relevant only for SMB devices.
197 type: str
198 choices: ['not-defined', 'external-ip-addresses-only', 'hide-behind-gateway-external-ip-address', 'all-ip-addresses-behind-the-gateway', 'manual']
199 color:
200 description:
201 - Color of the object. Should be one of existing colors.
202 type: str
203 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
204 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
205 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
206 comments:
207 description:
208 - Comments string.
209 type: str
210 details_level:
211 description:
212 - 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
213 representation of the object.
214 type: str
215 choices: ['uid', 'standard', 'full']
216 tags:
217 description:
218 - Collection of tag identifiers.
219 type: list
220 elements: str
221 version_added: "6.3.0"
222 ignore_warnings:
223 description:
224 - Apply changes ignoring warnings.
225 type: bool
226 ignore_errors:
227 description:
228 - 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.
229 type: bool
230 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
231 """
232
233 EXAMPLES = """
234 - name: add-lsm-cluster
235 cp_mgmt_lsm_cluster:
236 interfaces:
237 - ip_address_override: 192.168.8.197
238 member_network_override: 192.168.8.0
239 name: eth0
240 new_name: WAN
241 - ip_address_override: 10.8.197.1
242 member_network_override: 10.8.197.0
243 name: eth1
244 new_name: LAN1
245 - member_network_override: 10.10.10.0
246 name: eth2
247 main_ip_address: 192.168.8.197
248 members:
249 - name: Gaia_gw1
250 sic:
251 ip_address: 192.168.8.200
252 one_time_password: aaaa
253 - name: Gaia_gw2
254 sic:
255 ip_address: 192.168.8.202
256 one_time_password: aaaa
257 name_prefix: Gaia_
258 security_profile: gaia_cluster
259 state: present
260
261 - name: set-lsm-cluster
262 cp_mgmt_lsm_cluster:
263 interfaces:
264 - ip_address_override: 192.168.8.197
265 member_network_override: 192.168.8.0
266 name: eth0
267 new_name: WAN
268 - ip_address_override: 10.8.197.1
269 member_network_override: 10.8.197.0
270 name: eth1
271 new_name: LAN1
272 - member_network_override: 10.10.10.0
273 name: eth2
274 members:
275 - name: Gaia_gw1
276 sic:
277 ip_address: 192.168.8.200
278 one_time_password: aaaa
279 - name: Gaia_gw2
280 sic:
281 ip_address: 192.168.8.202
282 one_time_password: aaaa
283 name: Gaia_gaia_cluster
284 state: present
285
286 - name: delete-lsm-cluster
287 cp_mgmt_lsm_cluster:
288 name: lsm_cluster
289 state: absent
290 """
291
292 RETURN = """
293 cp_mgmt_lsm_cluster:
294 description: The checkpoint object created or updated.
295 returned: always, except when deleting the object.
296 type: dict
297 """
298
299 from ansible.module_utils.basic import AnsibleModule
300 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
301 checkpoint_argument_spec_for_objects,
302 api_call,
303 )
304
305
306 def main():
307 argument_spec = dict(
308 main_ip_address=dict(type="str"),
309 name_prefix=dict(type="str"),
310 name_suffix=dict(type="str"),
311 security_profile=dict(type="str", required=True),
312 dynamic_objects=dict(type='list', elements="dict", options=dict(
313 name=dict(type='str'),
314 resolved_ip_addresses=dict(type='list', elements="dict", options=dict(
315 ipv4_address=dict(type='str'),
316 ipv4_address_range=dict(type='dict', options=dict(
317 from_ipv4_address=dict(type='str'),
318 to_ipv4_address=dict(type='str')
319 ))
320 ))
321 )),
322 interfaces=dict(
323 type="list",
324 elements="dict",
325 options=dict(
326 name=dict(type="str"),
327 ip_address_override=dict(type="str"),
328 member_network_override=dict(type="str"),
329 ),
330 ),
331 members=dict(
332 type="list",
333 elements="dict",
334 options=dict(
335 name=dict(type="str"),
336 provisioning_settings=dict(
337 type="dict",
338 options=dict(provisioning_profile=dict(type="str")),
339 ),
340 provisioning_state=dict(
341 type="str", choices=["off", "manual", "using-profile"]
342 ),
343 sic=dict(
344 type="dict",
345 options=dict(
346 ip_address=dict(type="str"),
347 one_time_password=dict(type="str", no_log=True),
348 ),
349 ),
350 tags=dict(type="list", elements="str"),
351 color=dict(
352 type="str",
353 choices=[
354 "aquamarine",
355 "black",
356 "blue",
357 "crete blue",
358 "burlywood",
359 "cyan",
360 "dark green",
361 "khaki",
362 "orchid",
363 "dark orange",
364 "dark sea green",
365 "pink",
366 "turquoise",
367 "dark blue",
368 "firebrick",
369 "brown",
370 "forest green",
371 "gold",
372 "dark gold",
373 "gray",
374 "dark gray",
375 "light green",
376 "lemon chiffon",
377 "coral",
378 "sea green",
379 "sky blue",
380 "magenta",
381 "purple",
382 "slate blue",
383 "violet red",
384 "navy blue",
385 "olive",
386 "orange",
387 "red",
388 "sienna",
389 "yellow",
390 ],
391 ),
392 comments=dict(type="str"),
393 ),
394 ),
395 topology=dict(type='dict', options=dict(
396 manual_vpn_domain=dict(type='list', elements="dict", options=dict(
397 comments=dict(type='str'),
398 from_ipv4_address=dict(type='str'),
399 to_ipv4_address=dict(type='str')
400 )),
401 vpn_domain=dict(type='str',
402 choices=['not-defined',
403 'external-ip-addresses-only',
404 'hide-behind-gateway-external-ip-address',
405 'all-ip-addresses-behind-the-gateway',
406 'manual'])
407 )),
408 color=dict(
409 type="str",
410 choices=[
411 "aquamarine",
412 "black",
413 "blue",
414 "crete blue",
415 "burlywood",
416 "cyan",
417 "dark green",
418 "khaki",
419 "orchid",
420 "dark orange",
421 "dark sea green",
422 "pink",
423 "turquoise",
424 "dark blue",
425 "firebrick",
426 "brown",
427 "forest green",
428 "gold",
429 "dark gold",
430 "gray",
431 "dark gray",
432 "light green",
433 "lemon chiffon",
434 "coral",
435 "sea green",
436 "sky blue",
437 "magenta",
438 "purple",
439 "slate blue",
440 "violet red",
441 "navy blue",
442 "olive",
443 "orange",
444 "red",
445 "sienna",
446 "yellow",
447 ],
448 ),
449 comments=dict(type="str"),
450 details_level=dict(type="str", choices=["uid", "standard", "full"]),
451 tags=dict(type='list', elements="str"),
452 ignore_warnings=dict(type="bool"),
453 ignore_errors=dict(type="bool"),
454 )
455 argument_spec.update(checkpoint_argument_spec_for_objects)
456
457 module = AnsibleModule(
458 argument_spec=argument_spec, supports_check_mode=True
459 )
460
461 # Create lsm-cluster name
462 name = module.params["security_profile"]
463
464 if module.params["name_prefix"]:
465 name = module.params["name_prefix"] + name
466 if module.params["name_suffix"]:
467 name = name + module.params["name_suffix"]
468 module.params["name"] = name
469
470 api_call_object = "lsm-cluster"
471
472 result = api_call(module, api_call_object)
473 module.exit_json(**result)
474
475
476 if __name__ == "__main__":
477 main()