Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_vpnmgr_node.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_vpnmgr_node
15 short_description: VPN node for VPN Manager.
16 version_added: "2.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 vpnmgr_node:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 add_route:
34 aliases: ['add-route']
35 type: str
36 description: Add route.
37 choices: ['disable', 'enable']
38 assign_ip:
39 aliases: ['assign-ip']
40 type: str
41 description: Assign ip.
42 choices: ['disable', 'enable']
43 assign_ip_from:
44 aliases: ['assign-ip-from']
45 type: str
46 description: Assign ip from.
47 choices: ['range', 'usrgrp', 'dhcp', 'name']
48 authpasswd:
49 type: raw
50 description: (list) Authpasswd.
51 authusr:
52 type: str
53 description: Authusr.
54 authusrgrp:
55 type: str
56 description: Authusrgrp.
57 auto_configuration:
58 aliases: ['auto-configuration']
59 type: str
60 description: Auto configuration.
61 choices: ['disable', 'enable']
62 automatic_routing:
63 type: str
64 description: Automatic routing.
65 choices: ['disable', 'enable']
66 banner:
67 type: str
68 description: Banner.
69 default_gateway:
70 aliases: ['default-gateway']
71 type: str
72 description: Default gateway.
73 dhcp_server:
74 aliases: ['dhcp-server']
75 type: str
76 description: Dhcp server.
77 choices: ['disable', 'enable']
78 dns_mode:
79 aliases: ['dns-mode']
80 type: str
81 description: Dns mode.
82 choices: ['auto', 'manual']
83 dns_service:
84 aliases: ['dns-service']
85 type: str
86 description: Dns service.
87 choices: ['default', 'specify', 'local']
88 domain:
89 type: str
90 description: Domain.
91 extgw:
92 type: str
93 description: Extgw.
94 extgw_hubip:
95 type: str
96 description: Extgw hubip.
97 extgw_p2_per_net:
98 type: str
99 description: Extgw p2 per net.
100 choices: ['disable', 'enable']
101 extgwip:
102 type: str
103 description: Extgwip.
104 hub_iface:
105 type: raw
106 description: (list or str) Hub iface.
107 id:
108 type: int
109 description: Id.
110 required: true
111 iface:
112 type: raw
113 description: (list or str) Iface.
114 ip_range:
115 aliases: ['ip-range']
116 type: list
117 elements: dict
118 description: Ip range.
119 suboptions:
120 end_ip:
121 aliases: ['end-ip']
122 type: str
123 description: End ip.
124 id:
125 type: int
126 description: Id.
127 start_ip:
128 aliases: ['start-ip']
129 type: str
130 description: Start ip.
131 ipsec_lease_hold:
132 aliases: ['ipsec-lease-hold']
133 type: int
134 description: Ipsec lease hold.
135 ipv4_dns_server1:
136 aliases: ['ipv4-dns-server1']
137 type: str
138 description: Ipv4 dns server1.
139 ipv4_dns_server2:
140 aliases: ['ipv4-dns-server2']
141 type: str
142 description: Ipv4 dns server2.
143 ipv4_dns_server3:
144 aliases: ['ipv4-dns-server3']
145 type: str
146 description: Ipv4 dns server3.
147 ipv4_end_ip:
148 aliases: ['ipv4-end-ip']
149 type: str
150 description: Ipv4 end ip.
151 ipv4_exclude_range:
152 aliases: ['ipv4-exclude-range']
153 type: list
154 elements: dict
155 description: Ipv4 exclude range.
156 suboptions:
157 end_ip:
158 aliases: ['end-ip']
159 type: str
160 description: End ip.
161 id:
162 type: int
163 description: Id.
164 start_ip:
165 aliases: ['start-ip']
166 type: str
167 description: Start ip.
168 ipv4_netmask:
169 aliases: ['ipv4-netmask']
170 type: str
171 description: Ipv4 netmask.
172 ipv4_split_include:
173 aliases: ['ipv4-split-include']
174 type: str
175 description: Ipv4 split include.
176 ipv4_start_ip:
177 aliases: ['ipv4-start-ip']
178 type: str
179 description: Ipv4 start ip.
180 ipv4_wins_server1:
181 aliases: ['ipv4-wins-server1']
182 type: str
183 description: Ipv4 wins server1.
184 ipv4_wins_server2:
185 aliases: ['ipv4-wins-server2']
186 type: str
187 description: Ipv4 wins server2.
188 local_gw:
189 aliases: ['local-gw']
190 type: str
191 description: Local gw.
192 localid:
193 type: str
194 description: Localid.
195 mode_cfg:
196 aliases: ['mode-cfg']
197 type: str
198 description: Mode cfg.
199 choices: ['disable', 'enable']
200 mode_cfg_ip_version:
201 aliases: ['mode-cfg-ip-version']
202 type: str
203 description: Mode cfg ip version.
204 choices: ['4', '6']
205 net_device:
206 aliases: ['net-device']
207 type: str
208 description: Net device.
209 choices: ['disable', 'enable']
210 peer:
211 type: raw
212 description: (list or str) Peer.
213 peergrp:
214 type: str
215 description: Peergrp.
216 peerid:
217 type: str
218 description: Peerid.
219 peertype:
220 type: str
221 description: Peertype.
222 choices: ['any', 'one', 'dialup', 'peer', 'peergrp']
223 protected_subnet:
224 type: list
225 elements: dict
226 description: Protected subnet.
227 suboptions:
228 addr:
229 type: raw
230 description: (list or str) Addr.
231 seq:
232 type: int
233 description: Seq.
234 public_ip:
235 aliases: ['public-ip']
236 type: str
237 description: Public ip.
238 role:
239 type: str
240 description: Role.
241 choices: ['hub', 'spoke']
242 route_overlap:
243 aliases: ['route-overlap']
244 type: str
245 description: Route overlap.
246 choices: ['use-old', 'use-new', 'allow']
247 spoke_zone:
248 aliases: ['spoke-zone']
249 type: raw
250 description: (list or str) Spoke zone.
251 summary_addr:
252 type: list
253 elements: dict
254 description: Summary addr.
255 suboptions:
256 addr:
257 type: str
258 description: Addr.
259 priority:
260 type: int
261 description: Priority.
262 seq:
263 type: int
264 description: Seq.
265 tunnel_search:
266 aliases: ['tunnel-search']
267 type: str
268 description: Tunnel search.
269 choices: ['selectors', 'nexthop']
270 unity_support:
271 aliases: ['unity-support']
272 type: str
273 description: Unity support.
274 choices: ['disable', 'enable']
275 usrgrp:
276 type: str
277 description: Usrgrp.
278 vpn_interface_priority:
279 aliases: ['vpn-interface-priority']
280 type: int
281 description: Vpn interface priority.
282 vpn_zone:
283 aliases: ['vpn-zone']
284 type: raw
285 description: (list or str) Vpn zone.
286 vpntable:
287 type: raw
288 description: (list or str) Vpntable.
289 xauthtype:
290 type: str
291 description: Xauthtype.
292 choices: ['disable', 'client', 'pap', 'chap', 'auto']
293 exchange_interface_ip:
294 aliases: ['exchange-interface-ip']
295 type: str
296 description: Exchange interface ip.
297 choices: ['disable', 'enable']
298 hub_public_ip:
299 aliases: ['hub-public-ip']
300 type: str
301 description: Hub public ip.
302 ipv4_split_exclude:
303 aliases: ['ipv4-split-exclude']
304 type: str
305 description: Ipv4 split exclude.
306 scope_member:
307 aliases: ['scope member']
308 type: list
309 elements: dict
310 description: Scope member.
311 suboptions:
312 name:
313 type: str
314 description: Name.
315 vdom:
316 type: str
317 description: Vdom.
318 dhcp_ra_giaddr:
319 aliases: ['dhcp-ra-giaddr']
320 type: str
321 description: Dhcp ra giaddr.
322 encapsulation:
323 type: str
324 description: Encapsulation.
325 choices: ['tunnel-mode', 'transport-mode']
326 ipv4_name:
327 aliases: ['ipv4-name']
328 type: str
329 description: Ipv4 name.
330 l2tp:
331 type: str
332 description: L2tp.
333 choices: ['disable', 'enable']
334 auto_discovery_receiver:
335 aliases: ['auto-discovery-receiver']
336 type: str
337 description: Auto discovery receiver.
338 choices: ['disable', 'enable']
339 auto_discovery_sender:
340 aliases: ['auto-discovery-sender']
341 type: str
342 description: Auto discovery sender.
343 choices: ['disable', 'enable']
344 network_id:
345 aliases: ['network-id']
346 type: int
347 description: Network id.
348 network_overlay:
349 aliases: ['network-overlay']
350 type: str
351 description: Network overlay.
352 choices: ['enable', 'disable']
353 protocol:
354 type: int
355 description: Protocol.
356 '''
357
358 EXAMPLES = '''
359 - name: Example playbook (generated based on argument schema)
360 hosts: fortimanagers
361 connection: httpapi
362 gather_facts: false
363 tasks:
364 - name: VPN node for VPN Manager.
365 fortinet.fortimanager.fmgr_vpnmgr_node:
366 # workspace_locking_adom: <global or your adom name>
367 adom: <your own value>
368 state: present # <value in [present, absent]>
369 vpnmgr_node:
370 id: 0 # Required variable, integer
371 # add_route: <value in [disable, enable]>
372 # assign_ip: <value in [disable, enable]>
373 # assign_ip_from: <value in [range, usrgrp, dhcp, ...]>
374 # authpasswd: <list or string>
375 # authusr: <string>
376 # authusrgrp: <string>
377 # auto_configuration: <value in [disable, enable]>
378 # automatic_routing: <value in [disable, enable]>
379 # banner: <string>
380 # default_gateway: <string>
381 # dhcp_server: <value in [disable, enable]>
382 # dns_mode: <value in [auto, manual]>
383 # dns_service: <value in [default, specify, local]>
384 # domain: <string>
385 # extgw: <string>
386 # extgw_hubip: <string>
387 # extgw_p2_per_net: <value in [disable, enable]>
388 # extgwip: <string>
389 # hub_iface: <list or string>
390 # iface: <list or string>
391 # ip_range:
392 # - end_ip: <string>
393 # id: <integer>
394 # start_ip: <string>
395 # ipsec_lease_hold: <integer>
396 # ipv4_dns_server1: <string>
397 # ipv4_dns_server2: <string>
398 # ipv4_dns_server3: <string>
399 # ipv4_end_ip: <string>
400 # ipv4_exclude_range:
401 # - end_ip: <string>
402 # id: <integer>
403 # start_ip: <string>
404 # ipv4_netmask: <string>
405 # ipv4_split_include: <string>
406 # ipv4_start_ip: <string>
407 # ipv4_wins_server1: <string>
408 # ipv4_wins_server2: <string>
409 # local_gw: <string>
410 # localid: <string>
411 # mode_cfg: <value in [disable, enable]>
412 # mode_cfg_ip_version: <value in [4, 6]>
413 # net_device: <value in [disable, enable]>
414 # peer: <list or string>
415 # peergrp: <string>
416 # peerid: <string>
417 # peertype: <value in [any, one, dialup, ...]>
418 # protected_subnet:
419 # - addr: <list or string>
420 # seq: <integer>
421 # public_ip: <string>
422 # role: <value in [hub, spoke]>
423 # route_overlap: <value in [use-old, use-new, allow]>
424 # spoke_zone: <list or string>
425 # summary_addr:
426 # - addr: <string>
427 # priority: <integer>
428 # seq: <integer>
429 # tunnel_search: <value in [selectors, nexthop]>
430 # unity_support: <value in [disable, enable]>
431 # usrgrp: <string>
432 # vpn_interface_priority: <integer>
433 # vpn_zone: <list or string>
434 # vpntable: <list or string>
435 # xauthtype: <value in [disable, client, pap, ...]>
436 # exchange_interface_ip: <value in [disable, enable]>
437 # hub_public_ip: <string>
438 # ipv4_split_exclude: <string>
439 # scope_member:
440 # - name: <string>
441 # vdom: <string>
442 # dhcp_ra_giaddr: <string>
443 # encapsulation: <value in [tunnel-mode, transport-mode]>
444 # ipv4_name: <string>
445 # l2tp: <value in [disable, enable]>
446 # auto_discovery_receiver: <value in [disable, enable]>
447 # auto_discovery_sender: <value in [disable, enable]>
448 # network_id: <integer>
449 # network_overlay: <value in [enable, disable]>
450 # protocol: <integer>
451 '''
452
453 RETURN = '''
454 meta:
455 description: The result of the request.
456 type: dict
457 returned: always
458 contains:
459 request_url:
460 description: The full url requested.
461 returned: always
462 type: str
463 sample: /sys/login/user
464 response_code:
465 description: The status of api request.
466 returned: always
467 type: int
468 sample: 0
469 response_data:
470 description: The api response.
471 type: list
472 returned: always
473 response_message:
474 description: The descriptive message of the api response.
475 type: str
476 returned: always
477 sample: OK.
478 system_information:
479 description: The information of the target system.
480 type: dict
481 returned: always
482 rc:
483 description: The status the request.
484 type: int
485 returned: always
486 sample: 0
487 version_check_warning:
488 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
489 type: list
490 returned: complex
491 '''
492 from ansible.module_utils.basic import AnsibleModule
493 from ansible.module_utils.connection import Connection
494 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
495 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
496
497
498 def main():
499 urls_list = [
500 '/pm/config/adom/{adom}/obj/vpnmgr/node',
501 '/pm/config/global/obj/vpnmgr/node'
502 ]
503 module_arg_spec = {
504 'adom': {'required': True, 'type': 'str'},
505 'revision_note': {'type': 'str'},
506 'vpnmgr_node': {
507 'type': 'dict', 'v_range': [['6.0.0', '']],
508 'options': {
509 'add-route': {'choices': ['disable', 'enable'], 'type': 'str'},
510 'assign-ip': {'choices': ['disable', 'enable'], 'type': 'str'},
511 'assign-ip-from': {'choices': ['range', 'usrgrp', 'dhcp', 'name'], 'type': 'str'},
512 'authpasswd': {'no_log': True, 'type': 'raw'},
513 'authusr': {'type': 'str'},
514 'authusrgrp': {'type': 'str'},
515 'auto-configuration': {'choices': ['disable', 'enable'], 'type': 'str'},
516 'automatic_routing': {'choices': ['disable', 'enable'], 'type': 'str'},
517 'banner': {'type': 'str'},
518 'default-gateway': {'type': 'str'},
519 'dhcp-server': {'choices': ['disable', 'enable'], 'type': 'str'},
520 'dns-mode': {'choices': ['auto', 'manual'], 'type': 'str'},
521 'dns-service': {'choices': ['default', 'specify', 'local'], 'type': 'str'},
522 'domain': {'type': 'str'},
523 'extgw': {'type': 'str'},
524 'extgw_hubip': {'type': 'str'},
525 'extgw_p2_per_net': {'choices': ['disable', 'enable'], 'type': 'str'},
526 'extgwip': {'type': 'str'},
527 'hub_iface': {'type': 'raw'},
528 'id': {'required': True, 'type': 'int'},
529 'iface': {'type': 'raw'},
530 'ip-range': {
531 'type': 'list',
532 'options': {'end-ip': {'type': 'str'}, 'id': {'type': 'int'}, 'start-ip': {'type': 'str'}},
533 'elements': 'dict'
534 },
535 'ipsec-lease-hold': {'type': 'int'},
536 'ipv4-dns-server1': {'type': 'str'},
537 'ipv4-dns-server2': {'type': 'str'},
538 'ipv4-dns-server3': {'type': 'str'},
539 'ipv4-end-ip': {'type': 'str'},
540 'ipv4-exclude-range': {
541 'type': 'list',
542 'options': {'end-ip': {'type': 'str'}, 'id': {'type': 'int'}, 'start-ip': {'type': 'str'}},
543 'elements': 'dict'
544 },
545 'ipv4-netmask': {'type': 'str'},
546 'ipv4-split-include': {'type': 'str'},
547 'ipv4-start-ip': {'type': 'str'},
548 'ipv4-wins-server1': {'type': 'str'},
549 'ipv4-wins-server2': {'type': 'str'},
550 'local-gw': {'type': 'str'},
551 'localid': {'type': 'str'},
552 'mode-cfg': {'choices': ['disable', 'enable'], 'type': 'str'},
553 'mode-cfg-ip-version': {'choices': ['4', '6'], 'type': 'str'},
554 'net-device': {'choices': ['disable', 'enable'], 'type': 'str'},
555 'peer': {'type': 'raw'},
556 'peergrp': {'type': 'str'},
557 'peerid': {'type': 'str'},
558 'peertype': {'choices': ['any', 'one', 'dialup', 'peer', 'peergrp'], 'type': 'str'},
559 'protected_subnet': {'type': 'list', 'options': {'addr': {'type': 'raw'}, 'seq': {'type': 'int'}}, 'elements': 'dict'},
560 'public-ip': {'type': 'str'},
561 'role': {'choices': ['hub', 'spoke'], 'type': 'str'},
562 'route-overlap': {'choices': ['use-old', 'use-new', 'allow'], 'type': 'str'},
563 'spoke-zone': {'type': 'raw'},
564 'summary_addr': {
565 'type': 'list',
566 'options': {'addr': {'type': 'str'}, 'priority': {'type': 'int'}, 'seq': {'type': 'int'}},
567 'elements': 'dict'
568 },
569 'tunnel-search': {'choices': ['selectors', 'nexthop'], 'type': 'str'},
570 'unity-support': {'choices': ['disable', 'enable'], 'type': 'str'},
571 'usrgrp': {'type': 'str'},
572 'vpn-interface-priority': {'type': 'int'},
573 'vpn-zone': {'type': 'raw'},
574 'vpntable': {'type': 'raw'},
575 'xauthtype': {'choices': ['disable', 'client', 'pap', 'chap', 'auto'], 'type': 'str'},
576 'exchange-interface-ip': {'v_range': [['6.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
577 'hub-public-ip': {'v_range': [['6.2.2', '']], 'type': 'str'},
578 'ipv4-split-exclude': {'v_range': [['6.4.6', '']], 'type': 'str'},
579 'scope member': {
580 'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']],
581 'type': 'list',
582 'options': {
583 'name': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'str'},
584 'vdom': {'v_range': [['6.4.7', '6.4.15'], ['7.0.1', '']], 'type': 'str'}
585 },
586 'elements': 'dict'
587 },
588 'dhcp-ra-giaddr': {'v_range': [['6.4.8', '6.4.15'], ['7.0.4', '']], 'type': 'str'},
589 'encapsulation': {'v_range': [['7.0.2', '']], 'choices': ['tunnel-mode', 'transport-mode'], 'type': 'str'},
590 'ipv4-name': {'v_range': [['6.4.8', '6.4.15'], ['7.0.4', '']], 'type': 'str'},
591 'l2tp': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
592 'auto-discovery-receiver': {'v_range': [['7.0.8', '7.0.16'], ['7.2.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
593 'auto-discovery-sender': {'v_range': [['7.0.8', '7.0.16'], ['7.2.3', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
594 'network-id': {'v_range': [['7.0.8', '7.0.16'], ['7.2.3', '']], 'type': 'int'},
595 'network-overlay': {'v_range': [['7.0.8', '7.0.16'], ['7.2.3', '']], 'choices': ['enable', 'disable'], 'type': 'str'},
596 'protocol': {'v_range': [['7.2.5', '7.2.12'], ['7.4.1', '']], 'type': 'int'}
597 }
598 }
599 }
600
601 module_option_spec = get_module_arg_spec('full crud')
602 module_arg_spec.update(module_option_spec)
603 check_galaxy_version(module_arg_spec)
604 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'vpnmgr_node'),
605 supports_check_mode=True)
606 if not module._socket_path:
607 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
608 connection = Connection(module._socket_path)
609 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
610 'id', 'data', module, connection)
611 fmgr.process_crud()
612 module.exit_json(meta=module.params)
613
614
615 if __name__ == '__main__':
616 main()