Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2022 Red Hat
4 # GNU General Public License v3.0+
5 # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 """
8 The module file for cp_mgmt_add_access_layers
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13 __metaclass__ = type
14
15 DOCUMENTATION = """
16 module: cp_mgmt_access_layers
17 short_description: Manages ACCESS LAYERS resource module
18 description:
19 - This resource module allows for addition, deletion, or modification of CP Access Layers.
20 - This resource module also takes care of gathering Access layer config facts
21 - Available from R80 management version.
22 version_added: "5.0.0"
23 author: Ansible Security Automation Team (@justjais) <https://github.com/ansible-security>
24 options:
25 config:
26 description: A dictionary of ACCESS LAYERS options
27 type: dict
28 suboptions:
29 name:
30 description: Object name. Must be unique in the domain.
31 type: str
32 add_default_rule:
33 description: Indicates whether to include a cleanup rule in the new layer.
34 type: bool
35 applications_and_url_filtering:
36 description: Whether to enable Applications & URL Filtering blade on the layer.
37 type: bool
38 content_awareness:
39 description: Whether to enable Content Awareness blade on the layer.
40 type: bool
41 detect_using_x_forward_for:
42 description: Whether to use X-Forward-For HTTP header, which is added by the proxy
43 server to keep track of the original source IP.
44 type: bool
45 firewall:
46 description: Whether to enable Firewall blade on the layer.
47 type: bool
48 implicit_cleanup_action:
49 description: The default "catch-all" action for traffic that does not match
50 any explicit or implied rules in the layer.
51 type: str
52 choices:
53 - drop
54 - accept
55 mobile_access:
56 description: Whether to enable Mobile Access blade on the layer.
57 type: bool
58 shared:
59 description: Whether this layer is shared.
60 type: bool
61 tags:
62 description: Collection of tag identifiers.
63 type: list
64 elements: str
65 color:
66 description: Color of the object. Should be one of existing colors.
67 type: str
68 choices:
69 - aquamarine
70 - black
71 - blue
72 - crete blue
73 - burlywood
74 - cyan
75 - dark green
76 - khaki
77 - orchid
78 - dark orange
79 - dark sea green
80 - pink
81 - turquoise
82 - dark blue
83 - firebrick
84 - brown
85 - forest green
86 - gold
87 - dark gold
88 - gray
89 - dark gray
90 - light green
91 - lemon chiffon
92 - coral
93 - sea green
94 - sky blue
95 - magenta
96 - purple
97 - slate blue
98 - violet red
99 - navy blue
100 - olive
101 - orange
102 - red
103 - sienna
104 - yellow
105 comments:
106 description: Comments string.
107 type: str
108 details_level:
109 description: The level of detail for some of the fields in the response can
110 vary from showing only the UID value of the object to a fully detailed representation
111 of the object.
112 type: str
113 choices:
114 - uid
115 - standard
116 - full
117 ignore_warnings:
118 description: Apply changes ignoring warnings.
119 type: bool
120 ignore_errors:
121 description: Apply changes ignoring errors. You won't be able to publish such
122 a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
123 type: bool
124 limit:
125 description:
126 - The maximal number of returned results.
127 - NOTE, this parameter is a valid parameter only for the GATHERED state, for config states
128 like, MERGED, REPLACED, and DELETED state it won't be applicable.
129 type: int
130 offset:
131 description:
132 - Number of the results to initially skip.
133 - NOTE, this parameter is a valid parameter only for the GATHERED state, for config states
134 like, MERGED, REPLACED, and DELETED state it won't be applicable.
135 type: int
136 order:
137 description:
138 - Sorts results by the given field. By default the results are sorted in the ascending order by name.
139 This parameter is relevant only for getting few objects.
140 - NOTE, this parameter is a valid parameter only for the GATHERED state, for config states
141 like, MERGED, REPLACED, and DELETED state it won't be applicable.
142 type: list
143 elements: dict
144 suboptions:
145 ASC:
146 description:
147 - Sorts results by the given field in ascending order.
148 type: str
149 DESC:
150 description:
151 - Sorts results by the given field in descending order.
152 type: str
153 round_trip:
154 description:
155 - If set to True, the round trip will filter out the module parameters from the response param,
156 which will enable the user to fire the config request using the structured gathered data.
157 - NOTE, this parameter makes relevance only with the GATHERED state, as for config states like,
158 MERGED, REPLACED, and DELETED state it won't make any config updates,
159 as it's not a module config parameter.
160 type: bool
161 auto_publish_session:
162 description:
163 - Publish the current session if changes have been performed
164 after task completes.
165 type: bool
166 version:
167 description:
168 - Version of checkpoint. If not given one, the latest version taken.
169 type: str
170 state:
171 description:
172 - The state the configuration should be left in
173 - The state I(gathered) will get the module API configuration from the device
174 and transform it into structured data in the format as per the module argspec
175 and the value is returned in the I(gathered) key within the result.
176 type: str
177 choices:
178 - merged
179 - replaced
180 - gathered
181 - deleted
182 """
183
184 EXAMPLES = """
185
186 # Using MERGED state
187 # -------------------
188
189 - name: Merge Access-layer config
190 cp_mgmt_access_layers:
191 state: merged
192 config:
193 name: New Layer 1
194 add_default_rule: true
195 applications_and_url_filtering: true
196 content_awareness: true
197 detect_using_x_forward_for: false
198 firewall: true
199 implicit_cleanup_action: drop
200 mobile_access: true
201 shared: false
202 tags:
203 - test_layer
204 color: aquamarine
205 comments: test description
206 details_level: full
207 ignore_warnings: false
208 ignore_errors: false
209 round_trip: true
210
211 # RUN output:
212 # -----------
213
214 # mgmt_access_layers:
215 # after:
216 # applications_and_url_filtering: true
217 # color: aquamarine
218 # comments: test description
219 # content_awareness: true
220 # detect_using_x_forward_for: false
221 # domain: SMC User
222 # firewall: true
223 # icon: ApplicationFirewall/rulebase
224 # implicit_cleanup_action: drop
225 # mobile_access: true
226 # name: New Layer 1
227 # shared: false
228 # tags:
229 # - test_layer
230 # uid: eb74d7fe-81a6-4e6c-aedb-d2d6599f965e
231 # before: {}
232
233 # Using REPLACED state
234 # --------------------
235
236 - name: Replace Access-layer config
237 cp_mgmt_access_layers:
238 state: replaced
239 config:
240 name: New Layer 1
241 add_default_rule: true
242 applications_and_url_filtering: true
243 content_awareness: false
244 detect_using_x_forward_for: false
245 firewall: true
246 implicit_cleanup_action: drop
247 mobile_access: true
248 shared: true
249 tags:
250 - test_layer_replaced
251 color: cyan
252 comments: test REPLACE description
253 details_level: full
254 ignore_warnings: false
255 ignore_errors: false
256 round_trip: true
257
258 # RUN output:
259 # -----------
260
261 # mgmt_access_layers:
262 # after:
263 # applications_and_url_filtering: true
264 # color: cyan
265 # comments: test REPLACE description
266 # content_awareness: false
267 # detect_using_x_forward_for: false
268 # domain: SMC User
269 # firewall: true
270 # icon: ApplicationFirewall/sharedrulebase
271 # implicit_cleanup_action: drop
272 # mobile_access: true
273 # name: New Layer 1
274 # shared: true
275 # tags:
276 # - test_layer_replaced
277 # uid: a4e2bbc1-ec94-4b85-9b00-07ad1279ac12
278 # before:
279 # applications_and_url_filtering: true
280 # color: aquamarine
281 # comments: test description
282 # content_awareness: true
283 # detect_using_x_forward_for: false
284 # firewall: true
285 # icon: ApplicationFirewall/rulebase
286 # implicit_cleanup_action: drop
287 # mobile_access: true
288 # name: New Layer 1
289 # shared: false
290 # tags:
291 # - test_layer
292
293 # Using GATHERED state
294 # --------------------
295
296 # 1. With Round Trip set to True
297
298 - name: Gather Access-layers config by Name
299 cp_mgmt_access_layers:
300 state: gathered
301 config:
302 name: New Layer 1
303 round_trip: true
304
305 # RUN output:
306 # -----------
307
308 # gathered:
309 # applications_and_url_filtering: true
310 # color: aquamarine
311 # comments: test description
312 # content_awareness: true
313 # detect_using_x_forward_for: false
314 # domain: SMC User
315 # firewall: true
316 # icon: ApplicationFirewall/rulebase
317 # implicit_cleanup_action: drop
318 # mobile_access: true
319 # name: New Layer 1
320 # shared: false
321 # tags:
322 # - test_layer
323 # uid: eb74d7fe-81a6-4e6c-aedb-d2d6599f965e
324
325 # 2. With Round Trip set to False which is the default behaviour
326
327 - name: Gather Access-layers config by Name
328 cp_mgmt_access_layers:
329 state: gathered
330 config:
331 name: New Layer 1
332
333 # RUN output:
334 # -----------
335
336 # gathered:
337 # applications_and_url_filtering: true
338 # color: turquoise
339 # comments: test description
340 # content_awareness: true
341 # detect_using_x_forward_for: false
342 # domain:
343 # domain-type: domain
344 # name: SMC User
345 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
346 # firewall: true
347 # icon: ApplicationFirewall/rulebase
348 # implicit_cleanup_action: drop
349 # meta-info:
350 # creation-time:
351 # iso-8601: 2022-11-21T07:34+0000
352 # posix: 1669016073937
353 # creator: admin
354 # last-modifier: admin
355 # last-modify-time:
356 # iso-8601: 2022-11-21T07:34+0000
357 # posix: 1669016074765
358 # lock: unlocked
359 # validation-state: ok
360 # mobile_access: true
361 # name: New Layer 1
362 # read-only: false
363 # shared: false
364 # tags:
365 # - domain:
366 # domain-type: domain
367 # name: SMC User
368 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
369 # name: test_layer
370 # type: tag
371 # uid: 22cc8b0d-984f-47de-b1f6-276b3377eb0c
372 # type: access-layer
373 # uid: a54e47d3-22fc-4aff-90d9-f644aa4a1522
374
375 # 3. Gather ALL threat-layer config with DESC order filter
376
377 - name: To Gather ALL access-layer and order by Name
378 cp_mgmt_access_layers:
379 config:
380 order:
381 - DESC: name
382 state: gathered
383
384 # RUN output:
385 # -----------
386
387 # gathered:
388 # - domain:
389 # domain-type: domain
390 # name: SMC User
391 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
392 # name: New Layer 1
393 # type: access-layer
394 # uid: a54e47d3-22fc-4aff-90d9-f644aa4a1522
395 # - domain:
396 # domain-type: domain
397 # name: SMC User
398 # uid: 41e821a0-3720-11e3-aa6e-0800200c9fde
399 # name: Network
400 # type: access-layer
401 # uid: 63b7fe60-76d2-4287-bca5-21af87337b0a
402
403 # Using DELETED state
404 # -------------------
405
406 - name: Delete Access-layer config by Name
407 cp_mgmt_access_layers:
408 state: deleted
409 config:
410 name: New Layer 1
411
412 # RUN output:
413 # -----------
414
415 # mgmt_access_layers:
416 # after: {}
417 # before:
418 # applications_and_url_filtering: true
419 # color: cyan
420 # comments: test REPLACE description
421 # content_awareness: false
422 # detect_using_x_forward_for: false
423 # domain: SMC User
424 # firewall: true
425 # icon: ApplicationFirewall/sharedrulebase
426 # implicit_cleanup_action: drop
427 # mobile_access: true
428 # name: New Layer 1
429 # shared: true
430 # tags:
431 # - test_layer_replaced
432 # uid: a4e2bbc1-ec94-4b85-9b00-07ad1279ac12
433 """
434
435 RETURN = """
436 before:
437 description: The configuration prior to the module execution.
438 returned: when state is I(merged), I(replaced), I(deleted)
439 type: dict
440 sample: >
441 This output will always be in the same format as the
442 module argspec.
443 after:
444 description: The resulting configuration after module execution.
445 returned: when changed
446 type: dict
447 sample: >
448 This output will always be in the same format as the
449 module argspec.
450 gathered:
451 description: Facts about the network resource gathered from the remote device as structured data.
452 returned: when state is I(gathered)
453 type: dict
454 sample: >
455 This output will always be in the same format as the
456 module argspec.
457 """