Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_ippool.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_ippool
15 short_description: Configure IPv4 IP pools.
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_ippool:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 arp_intf:
34 aliases: ['arp-intf']
35 type: str
36 description: Select an interface from available options that will reply to ARP requests.
37 arp_reply:
38 aliases: ['arp-reply']
39 type: str
40 description: Enable/disable replying to ARP requests when an IP Pool is added to a policy
41 choices: ['disable', 'enable']
42 associated_interface:
43 aliases: ['associated-interface']
44 type: str
45 description: Associated interface name.
46 block_size:
47 aliases: ['block-size']
48 type: int
49 description: Number of addresses in a block
50 comments:
51 type: str
52 description: Comment.
53 dynamic_mapping:
54 type: list
55 elements: dict
56 description: Dynamic mapping.
57 suboptions:
58 _scope:
59 type: list
60 elements: dict
61 description: Scope.
62 suboptions:
63 name:
64 type: str
65 description: Name.
66 vdom:
67 type: str
68 description: Vdom.
69 arp_intf:
70 aliases: ['arp-intf']
71 type: str
72 description: Arp intf.
73 arp_reply:
74 aliases: ['arp-reply']
75 type: str
76 description: Arp reply.
77 choices: ['disable', 'enable']
78 associated_interface:
79 aliases: ['associated-interface']
80 type: str
81 description: Associated interface.
82 block_size:
83 aliases: ['block-size']
84 type: int
85 description: Block size.
86 comments:
87 type: str
88 description: Comments.
89 endip:
90 type: str
91 description: Endip.
92 num_blocks_per_user:
93 aliases: ['num-blocks-per-user']
94 type: int
95 description: Num blocks per user.
96 pba_timeout:
97 aliases: ['pba-timeout']
98 type: int
99 description: Pba timeout.
100 permit_any_host:
101 aliases: ['permit-any-host']
102 type: str
103 description: Permit any host.
104 choices: ['disable', 'enable']
105 source_endip:
106 aliases: ['source-endip']
107 type: str
108 description: Source endip.
109 source_startip:
110 aliases: ['source-startip']
111 type: str
112 description: Source startip.
113 startip:
114 type: str
115 description: Startip.
116 type:
117 type: str
118 description: Type.
119 choices: ['overload', 'one-to-one', 'fixed-port-range',
120 'port-block-allocation', 'cgn-resource-allocation']
121 cgn_block_size:
122 aliases: ['cgn-block-size']
123 type: int
124 description: Cgn block size.
125 cgn_client_endip:
126 aliases: ['cgn-client-endip']
127 type: str
128 description: Cgn client endip.
129 cgn_client_startip:
130 aliases: ['cgn-client-startip']
131 type: str
132 description: Cgn client startip.
133 cgn_fixedalloc:
134 aliases: ['cgn-fixedalloc']
135 type: str
136 description: Cgn fixedalloc.
137 choices: ['disable', 'enable']
138 cgn_overload:
139 aliases: ['cgn-overload']
140 type: str
141 description: Cgn overload.
142 choices: ['disable', 'enable']
143 cgn_port_end:
144 aliases: ['cgn-port-end']
145 type: int
146 description: Cgn port end.
147 cgn_port_start:
148 aliases: ['cgn-port-start']
149 type: int
150 description: Cgn port start.
151 cgn_spa:
152 aliases: ['cgn-spa']
153 type: str
154 description: Cgn spa.
155 choices: ['disable', 'enable']
156 utilization_alarm_clear:
157 aliases: ['utilization-alarm-clear']
158 type: int
159 description: Utilization alarm clear.
160 utilization_alarm_raise:
161 aliases: ['utilization-alarm-raise']
162 type: int
163 description: Utilization alarm raise.
164 endport:
165 type: int
166 description: Final port number
167 port_per_user:
168 aliases: ['port-per-user']
169 type: int
170 description: Number of port for each user
171 startport:
172 type: int
173 description: First port number
174 add_nat64_route:
175 aliases: ['add-nat64-route']
176 type: str
177 description: Enable/disable adding NAT64 route.
178 choices: ['disable', 'enable']
179 cgn_client_ipv6shift:
180 aliases: ['cgn-client-ipv6shift']
181 type: int
182 description: IPv6 shift for fixed-allocation.
183 nat64:
184 type: str
185 description: Enable/disable NAT64.
186 choices: ['disable', 'enable']
187 subnet_broadcast_in_ippool:
188 aliases: ['subnet-broadcast-in-ippool']
189 type: str
190 description: Enable/disable inclusion of the subnetwork address and broadcast IP address in the NAT64 IP pool.
191 choices: ['disable', 'enable']
192 exclude_ip:
193 aliases: ['exclude-ip']
194 type: raw
195 description: (list) Exclude IPs x.
196 pba_interim_log:
197 aliases: ['pba-interim-log']
198 type: int
199 description: Port block allocation interim logging interval
200 client_prefix_length:
201 aliases: ['client-prefix-length']
202 type: int
203 description: Subnet length of a single deterministic NAT64 client
204 icmp_session_quota:
205 aliases: ['icmp-session-quota']
206 type: int
207 description: Maximum number of concurrent ICMP sessions allowed per client
208 privileged_port_use_pba:
209 aliases: ['privileged-port-use-pba']
210 type: str
211 description: Enable/disable selection of the external port from the port block allocation for NATing privileged ports
212 choices: ['disable', 'enable']
213 source_prefix6:
214 aliases: ['source-prefix6']
215 type: str
216 description: Source IPv6 network to be translated
217 tcp_session_quota:
218 aliases: ['tcp-session-quota']
219 type: int
220 description: Maximum number of concurrent TCP sessions allowed per client
221 udp_session_quota:
222 aliases: ['udp-session-quota']
223 type: int
224 description: Maximum number of concurrent UDP sessions allowed per client
225 endip:
226 type: str
227 description: Final IPv4 address
228 name:
229 type: str
230 description: IP pool name.
231 required: true
232 num_blocks_per_user:
233 aliases: ['num-blocks-per-user']
234 type: int
235 description: Number of addresses blocks that can be used by a user
236 pba_timeout:
237 aliases: ['pba-timeout']
238 type: int
239 description: Port block allocation timeout
240 permit_any_host:
241 aliases: ['permit-any-host']
242 type: str
243 description: Enable/disable full cone NAT.
244 choices: ['disable', 'enable']
245 source_endip:
246 aliases: ['source-endip']
247 type: str
248 description: Final IPv4 address
249 source_startip:
250 aliases: ['source-startip']
251 type: str
252 description: First IPv4 address
253 startip:
254 type: str
255 description: First IPv4 address
256 type:
257 type: str
258 description: IP pool type
259 choices: ['overload', 'one-to-one', 'fixed-port-range', 'port-block-allocation',
260 'cgn-resource-allocation']
261 utilization_alarm_clear:
262 aliases: ['utilization-alarm-clear']
263 type: int
264 description: Pool utilization alarm clear threshold
265 cgn_fixedalloc:
266 aliases: ['cgn-fixedalloc']
267 type: str
268 description: Enable/disable fixed-allocation mode.
269 choices: ['disable', 'enable']
270 cgn_client_startip:
271 aliases: ['cgn-client-startip']
272 type: str
273 description: First client IPv4 address
274 cgn_client_endip:
275 aliases: ['cgn-client-endip']
276 type: str
277 description: Final client IPv4 address
278 cgn_overload:
279 aliases: ['cgn-overload']
280 type: str
281 description: Enable/disable overload mode.
282 choices: ['disable', 'enable']
283 cgn_block_size:
284 aliases: ['cgn-block-size']
285 type: int
286 description: Number of ports in a block
287 utilization_alarm_raise:
288 aliases: ['utilization-alarm-raise']
289 type: int
290 description: Pool utilization alarm raise threshold
291 cgn_port_start:
292 aliases: ['cgn-port-start']
293 type: int
294 description: Starting public port can be allocated.
295 cgn_spa:
296 aliases: ['cgn-spa']
297 type: str
298 description: Enable/disable single port allocation mode.
299 choices: ['disable', 'enable']
300 cgn_port_end:
301 aliases: ['cgn-port-end']
302 type: int
303 description: Ending public port can be allocated.
304 endport:
305 type: int
306 description: Final port number
307 port_per_user:
308 aliases: ['port-per-user']
309 type: int
310 description: Number of port for each user
311 startport:
312 type: int
313 description: First port number
314 add_nat64_route:
315 aliases: ['add-nat64-route']
316 type: str
317 description: Enable/disable adding NAT64 route.
318 choices: ['disable', 'enable']
319 nat64:
320 type: str
321 description: Enable/disable NAT64.
322 choices: ['disable', 'enable']
323 cgn_client_ipv6shift:
324 aliases: ['cgn-client-ipv6shift']
325 type: int
326 description: IPv6 shift for fixed-allocation.
327 subnet_broadcast_in_ippool:
328 aliases: ['subnet-broadcast-in-ippool']
329 type: str
330 description: Enable/disable inclusion of the subnetwork address and broadcast IP address in the NAT64 IP pool.
331 choices: ['disable', 'enable']
332 exclude_ip:
333 aliases: ['exclude-ip']
334 type: raw
335 description: (list) Exclude IPs x.
336 pba_interim_log:
337 aliases: ['pba-interim-log']
338 type: int
339 description: Port block allocation interim logging interval
340 client_prefix_length:
341 aliases: ['client-prefix-length']
342 type: int
343 description: Subnet length of a single deterministic NAT64 client
344 icmp_session_quota:
345 aliases: ['icmp-session-quota']
346 type: int
347 description: Maximum number of concurrent ICMP sessions allowed per client
348 privileged_port_use_pba:
349 aliases: ['privileged-port-use-pba']
350 type: str
351 description: Enable/disable selection of the external port from the port block allocation for NATing privileged ports
352 choices: ['disable', 'enable']
353 source_prefix6:
354 aliases: ['source-prefix6']
355 type: str
356 description: Source IPv6 network to be translated
357 tcp_session_quota:
358 aliases: ['tcp-session-quota']
359 type: int
360 description: Maximum number of concurrent TCP sessions allowed per client
361 udp_session_quota:
362 aliases: ['udp-session-quota']
363 type: int
364 description: Maximum number of concurrent UDP sessions allowed per client
365 '''
366
367 EXAMPLES = '''
368 - name: Example playbook
369 hosts: fortimanagers
370 gather_facts: false
371 connection: httpapi
372 vars:
373 ansible_httpapi_use_ssl: true
374 ansible_httpapi_validate_certs: false
375 ansible_httpapi_port: 443
376 tasks:
377 - name: Configure IPv4 IP pools.
378 fortinet.fortimanager.fmgr_firewall_ippool:
379 bypass_validation: false
380 adom: ansible
381 state: present
382 firewall_ippool:
383 comments: "ansible-comment"
384 endip: "222.222.222.254"
385 name: "ansible-test"
386 startip: "222.222.222.0"
387 type: overload # <value in [overload, one-to-one, fixed-port-range, ...]>
388
389 - name: Gathering fortimanager facts
390 hosts: fortimanagers
391 gather_facts: false
392 connection: httpapi
393 vars:
394 ansible_httpapi_use_ssl: true
395 ansible_httpapi_validate_certs: false
396 ansible_httpapi_port: 443
397 tasks:
398 - name: Retrieve all the IPv4 IP pools
399 fortinet.fortimanager.fmgr_fact:
400 facts:
401 selector: "firewall_ippool"
402 params:
403 adom: "ansible"
404 ippool: "your_value"
405 '''
406
407 RETURN = '''
408 meta:
409 description: The result of the request.
410 type: dict
411 returned: always
412 contains:
413 request_url:
414 description: The full url requested.
415 returned: always
416 type: str
417 sample: /sys/login/user
418 response_code:
419 description: The status of api request.
420 returned: always
421 type: int
422 sample: 0
423 response_data:
424 description: The api response.
425 type: list
426 returned: always
427 response_message:
428 description: The descriptive message of the api response.
429 type: str
430 returned: always
431 sample: OK.
432 system_information:
433 description: The information of the target system.
434 type: dict
435 returned: always
436 rc:
437 description: The status the request.
438 type: int
439 returned: always
440 sample: 0
441 version_check_warning:
442 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
443 type: list
444 returned: complex
445 '''
446 from ansible.module_utils.basic import AnsibleModule
447 from ansible.module_utils.connection import Connection
448 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
449 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
450
451
452 def main():
453 urls_list = [
454 '/pm/config/adom/{adom}/obj/firewall/ippool',
455 '/pm/config/global/obj/firewall/ippool'
456 ]
457 module_arg_spec = {
458 'adom': {'required': True, 'type': 'str'},
459 'revision_note': {'type': 'str'},
460 'firewall_ippool': {
461 'type': 'dict', 'v_range': [['6.0.0', '']],
462 'options': {
463 'arp-intf': {'type': 'str'},
464 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
465 'associated-interface': {'type': 'str'},
466 'block-size': {'type': 'int'},
467 'comments': {'type': 'str'},
468 'dynamic_mapping': {
469 'type': 'list',
470 'options': {
471 '_scope': {'type': 'list', 'options': {'name': {'type': 'str'}, 'vdom': {'type': 'str'}}, 'elements': 'dict'},
472 'arp-intf': {'type': 'str'},
473 'arp-reply': {'choices': ['disable', 'enable'], 'type': 'str'},
474 'associated-interface': {'type': 'str'},
475 'block-size': {'type': 'int'},
476 'comments': {'type': 'str'},
477 'endip': {'type': 'str'},
478 'num-blocks-per-user': {'type': 'int'},
479 'pba-timeout': {'type': 'int'},
480 'permit-any-host': {'choices': ['disable', 'enable'], 'type': 'str'},
481 'source-endip': {'type': 'str'},
482 'source-startip': {'type': 'str'},
483 'startip': {'type': 'str'},
484 'type': {
485 'choices': ['overload', 'one-to-one', 'fixed-port-range', 'port-block-allocation', 'cgn-resource-allocation'],
486 'type': 'str'
487 },
488 'cgn-block-size': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
489 'cgn-client-endip': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
490 'cgn-client-startip': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
491 'cgn-fixedalloc': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
492 'cgn-overload': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
493 'cgn-port-end': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
494 'cgn-port-start': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
495 'cgn-spa': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
496 'utilization-alarm-clear': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
497 'utilization-alarm-raise': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
498 'endport': {'v_range': [['7.0.0', '']], 'type': 'int'},
499 'port-per-user': {'v_range': [['7.0.0', '']], 'type': 'int'},
500 'startport': {'v_range': [['7.0.0', '']], 'type': 'int'},
501 'add-nat64-route': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
502 'cgn-client-ipv6shift': {'v_range': [['6.2.9', '6.2.13'], ['6.4.7', '6.4.15'], ['7.0.2', '']], 'type': 'int'},
503 'nat64': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
504 'subnet-broadcast-in-ippool': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
505 'exclude-ip': {'v_range': [['7.2.2', '']], 'type': 'raw'},
506 'pba-interim-log': {'v_range': [['7.4.3', '']], 'type': 'int'},
507 'client-prefix-length': {'v_range': [['7.6.0', '']], 'type': 'int'},
508 'icmp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'},
509 'privileged-port-use-pba': {'v_range': [['7.6.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
510 'source-prefix6': {'v_range': [['7.6.0', '']], 'type': 'str'},
511 'tcp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'},
512 'udp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'}
513 },
514 'elements': 'dict'
515 },
516 'endip': {'type': 'str'},
517 'name': {'required': True, 'type': 'str'},
518 'num-blocks-per-user': {'type': 'int'},
519 'pba-timeout': {'type': 'int'},
520 'permit-any-host': {'choices': ['disable', 'enable'], 'type': 'str'},
521 'source-endip': {'type': 'str'},
522 'source-startip': {'type': 'str'},
523 'startip': {'type': 'str'},
524 'type': {'choices': ['overload', 'one-to-one', 'fixed-port-range', 'port-block-allocation', 'cgn-resource-allocation'], 'type': 'str'},
525 'utilization-alarm-clear': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
526 'cgn-fixedalloc': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
527 'cgn-client-startip': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
528 'cgn-client-endip': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'str'},
529 'cgn-overload': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
530 'cgn-block-size': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
531 'utilization-alarm-raise': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
532 'cgn-port-start': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
533 'cgn-spa': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
534 'cgn-port-end': {'v_range': [['6.2.6', '6.2.13'], ['6.4.2', '']], 'type': 'int'},
535 'endport': {'v_range': [['7.0.0', '']], 'type': 'int'},
536 'port-per-user': {'v_range': [['7.0.0', '']], 'type': 'int'},
537 'startport': {'v_range': [['7.0.0', '']], 'type': 'int'},
538 'add-nat64-route': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
539 'nat64': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
540 'cgn-client-ipv6shift': {'v_range': [['6.2.9', '6.2.13'], ['6.4.7', '6.4.15'], ['7.0.2', '']], 'type': 'int'},
541 'subnet-broadcast-in-ippool': {'v_range': [['7.0.5', '7.0.16'], ['7.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
542 'exclude-ip': {'v_range': [['7.2.2', '']], 'type': 'raw'},
543 'pba-interim-log': {'v_range': [['7.4.3', '']], 'type': 'int'},
544 'client-prefix-length': {'v_range': [['7.6.0', '']], 'type': 'int'},
545 'icmp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'},
546 'privileged-port-use-pba': {'v_range': [['7.6.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
547 'source-prefix6': {'v_range': [['7.6.0', '']], 'type': 'str'},
548 'tcp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'},
549 'udp-session-quota': {'v_range': [['7.6.0', '']], 'type': 'int'}
550 }
551 }
552 }
553
554 module_option_spec = get_module_arg_spec('full crud')
555 module_arg_spec.update(module_option_spec)
556 check_galaxy_version(module_arg_spec)
557 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_ippool'),
558 supports_check_mode=True)
559 if not module._socket_path:
560 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
561 connection = Connection(module._socket_path)
562 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
563 'name', 'data', module, connection)
564 fmgr.process_crud()
565 module.exit_json(meta=module.params)
566
567
568 if __name__ == '__main__':
569 main()