Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_address6.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_firewall_address6
15 short_description: Configure IPv6 firewall addresses.
16 version_added: "1.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 firewall_address6:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 cache_ttl:
34 aliases: ['cache-ttl']
35 type: int
36 description: Minimal TTL of individual IPv6 addresses in FQDN cache.
37 color:
38 type: int
39 description: Integer value to determine the color of the icon in the GUI
40 comment:
41 type: str
42 description: Comment.
43 dynamic_mapping:
44 type: list
45 elements: dict
46 description: Dynamic mapping.
47 suboptions:
48 _scope:
49 type: list
50 elements: dict
51 description: Scope.
52 suboptions:
53 name:
54 type: str
55 description: Name.
56 vdom:
57 type: str
58 description: Vdom.
59 cache_ttl:
60 aliases: ['cache-ttl']
61 type: int
62 description: Cache ttl.
63 color:
64 type: int
65 description: Color.
66 comment:
67 type: str
68 description: Comment.
69 end_ip:
70 aliases: ['end-ip']
71 type: str
72 description: End ip.
73 fqdn:
74 type: str
75 description: Fqdn.
76 host:
77 type: str
78 description: Host.
79 host_type:
80 aliases: ['host-type']
81 type: str
82 description: Host type.
83 choices: ['any', 'specific']
84 ip6:
85 type: str
86 description: Ip6.
87 obj_id:
88 aliases: ['obj-id']
89 type: str
90 description: Obj id.
91 sdn:
92 type: str
93 description: Sdn.
94 choices: ['nsx']
95 start_ip:
96 aliases: ['start-ip']
97 type: str
98 description: Start ip.
99 tags:
100 type: raw
101 description: (list or str) Tags.
102 template:
103 type: str
104 description: Template.
105 type:
106 type: str
107 description: Type.
108 choices: ['ipprefix', 'iprange', 'nsx', 'dynamic', 'fqdn', 'template',
109 'mac', 'geography', 'route-tag', 'wildcard']
110 uuid:
111 type: str
112 description: Uuid.
113 visibility:
114 type: str
115 description: Visibility.
116 choices: ['disable', 'enable']
117 subnet_segment:
118 aliases: ['subnet-segment']
119 type: list
120 elements: dict
121 description: Subnet segment.
122 suboptions:
123 name:
124 type: str
125 description: Name.
126 type:
127 type: str
128 description: Type.
129 choices: ['any', 'specific']
130 value:
131 type: str
132 description: Value.
133 _image_base64:
134 aliases: ['_image-base64']
135 type: str
136 description: Image base64.
137 end_mac:
138 aliases: ['end-mac']
139 type: str
140 description: End mac.
141 start_mac:
142 aliases: ['start-mac']
143 type: str
144 description: Start mac.
145 country:
146 type: str
147 description: Country.
148 global_object:
149 aliases: ['global-object']
150 type: int
151 description: Global object.
152 fabric_object:
153 aliases: ['fabric-object']
154 type: str
155 description: Security Fabric global object setting.
156 choices: ['disable', 'enable']
157 macaddr:
158 type: raw
159 description: (list) Multiple MAC address ranges.
160 epg_name:
161 aliases: ['epg-name']
162 type: str
163 description: Endpoint group name.
164 sdn_tag:
165 aliases: ['sdn-tag']
166 type: str
167 description: SDN Tag.
168 tenant:
169 type: str
170 description: Tenant.
171 route_tag:
172 aliases: ['route-tag']
173 type: int
174 description: Route-tag address.
175 filter:
176 type: str
177 description: Match criteria filter.
178 sdn_addr_type:
179 aliases: ['sdn-addr-type']
180 type: str
181 description: Type of addresses to collect.
182 choices: ['all', 'private', 'public']
183 wildcard:
184 type: str
185 description: IPv6 address and wildcard netmask.
186 passive_fqdn_learning:
187 aliases: ['passive-fqdn-learning']
188 type: str
189 description: Enable/disable passive learning of FQDNs.
190 choices: ['disable', 'enable']
191 end_ip:
192 aliases: ['end-ip']
193 type: str
194 description: Final IP address
195 fqdn:
196 type: str
197 description: Fully qualified domain name.
198 host:
199 type: str
200 description: Host Address.
201 host_type:
202 aliases: ['host-type']
203 type: str
204 description: Host type.
205 choices: ['any', 'specific']
206 ip6:
207 type: str
208 description: IPv6 address prefix
209 list:
210 type: list
211 elements: dict
212 description: List.
213 suboptions:
214 ip:
215 type: str
216 description: IP.
217 net_id:
218 aliases: ['net-id']
219 type: str
220 description: Network ID.
221 obj_id:
222 aliases: ['obj-id']
223 type: str
224 description: Object ID.
225 name:
226 type: str
227 description: Address name.
228 required: true
229 obj_id:
230 aliases: ['obj-id']
231 type: str
232 description: Object ID for NSX.
233 sdn:
234 type: str
235 description: SDN.
236 choices: ['nsx']
237 start_ip:
238 aliases: ['start-ip']
239 type: str
240 description: First IP address
241 subnet_segment:
242 aliases: ['subnet-segment']
243 type: list
244 elements: dict
245 description: Subnet segment.
246 suboptions:
247 name:
248 type: str
249 description: Name.
250 type:
251 type: str
252 description: Subnet segment type.
253 choices: ['any', 'specific']
254 value:
255 type: str
256 description: Subnet segment value.
257 tagging:
258 type: list
259 elements: dict
260 description: Tagging.
261 suboptions:
262 category:
263 type: str
264 description: Tag category.
265 name:
266 type: str
267 description: Tagging entry name.
268 tags:
269 type: raw
270 description: (list) Tags.
271 template:
272 type: str
273 description: IPv6 address template.
274 type:
275 type: str
276 description: Type of IPv6 address object
277 choices: ['ipprefix', 'iprange', 'nsx', 'dynamic', 'fqdn', 'template', 'mac',
278 'geography', 'route-tag', 'wildcard']
279 uuid:
280 type: str
281 description: Universally Unique Identifier
282 visibility:
283 type: str
284 description: Enable/disable the visibility of the object in the GUI.
285 choices: ['disable', 'enable']
286 tags:
287 type: str
288 description: Names of object-tags applied to address.
289 profile_list:
290 aliases: ['profile-list']
291 type: list
292 elements: dict
293 description: Profile list.
294 suboptions:
295 profile_id:
296 aliases: ['profile-id']
297 type: int
298 description: NSX service profile ID.
299 _image_base64:
300 aliases: ['_image-base64']
301 type: str
302 description: Image base64.
303 end_mac:
304 aliases: ['end-mac']
305 type: str
306 description: Last MAC address in the range.
307 start_mac:
308 aliases: ['start-mac']
309 type: str
310 description: First MAC address in the range.
311 country:
312 type: str
313 description: IPv6 addresses associated to a specific country.
314 global_object:
315 aliases: ['global-object']
316 type: int
317 description: Global Object.
318 fabric_object:
319 aliases: ['fabric-object']
320 type: str
321 description: Security Fabric global object setting.
322 choices: ['disable', 'enable']
323 macaddr:
324 type: raw
325 description: (list) Multiple MAC address ranges.
326 epg_name:
327 aliases: ['epg-name']
328 type: str
329 description: Endpoint group name.
330 sdn_tag:
331 aliases: ['sdn-tag']
332 type: str
333 description: SDN Tag.
334 tenant:
335 type: str
336 description: Tenant.
337 route_tag:
338 aliases: ['route-tag']
339 type: int
340 description: Route-tag address.
341 filter:
342 type: str
343 description: Match criteria filter.
344 sdn_addr_type:
345 aliases: ['sdn-addr-type']
346 type: str
347 description: Type of addresses to collect.
348 choices: ['all', 'private', 'public']
349 wildcard:
350 type: str
351 description: IPv6 address and wildcard netmask.
352 passive_fqdn_learning:
353 aliases: ['passive-fqdn-learning']
354 type: str
355 description: Enable/disable passive learning of FQDNs.
356 choices: ['disable', 'enable']
357 '''
358
359 EXAMPLES = '''
360 - name: Example playbook
361 hosts: fortimanagers
362 gather_facts: false
363 connection: httpapi
364 vars:
365 ansible_httpapi_use_ssl: true
366 ansible_httpapi_validate_certs: false
367 ansible_httpapi_port: 443
368 tasks:
369 - name: Configure IPv6 firewall addresses.
370 fortinet.fortimanager.fmgr_firewall_address6:
371 bypass_validation: false
372 adom: ansible
373 state: present
374 firewall_address6:
375 host_type: any # <value in [any, specific]>
376 ip6: "::/55"
377 name: "ansible-test"
378 visibility: disable
379
380 - name: Gathering fortimanager facts
381 hosts: fortimanagers
382 gather_facts: false
383 connection: httpapi
384 vars:
385 ansible_httpapi_use_ssl: true
386 ansible_httpapi_validate_certs: false
387 ansible_httpapi_port: 443
388 tasks:
389 - name: Retrieve all the IPv6 addresses
390 fortinet.fortimanager.fmgr_fact:
391 facts:
392 selector: "firewall_address6"
393 params:
394 adom: "ansible"
395 address6: "your_value"
396 '''
397
398 RETURN = '''
399 meta:
400 description: The result of the request.
401 type: dict
402 returned: always
403 contains:
404 request_url:
405 description: The full url requested.
406 returned: always
407 type: str
408 sample: /sys/login/user
409 response_code:
410 description: The status of api request.
411 returned: always
412 type: int
413 sample: 0
414 response_data:
415 description: The api response.
416 type: list
417 returned: always
418 response_message:
419 description: The descriptive message of the api response.
420 type: str
421 returned: always
422 sample: OK.
423 system_information:
424 description: The information of the target system.
425 type: dict
426 returned: always
427 rc:
428 description: The status the request.
429 type: int
430 returned: always
431 sample: 0
432 version_check_warning:
433 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
434 type: list
435 returned: complex
436 '''
437 from ansible.module_utils.basic import AnsibleModule
438 from ansible.module_utils.connection import Connection
439 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
440 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
441
442
443 def main():
444 urls_list = [
445 '/pm/config/adom/{adom}/obj/firewall/address6',
446 '/pm/config/global/obj/firewall/address6'
447 ]
448 module_arg_spec = {
449 'adom': {'required': True, 'type': 'str'},
450 'revision_note': {'type': 'str'},
451 'firewall_address6': {
452 'type': 'dict', 'v_range': [['6.0.0', '']],
453 'options': {
454 'cache-ttl': {'type': 'int'},
455 'color': {'type': 'int'},
456 'comment': {'type': 'str'},
457 'dynamic_mapping': {
458 'type': 'list',
459 'options': {
460 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
461 'cache-ttl': {'type': 'int'},
462 'color': {'type': 'int'},
463 'comment': {'type': 'str'},
464 'end-ip': {'type': 'str'},
465 'fqdn': {'type': 'str'},
466 'host': {'type': 'str'},
467 'host-type': {'choices': ['any', 'specific'], 'type': 'str'},
468 'ip6': {'type': 'str'},
469 'obj-id': {'type': 'str'},
470 'sdn': {'choices': ['nsx'], 'type': 'str'},
471 'start-ip': {'type': 'str'},
472 'tags': {'type': 'raw'},
473 'template': {'type': 'str'},
474 'type': {
475 'choices': ['ipprefix', 'iprange', 'nsx', 'dynamic', 'fqdn', 'template', 'mac', 'geography', 'route-tag', 'wildcard'],
476 'type': 'str'
477 },
478 'uuid': {'type': 'str'},
479 'visibility': {'choices': ['disable', 'enable'], 'type': 'str'},
480 'subnet-segment': {
481 'v_range': [['6.2.1', '']],
482 'type': 'list',
483 'options': {
484 'name': {'v_range': [['6.2.1', '']], 'type': 'str'},
485 'type': {'v_range': [['6.2.1', '']], 'choices': ['any', 'specific'], 'type': 'str'},
486 'value': {'v_range': [['6.2.1', '']], 'type': 'str'}
487 },
488 'elements': 'dict'
489 },
490 '_image-base64': {'v_range': [['6.2.2', '']], 'type': 'str'},
491 'end-mac': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'},
492 'start-mac': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'},
493 'country': {'v_range': [['6.4.0', '']], 'type': 'str'},
494 'global-object': {'v_range': [['6.4.0', '']], 'type': 'int'},
495 'fabric-object': {'v_range': [['6.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
496 'macaddr': {'v_range': [['7.0.0', '']], 'type': 'raw'},
497 'epg-name': {'v_range': [['7.2.1', '']], 'type': 'str'},
498 'sdn-tag': {'v_range': [['7.2.1', '']], 'type': 'str'},
499 'tenant': {'v_range': [['7.2.1', '']], 'type': 'str'},
500 'route-tag': {'v_range': [['7.4.0', '']], 'type': 'int'},
501 'filter': {'v_range': [['7.4.4', '7.4.10'], ['7.6.2', '']], 'type': 'str'},
502 'sdn-addr-type': {'v_range': [['7.4.4', '7.4.10'], ['7.6.2', '']], 'choices': ['all', 'private', 'public'], 'type': 'str'},
503 'wildcard': {'v_range': [['7.6.4', '']], 'type': 'str'},
504 'passive-fqdn-learning': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
505 },
506 'elements': 'dict'
507 },
508 'end-ip': {'type': 'str'},
509 'fqdn': {'type': 'str'},
510 'host': {'type': 'str'},
511 'host-type': {'choices': ['any', 'specific'], 'type': 'str'},
512 'ip6': {'type': 'str'},
513 'list': {
514 'type': 'list',
515 'options': {
516 'ip': {'type': 'str'},
517 'net-id': {'v_range': [['6.2.1', '']], 'type': 'str'},
518 'obj-id': {'v_range': [['6.2.1', '']], 'type': 'str'}
519 },
520 'elements': 'dict'
521 },
522 'name': {'required': True, 'type': 'str'},
523 'obj-id': {'type': 'str'},
524 'sdn': {'choices': ['nsx'], 'type': 'str'},
525 'start-ip': {'type': 'str'},
526 'subnet-segment': {
527 'type': 'list',
528 'options': {'name': {'type': 'str'}, 'type': {'choices': ['any', 'specific'], 'type': 'str'}, 'value': {'type': 'str'}},
529 'elements': 'dict'
530 },
531 'tagging': {
532 'type': 'list',
533 'options': {'category': {'type': 'str'}, 'name': {'type': 'str'}, 'tags': {'type': 'raw'}},
534 'elements': 'dict'
535 },
536 'template': {'type': 'str'},
537 'type': {
538 'choices': ['ipprefix', 'iprange', 'nsx', 'dynamic', 'fqdn', 'template', 'mac', 'geography', 'route-tag', 'wildcard'],
539 'type': 'str'
540 },
541 'uuid': {'type': 'str'},
542 'visibility': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
543 'tags': {'v_range': [['6.2.0', '6.4.15'], ['7.4.8', '7.4.10'], ['7.6.4', '']], 'type': 'str'},
544 'profile-list': {
545 'v_range': [['6.2.0', '6.2.13']],
546 'type': 'list',
547 'options': {'profile-id': {'v_range': [['6.2.0', '6.2.13']], 'type': 'int'}},
548 'elements': 'dict'
549 },
550 '_image-base64': {'v_range': [['6.2.2', '']], 'type': 'str'},
551 'end-mac': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'},
552 'start-mac': {'v_range': [['6.2.5', '6.2.13'], ['6.4.1', '']], 'type': 'str'},
553 'country': {'v_range': [['6.4.0', '']], 'type': 'str'},
554 'global-object': {'v_range': [['6.4.0', '']], 'type': 'int'},
555 'fabric-object': {'v_range': [['6.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
556 'macaddr': {'v_range': [['7.0.0', '']], 'type': 'raw'},
557 'epg-name': {'v_range': [['7.2.1', '']], 'type': 'str'},
558 'sdn-tag': {'v_range': [['7.2.1', '']], 'type': 'str'},
559 'tenant': {'v_range': [['7.2.1', '']], 'type': 'str'},
560 'route-tag': {'v_range': [['7.4.0', '']], 'type': 'int'},
561 'filter': {'v_range': [['7.4.4', '7.4.10'], ['7.6.2', '']], 'type': 'str'},
562 'sdn-addr-type': {'v_range': [['7.4.4', '7.4.10'], ['7.6.2', '']], 'choices': ['all', 'private', 'public'], 'type': 'str'},
563 'wildcard': {'v_range': [['7.6.4', '']], 'type': 'str'},
564 'passive-fqdn-learning': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
565 }
566 }
567 }
568
569 module_option_spec = get_module_arg_spec('full crud')
570 module_arg_spec.update(module_option_spec)
571 check_galaxy_version(module_arg_spec)
572 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_address6'),
573 supports_check_mode=True)
574 if not module._socket_path:
575 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
576 connection = Connection(module._socket_path)
577 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
578 'name', 'data', module, connection)
579 fmgr.process_crud()
580 module.exit_json(meta=module.params)
581
582
583 if __name__ == '__main__':
584 main()