Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_router_routemap.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_router_routemap
15 short_description: Configure route maps.
16 version_added: "2.1.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 router_routemap:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comments:
34 type: str
35 description: Optional comments.
36 name:
37 type: str
38 description: Name.
39 required: true
40 rule:
41 type: list
42 elements: dict
43 description: Rule.
44 suboptions:
45 action:
46 type: str
47 description: Action.
48 choices: ['permit', 'deny']
49 id:
50 type: int
51 description: Rule ID.
52 match_as_path:
53 aliases: ['match-as-path']
54 type: str
55 description: Match BGP AS path list.
56 match_community:
57 aliases: ['match-community']
58 type: str
59 description: Match BGP community list.
60 match_community_exact:
61 aliases: ['match-community-exact']
62 type: str
63 description: Enable/disable exact matching of communities.
64 choices: ['disable', 'enable']
65 match_flags:
66 aliases: ['match-flags']
67 type: int
68 description: Match flags.
69 match_interface:
70 aliases: ['match-interface']
71 type: str
72 description: Match interface configuration.
73 match_ip_address:
74 aliases: ['match-ip-address']
75 type: str
76 description: Match IP address permitted by access-list or prefix-list.
77 match_ip_nexthop:
78 aliases: ['match-ip-nexthop']
79 type: str
80 description: Match next hop IP address passed by access-list or prefix-list.
81 match_ip6_address:
82 aliases: ['match-ip6-address']
83 type: str
84 description: Match IPv6 address permitted by access-list6 or prefix-list6.
85 match_ip6_nexthop:
86 aliases: ['match-ip6-nexthop']
87 type: str
88 description: Match next hop IPv6 address passed by access-list6 or prefix-list6.
89 match_metric:
90 aliases: ['match-metric']
91 type: str
92 description: Match metric for redistribute routes.
93 match_origin:
94 aliases: ['match-origin']
95 type: str
96 description: Match BGP origin code.
97 choices: ['none', 'egp', 'igp', 'incomplete']
98 match_route_type:
99 aliases: ['match-route-type']
100 type: str
101 description: Match route type.
102 choices: ['1', '2', 'none', 'external-type1', 'external-type2']
103 match_tag:
104 aliases: ['match-tag']
105 type: str
106 description: Match tag.
107 match_vrf:
108 aliases: ['match-vrf']
109 type: int
110 description: Match VRF ID.
111 set_aggregator_as:
112 aliases: ['set-aggregator-as']
113 type: int
114 description: BGP aggregator AS.
115 set_aggregator_ip:
116 aliases: ['set-aggregator-ip']
117 type: str
118 description: BGP aggregator IP.
119 set_aspath:
120 aliases: ['set-aspath']
121 type: raw
122 description: (list) Prepend BGP AS path attribute.
123 set_aspath_action:
124 aliases: ['set-aspath-action']
125 type: str
126 description: Specify preferred action of set-aspath.
127 choices: ['prepend', 'replace']
128 set_atomic_aggregate:
129 aliases: ['set-atomic-aggregate']
130 type: str
131 description: Enable/disable BGP atomic aggregate attribute.
132 choices: ['disable', 'enable']
133 set_community:
134 aliases: ['set-community']
135 type: raw
136 description: (list) BGP community attribute.
137 set_community_additive:
138 aliases: ['set-community-additive']
139 type: str
140 description: Enable/disable adding set-community to existing community.
141 choices: ['disable', 'enable']
142 set_community_delete:
143 aliases: ['set-community-delete']
144 type: str
145 description: Delete communities matching community list.
146 set_dampening_max_suppress:
147 aliases: ['set-dampening-max-suppress']
148 type: int
149 description: Maximum duration to suppress a route
150 set_dampening_reachability_half_life:
151 aliases: ['set-dampening-reachability-half-life']
152 type: int
153 description: Reachability half-life time for the penalty
154 set_dampening_reuse:
155 aliases: ['set-dampening-reuse']
156 type: int
157 description: Value to start reusing a route
158 set_dampening_suppress:
159 aliases: ['set-dampening-suppress']
160 type: int
161 description: Value to start suppressing a route
162 set_dampening_unreachability_half_life:
163 aliases: ['set-dampening-unreachability-half-life']
164 type: int
165 description: Unreachability Half-life time for the penalty
166 set_extcommunity_rt:
167 aliases: ['set-extcommunity-rt']
168 type: raw
169 description: (list) Route Target extended community.
170 set_extcommunity_soo:
171 aliases: ['set-extcommunity-soo']
172 type: raw
173 description: (list) Site-of-Origin extended community.
174 set_flags:
175 aliases: ['set-flags']
176 type: int
177 description: Set flags.
178 set_ip_nexthop:
179 aliases: ['set-ip-nexthop']
180 type: str
181 description: IP address of next hop.
182 set_ip6_nexthop:
183 aliases: ['set-ip6-nexthop']
184 type: str
185 description: IPv6 global address of next hop.
186 set_ip6_nexthop_local:
187 aliases: ['set-ip6-nexthop-local']
188 type: str
189 description: IPv6 local address of next hop.
190 set_local_preference:
191 aliases: ['set-local-preference']
192 type: str
193 description: BGP local preference path attribute.
194 set_metric:
195 aliases: ['set-metric']
196 type: str
197 description: Metric value.
198 set_metric_type:
199 aliases: ['set-metric-type']
200 type: str
201 description: Metric type.
202 choices: ['1', '2', 'none', 'external-type1', 'external-type2']
203 set_origin:
204 aliases: ['set-origin']
205 type: str
206 description: BGP origin code.
207 choices: ['none', 'egp', 'igp', 'incomplete']
208 set_originator_id:
209 aliases: ['set-originator-id']
210 type: str
211 description: BGP originator ID attribute.
212 set_priority:
213 aliases: ['set-priority']
214 type: int
215 description: Priority for routing table.
216 set_route_tag:
217 aliases: ['set-route-tag']
218 type: str
219 description: Route tag for routing table.
220 set_tag:
221 aliases: ['set-tag']
222 type: str
223 description: Tag value.
224 set_weight:
225 aliases: ['set-weight']
226 type: str
227 description: BGP weight for routing table.
228 match_extcommunity:
229 aliases: ['match-extcommunity']
230 type: str
231 description: Match BGP extended community list.
232 match_extcommunity_exact:
233 aliases: ['match-extcommunity-exact']
234 type: str
235 description: Enable/disable exact matching of extended communities.
236 choices: ['disable', 'enable']
237 set_ip_prefsrc:
238 aliases: ['set-ip-prefsrc']
239 type: str
240 description: IP address of preferred source.
241 set_vpnv4_nexthop:
242 aliases: ['set-vpnv4-nexthop']
243 type: str
244 description: IP address of VPNv4 next-hop.
245 set_vpnv6_nexthop:
246 aliases: ['set-vpnv6-nexthop']
247 type: str
248 description: IPv6 global address of VPNv6 next-hop.
249 set_vpnv6_nexthop_local:
250 aliases: ['set-vpnv6-nexthop-local']
251 type: str
252 description: IPv6 link-local address of VPNv6 next-hop.
253 match_suppress:
254 aliases: ['match-suppress']
255 type: str
256 description: Enable/disable matching of suppressed original neighbor.
257 choices: ['disable', 'enable']
258 '''
259
260 EXAMPLES = '''
261 - name: Example playbook (generated based on argument schema)
262 hosts: fortimanagers
263 connection: httpapi
264 gather_facts: false
265 tasks:
266 - name: Configure route maps.
267 fortinet.fortimanager.fmgr_router_routemap:
268 # workspace_locking_adom: <global or your adom name>
269 adom: <your own value>
270 state: present # <value in [present, absent]>
271 router_routemap:
272 name: "your value" # Required variable, string
273 # comments: <string>
274 # rule:
275 # - action: <value in [permit, deny]>
276 # id: <integer>
277 # match_as_path: <string>
278 # match_community: <string>
279 # match_community_exact: <value in [disable, enable]>
280 # match_flags: <integer>
281 # match_interface: <string>
282 # match_ip_address: <string>
283 # match_ip_nexthop: <string>
284 # match_ip6_address: <string>
285 # match_ip6_nexthop: <string>
286 # match_metric: <string>
287 # match_origin: <value in [none, egp, igp, ...]>
288 # match_route_type: <value in [1, 2, none, ...]>
289 # match_tag: <string>
290 # match_vrf: <integer>
291 # set_aggregator_as: <integer>
292 # set_aggregator_ip: <string>
293 # set_aspath: <list or string>
294 # set_aspath_action: <value in [prepend, replace]>
295 # set_atomic_aggregate: <value in [disable, enable]>
296 # set_community: <list or string>
297 # set_community_additive: <value in [disable, enable]>
298 # set_community_delete: <string>
299 # set_dampening_max_suppress: <integer>
300 # set_dampening_reachability_half_life: <integer>
301 # set_dampening_reuse: <integer>
302 # set_dampening_suppress: <integer>
303 # set_dampening_unreachability_half_life: <integer>
304 # set_extcommunity_rt: <list or string>
305 # set_extcommunity_soo: <list or string>
306 # set_flags: <integer>
307 # set_ip_nexthop: <string>
308 # set_ip6_nexthop: <string>
309 # set_ip6_nexthop_local: <string>
310 # set_local_preference: <string>
311 # set_metric: <string>
312 # set_metric_type: <value in [1, 2, none, ...]>
313 # set_origin: <value in [none, egp, igp, ...]>
314 # set_originator_id: <string>
315 # set_priority: <integer>
316 # set_route_tag: <string>
317 # set_tag: <string>
318 # set_weight: <string>
319 # match_extcommunity: <string>
320 # match_extcommunity_exact: <value in [disable, enable]>
321 # set_ip_prefsrc: <string>
322 # set_vpnv4_nexthop: <string>
323 # set_vpnv6_nexthop: <string>
324 # set_vpnv6_nexthop_local: <string>
325 # match_suppress: <value in [disable, enable]>
326 '''
327
328 RETURN = '''
329 meta:
330 description: The result of the request.
331 type: dict
332 returned: always
333 contains:
334 request_url:
335 description: The full url requested.
336 returned: always
337 type: str
338 sample: /sys/login/user
339 response_code:
340 description: The status of api request.
341 returned: always
342 type: int
343 sample: 0
344 response_data:
345 description: The api response.
346 type: list
347 returned: always
348 response_message:
349 description: The descriptive message of the api response.
350 type: str
351 returned: always
352 sample: OK.
353 system_information:
354 description: The information of the target system.
355 type: dict
356 returned: always
357 rc:
358 description: The status the request.
359 type: int
360 returned: always
361 sample: 0
362 version_check_warning:
363 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
364 type: list
365 returned: complex
366 '''
367 from ansible.module_utils.basic import AnsibleModule
368 from ansible.module_utils.connection import Connection
369 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
370 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
371
372
373 def main():
374 urls_list = [
375 '/pm/config/adom/{adom}/obj/router/route-map',
376 '/pm/config/global/obj/router/route-map'
377 ]
378 module_arg_spec = {
379 'adom': {'required': True, 'type': 'str'},
380 'revision_note': {'type': 'str'},
381 'router_routemap': {
382 'type': 'dict', 'v_range': [['7.0.2', '']],
383 'options': {
384 'comments': {'v_range': [['7.0.2', '']], 'type': 'str'},
385 'name': {'v_range': [['7.0.2', '']], 'required': True, 'type': 'str'},
386 'rule': {
387 'v_range': [['7.0.2', '']],
388 'type': 'list',
389 'options': {
390 'action': {'v_range': [['7.0.2', '']], 'choices': ['permit', 'deny'], 'type': 'str'},
391 'id': {'v_range': [['7.0.2', '']], 'type': 'int'},
392 'match-as-path': {'v_range': [['7.0.2', '']], 'type': 'str'},
393 'match-community': {'v_range': [['7.0.2', '']], 'type': 'str'},
394 'match-community-exact': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
395 'match-flags': {'v_range': [['7.0.2', '']], 'type': 'int'},
396 'match-interface': {'v_range': [['7.0.2', '']], 'type': 'str'},
397 'match-ip-address': {'v_range': [['7.0.2', '']], 'type': 'str'},
398 'match-ip-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
399 'match-ip6-address': {'v_range': [['7.0.2', '']], 'type': 'str'},
400 'match-ip6-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
401 'match-metric': {'v_range': [['7.0.2', '']], 'type': 'str'},
402 'match-origin': {'v_range': [['7.0.2', '']], 'choices': ['none', 'egp', 'igp', 'incomplete'], 'type': 'str'},
403 'match-route-type': {'v_range': [['7.0.2', '']], 'choices': ['1', '2', 'none', 'external-type1', 'external-type2'], 'type': 'str'},
404 'match-tag': {'v_range': [['7.0.2', '']], 'type': 'str'},
405 'match-vrf': {'v_range': [['7.0.2', '']], 'type': 'int'},
406 'set-aggregator-as': {'v_range': [['7.0.2', '']], 'type': 'int'},
407 'set-aggregator-ip': {'v_range': [['7.0.2', '']], 'type': 'str'},
408 'set-aspath': {'v_range': [['7.0.2', '']], 'type': 'raw'},
409 'set-aspath-action': {'v_range': [['7.0.2', '']], 'choices': ['prepend', 'replace'], 'type': 'str'},
410 'set-atomic-aggregate': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
411 'set-community': {'v_range': [['7.0.2', '']], 'type': 'raw'},
412 'set-community-additive': {'v_range': [['7.0.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
413 'set-community-delete': {'v_range': [['7.0.2', '']], 'type': 'str'},
414 'set-dampening-max-suppress': {'v_range': [['7.0.2', '']], 'type': 'int'},
415 'set-dampening-reachability-half-life': {'v_range': [['7.0.2', '']], 'type': 'int'},
416 'set-dampening-reuse': {'v_range': [['7.0.2', '']], 'type': 'int'},
417 'set-dampening-suppress': {'v_range': [['7.0.2', '']], 'type': 'int'},
418 'set-dampening-unreachability-half-life': {'v_range': [['7.0.2', '']], 'type': 'int'},
419 'set-extcommunity-rt': {'v_range': [['7.0.2', '']], 'type': 'raw'},
420 'set-extcommunity-soo': {'v_range': [['7.0.2', '']], 'type': 'raw'},
421 'set-flags': {'v_range': [['7.0.2', '']], 'type': 'int'},
422 'set-ip-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
423 'set-ip6-nexthop': {'v_range': [['7.0.2', '']], 'type': 'str'},
424 'set-ip6-nexthop-local': {'v_range': [['7.0.2', '']], 'type': 'str'},
425 'set-local-preference': {'v_range': [['7.0.2', '']], 'type': 'str'},
426 'set-metric': {'v_range': [['7.0.2', '']], 'type': 'str'},
427 'set-metric-type': {'v_range': [['7.0.2', '']], 'choices': ['1', '2', 'none', 'external-type1', 'external-type2'], 'type': 'str'},
428 'set-origin': {'v_range': [['7.0.2', '']], 'choices': ['none', 'egp', 'igp', 'incomplete'], 'type': 'str'},
429 'set-originator-id': {'v_range': [['7.0.2', '']], 'type': 'str'},
430 'set-priority': {'v_range': [['7.2.0', '']], 'type': 'int'},
431 'set-route-tag': {'v_range': [['7.0.2', '']], 'type': 'str'},
432 'set-tag': {'v_range': [['7.0.2', '']], 'type': 'str'},
433 'set-weight': {'v_range': [['7.0.2', '']], 'type': 'str'},
434 'match-extcommunity': {'v_range': [['7.2.2', '']], 'type': 'str'},
435 'match-extcommunity-exact': {'v_range': [['7.2.2', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
436 'set-ip-prefsrc': {'v_range': [['7.4.0', '']], 'type': 'str'},
437 'set-vpnv4-nexthop': {'v_range': [['7.4.1', '']], 'type': 'str'},
438 'set-vpnv6-nexthop': {'v_range': [['7.4.2', '']], 'type': 'str'},
439 'set-vpnv6-nexthop-local': {'v_range': [['7.4.2', '']], 'type': 'str'},
440 'match-suppress': {'v_range': [['7.6.5', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
441 },
442 'elements': 'dict'
443 }
444 }
445 }
446 }
447
448 module_option_spec = get_module_arg_spec('full crud')
449 module_arg_spec.update(module_option_spec)
450 check_galaxy_version(module_arg_spec)
451 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'router_routemap'),
452 supports_check_mode=True)
453 if not module._socket_path:
454 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
455 connection = Connection(module._socket_path)
456 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
457 'name', 'data', module, connection)
458 fmgr.process_crud()
459 module.exit_json(meta=module.params)
460
461
462 if __name__ == '__main__':
463 main()