Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_interoperable_device.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_interoperable_device
33 short_description: Manages interoperable-device objects on Checkpoint over Web Services API
34 description:
35 - Manages interoperable-device objects on Checkpoint devices including creating, updating and removing objects.
36 - All operations are performed over Web Services API.
37 - Available from R81.20 management version.
38 version_added: "3.0.0"
39 author: "Eden Brillant (@chkp-edenbr)"
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.
49 type: str
50 ipv4_address:
51 description:
52 - IPv4 address of the Interoperable Device.
53 type: str
54 ipv6_address:
55 description:
56 - IPv6 address of the Interoperable Device.
57 type: str
58 interfaces:
59 description:
60 - Network interfaces.
61 type: list
62 elements: dict
63 suboptions:
64 name:
65 description:
66 - Object name. Must be unique in the domain.
67 type: str
68 ip_address:
69 description:
70 - IPv4 or IPv6 address. If both addresses are required use ipv4-address and ipv6-address fields explicitly.
71 type: str
72 ipv4_address:
73 description:
74 - IPv4 address.
75 type: str
76 ipv6_address:
77 description:
78 - IPv6 address.
79 type: str
80 network_mask:
81 description:
82 - IPv4 or IPv6 network mask. If both masks are required use ipv4-network-mask and ipv6-network-mask fields explicitly. Instead of
83 providing mask itself it is possible to specify IPv4 or IPv6 mask length in mask-length field. If both masks length are required use
84 ipv4-mask-length and ipv6-mask-length fields explicitly.
85 type: str
86 ipv4_network_mask:
87 description:
88 - IPv4 network address.
89 type: str
90 ipv6_network_mask:
91 description:
92 - IPv6 network address.
93 type: str
94 mask_length:
95 description:
96 - IPv4 or IPv6 network mask length.
97 type: str
98 ipv4_mask_length:
99 description:
100 - IPv4 network mask length.
101 type: str
102 ipv6_mask_length:
103 description:
104 - IPv6 network mask length.
105 type: str
106 tags:
107 description:
108 - Collection of tag identifiers.
109 type: list
110 elements: str
111 topology:
112 description:
113 - Topology configuration.
114 type: str
115 choices: ['external', 'internal']
116 topology_settings:
117 description:
118 - Internal topology settings.
119 type: dict
120 suboptions:
121 interface_leads_to_dmz:
122 description:
123 - Whether this interface leads to demilitarized zone (perimeter network).
124 type: bool
125 ip_address_behind_this_interface:
126 description:
127 - Network settings behind this interface.
128 type: str
129 choices: ['not defined', 'network defined by the interface ip and net mask', 'network defined by routing', 'specific']
130 specific_network:
131 description:
132 - Network behind this interface.
133 type: str
134 color:
135 description:
136 - Color of the object. Should be one of existing colors.
137 type: str
138 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange',
139 'dark sea green', 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray',
140 'light green', 'lemon chiffon', 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive',
141 'orange', 'red', 'sienna', 'yellow']
142 comments:
143 description:
144 - Comments string.
145 type: str
146 details_level:
147 description:
148 - 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
149 representation of the object.
150 type: str
151 choices: ['uid', 'standard', 'full']
152 domains_to_process:
153 description:
154 - Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain
155 only and with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
156 type: list
157 elements: str
158 ignore_warnings:
159 description:
160 - Apply changes ignoring warnings.
161 type: bool
162 ignore_errors:
163 description:
164 - 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.
165 type: bool
166 vpn_settings:
167 description:
168 - VPN domain properties for the Interoperable Device.
169 type: dict
170 suboptions:
171 vpn_domain:
172 description:
173 - Network group representing the customized encryption domain. Must be set when vpn-domain-type is set to 'manual' option.
174 type: str
175 vpn_domain_exclude_external_ip_addresses:
176 description:
177 - Exclude the external IP addresses from the VPN domain of this Interoperable device.
178 type: bool
179 vpn_domain_type:
180 description:
181 - Indicates the encryption domain.
182 type: str
183 choices: ['manual', 'addresses_behind_gw']
184 tags:
185 description:
186 - Collection of tag identifiers.
187 type: list
188 elements: str
189 color:
190 description:
191 - Color of the object. Should be one of existing colors.
192 type: str
193 choices: ['aquamarine', 'black', 'blue', 'crete blue', 'burlywood', 'cyan', 'dark green', 'khaki', 'orchid', 'dark orange', 'dark sea green',
194 'pink', 'turquoise', 'dark blue', 'firebrick', 'brown', 'forest green', 'gold', 'dark gold', 'gray', 'dark gray', 'light green', 'lemon chiffon',
195 'coral', 'sea green', 'sky blue', 'magenta', 'purple', 'slate blue', 'violet red', 'navy blue', 'olive', 'orange', 'red', 'sienna', 'yellow']
196 comments:
197 description:
198 - Comments string.
199 type: str
200 details_level:
201 description:
202 - 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
203 representation of the object.
204 type: str
205 choices: ['uid', 'standard', 'full']
206 domains_to_process:
207 description:
208 - 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
209 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
210 type: list
211 elements: str
212 ignore_warnings:
213 description:
214 - Apply changes ignoring warnings.
215 type: bool
216 groups:
217 description:
218 - Collection of group identifiers.
219 type: list
220 elements: str
221 ignore_errors:
222 description:
223 - 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.
224 type: bool
225 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
226 """
227
228 EXAMPLES = """
229 - name: add-interoperable-device
230 cp_mgmt_interoperable_device:
231 ip_address: 192.168.1.6
232 name: NewInteroperableDevice
233 state: present
234
235 - name: set-interoperable-device
236 cp_mgmt_interoperable_device:
237 ip_address: 192.168.1.6
238 name: NewInteroperableDevice
239 state: present
240
241 - name: delete-interoperable-device
242 cp_mgmt_interoperable_device:
243 name: NewInteroperableDevice
244 state: absent
245 """
246
247 RETURN = """
248 cp_mgmt_interoperable_device:
249 description: The checkpoint object created or updated.
250 returned: always, except when deleting the object.
251 type: dict
252 """
253
254 from ansible.module_utils.basic import AnsibleModule
255 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import (
256 checkpoint_argument_spec_for_objects,
257 api_call,
258 )
259
260
261 def main():
262 argument_spec = dict(
263 name=dict(type="str", required=True),
264 ip_address=dict(type="str"),
265 ipv4_address=dict(type="str"),
266 ipv6_address=dict(type="str"),
267 interfaces=dict(
268 type="list",
269 elements="dict",
270 options=dict(
271 name=dict(type="str"),
272 ip_address=dict(type="str"),
273 ipv4_address=dict(type="str"),
274 ipv6_address=dict(type="str"),
275 network_mask=dict(type="str"),
276 ipv4_network_mask=dict(type="str"),
277 ipv6_network_mask=dict(type="str"),
278 mask_length=dict(type="str"),
279 ipv4_mask_length=dict(type="str"),
280 ipv6_mask_length=dict(type="str"),
281 tags=dict(type="list", elements="str"),
282 topology=dict(type="str", choices=["external", "internal"]),
283 topology_settings=dict(
284 type="dict",
285 options=dict(
286 interface_leads_to_dmz=dict(type="bool"),
287 ip_address_behind_this_interface=dict(
288 type="str",
289 choices=[
290 "not defined",
291 "network defined by the interface ip and net mask",
292 "network defined by routing",
293 "specific",
294 ],
295 ),
296 specific_network=dict(type="str"),
297 ),
298 ),
299 color=dict(
300 type="str",
301 choices=[
302 "aquamarine",
303 "black",
304 "blue",
305 "crete blue",
306 "burlywood",
307 "cyan",
308 "dark green",
309 "khaki",
310 "orchid",
311 "dark orange",
312 "dark sea green",
313 "pink",
314 "turquoise",
315 "dark blue",
316 "firebrick",
317 "brown",
318 "forest green",
319 "gold",
320 "dark gold",
321 "gray",
322 "dark gray",
323 "light green",
324 "lemon chiffon",
325 "coral",
326 "sea green",
327 "sky blue",
328 "magenta",
329 "purple",
330 "slate blue",
331 "violet red",
332 "navy blue",
333 "olive",
334 "orange",
335 "red",
336 "sienna",
337 "yellow",
338 ],
339 ),
340 comments=dict(type="str"),
341 details_level=dict(
342 type="str", choices=["uid", "standard", "full"]
343 ),
344 domains_to_process=dict(type="list", elements="str"),
345 ignore_warnings=dict(type="bool"),
346 ignore_errors=dict(type="bool"),
347 ),
348 ),
349 vpn_settings=dict(
350 type="dict",
351 options=dict(
352 vpn_domain=dict(type="str"),
353 vpn_domain_exclude_external_ip_addresses=dict(type="bool"),
354 vpn_domain_type=dict(
355 type="str", choices=["manual", "addresses_behind_gw"]
356 ),
357 ),
358 ),
359 tags=dict(type="list", elements="str"),
360 color=dict(
361 type="str",
362 choices=[
363 "aquamarine",
364 "black",
365 "blue",
366 "crete blue",
367 "burlywood",
368 "cyan",
369 "dark green",
370 "khaki",
371 "orchid",
372 "dark orange",
373 "dark sea green",
374 "pink",
375 "turquoise",
376 "dark blue",
377 "firebrick",
378 "brown",
379 "forest green",
380 "gold",
381 "dark gold",
382 "gray",
383 "dark gray",
384 "light green",
385 "lemon chiffon",
386 "coral",
387 "sea green",
388 "sky blue",
389 "magenta",
390 "purple",
391 "slate blue",
392 "violet red",
393 "navy blue",
394 "olive",
395 "orange",
396 "red",
397 "sienna",
398 "yellow",
399 ],
400 ),
401 comments=dict(type="str"),
402 details_level=dict(type="str", choices=["uid", "standard", "full"]),
403 domains_to_process=dict(type="list", elements="str"),
404 ignore_warnings=dict(type="bool"),
405 groups=dict(type="list", elements="str"),
406 ignore_errors=dict(type="bool"),
407 )
408 argument_spec.update(checkpoint_argument_spec_for_objects)
409
410 module = AnsibleModule(
411 argument_spec=argument_spec, supports_check_mode=True
412 )
413 api_call_object = "interoperable-device"
414
415 result = api_call(module, api_call_object)
416 module.exit_json(**result)
417
418
419 if __name__ == "__main__":
420 main()