Debian Codegraph @

ansible_collections/cisco/iosxr/plugins/modules/iosxr_ospf_interfaces.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2020 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 iosxr_ospf_interfaces
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: iosxr_ospf_interfaces
18 version_added: 1.2.0
19 short_description: Resource module to configure OSPF interfaces.
20 description:
21 - This module manages OSPF(v2/v3) configuration of interfaces on devices running Cisco IOS-XR.
22 author: Rohit Thakur (@rohitthakur2590)
23 notes:
24 - This module works with connection C(network_cli). See L(the IOS-XR Platform Options,../network/user_guide/platform_iosxr.html)
25 options:
26 running_config:
27 description:
28 - This option is used only with state I(parsed).
29 - The value of this option should be the output received from the IOS-XR device
30 by executing the command B(show running-config router ospf').
31 - The state I(parsed) reads the configuration from C(running_config) option and
32 transforms it into Ansible structured data as per the resource module's argspec
33 and the value is then returned in the I(parsed) key within the result.
34 type: str
35 config:
36 description: A list of OSPF configuration for interfaces.
37 type: list
38 elements: dict
39 suboptions:
40 name:
41 description:
42 - Name/Identifier of the interface.
43 type: str
44 required: True
45 type:
46 description:
47 - Type of the interface.
48 type: str
49 required: True
50 address_family:
51 description:
52 - OSPF settings on the interfaces in address-family context.
53 type: list
54 elements: dict
55 suboptions:
56 afi:
57 description:
58 - Address Family Identifier (AFI) for OSPF settings on the interfaces.
59 type: str
60 choices: ['ipv4', 'ipv6']
61 required: True
62 processes:
63 description:
64 - Interfaces configuration for an OSPF process.
65 type: list
66 elements: dict
67 suboptions:
68 process_id:
69 description:
70 - OSPF process tag.
71 type: str
72 required: True
73 area:
74 description: Specify the area-id
75 type: dict
76 suboptions:
77 area_id:
78 description:
79 - OSPF interfaces area ID as a decimal value. Please
80 refer vendor documentation of Valid values.
81 - OSPF interfaces area ID in IP address format(e.g.
82 A.B.C.D)
83 type: str
84 apply_group_option:
85 description: Specify configuration from a group
86 type: dict
87 suboptions:
88 group_name:
89 description: Specify the name of the group
90 type: str
91 operation:
92 description: Specify the group config operation
93 type: str
94 choices: [add, remove, append]
95 authentication:
96 description: Enable authentication
97 type: dict
98 suboptions:
99 message_digest:
100 description: Use message-digest authentication
101 type: dict
102 suboptions:
103 keychain:
104 description: Specify keychain name
105 type: str
106 null_auth:
107 description: Use no authentication
108 type: bool
109 authentication_key:
110 description: Specify authentication password (key)
111 type: dict
112 suboptions:
113 password:
114 description: The OSPFv2 password (key)
115 type: str
116 clear:
117 description: Specifies an UNENCRYPTED password (key) will follow
118 type: str
119 encrypted:
120 description: Specifies an ENCRYPTED password (key) will follow
121 type: str
122 bfd:
123 description: Configure BFD parameters
124 type: dict
125 suboptions:
126 fast_detect:
127 description: Configure fast detection
128 type: dict
129 suboptions:
130 set:
131 description: Enable fast detection only
132 type: bool
133 strict_mode:
134 description: Hold down neighbor session until BFD session is up
135 type: bool
136 minimum_interval:
137 description: Hello interval in milli-seconds
138 type: int
139 multiplier:
140 description: Detect multiplier
141 type: int
142 cost:
143 description: Specify Interface cost
144 type: int
145 cost_fallback:
146 description: Specify Cost when cumulative bandwidth goes below the theshold
147 type: dict
148 suboptions:
149 cost:
150 description: Specify cost w.r.t cummulative bandwidth
151 type: int
152 threshold:
153 description: Specify threshold bandwidth when cost-fallback is applied
154 type: int
155 database_filter:
156 description: Filter OSPF LSAs during synchronization and flooding
157 type: dict
158 suboptions:
159 all_outgoing_lsa:
160 description: Filter all outgoing LSA
161 type: bool
162 dead_interval:
163 description: Specify interval after which a neighbor is declared dead
164 type: int
165 demand_circuit:
166 description: Enable/Disable demand circuits
167 type: bool
168 fast_reroute:
169 description: Specify IP Fast Reroute
170 type: dict
171 suboptions:
172 disabled:
173 description: Disable IP fast reroute
174 type: bool
175 per_link:
176 description: Specify per-prefix computation
177 type: dict
178 suboptions:
179 information_type:
180 description: Specify per-link LFA exclusion or FRR LFA candidate information
181 type: str
182 choices: ["exclude", "lfa_candidate"]
183 use_candidate_only:
184 description: Enable/Disable backup selection from candidate-list only
185 type: bool
186 interface:
187 description: Specify Per-link LFA exclusion information
188 type: dict
189 suboptions:
190 bvi:
191 description: Specify Bridge-Group Virtual Interface
192 type: list
193 elements: dict
194 suboptions:
195 name:
196 description: Specify the interface id
197 type: int
198 bundle_ether:
199 description: Specify Aggregated Ethernet interface(s)
200 type: list
201 elements: dict
202 suboptions:
203 name:
204 description: Specify the interface id
205 type: int
206 pos_int:
207 description: Specify Aggregated pos interface(s)
208 type: list
209 elements: dict
210 suboptions:
211 name:
212 description: Specify the interface id
213 type: int
214 fast_ethernet:
215 description: Specify FastEthernet/IEEE 802.3 interface(s)
216 type: list
217 elements: dict
218 suboptions:
219 name:
220 description: Specify the interface id
221 type: str
222 fiftygige:
223 description: Specify FiftyGigE/IEEE 802.3 interface(s)
224 type: list
225 elements: dict
226 suboptions:
227 name:
228 description: Specify the interface id
229 type: str
230 fortygige:
231 description: Specify FortyGigE/IEEE 802.3 interface(s)
232 type: list
233 elements: dict
234 suboptions:
235 name:
236 description: Specify the interface id
237 type: str
238 fourhundredgige:
239 description: Specify FourHundredGigE/IEEE 802.3 interface(s)
240 type: list
241 elements: dict
242 suboptions:
243 name:
244 description: Specify the interface id
245 type: str
246 gigabitethernet:
247 description: Specify GigabitEthernet/IEEE 802.3 interface(s)
248 type: list
249 elements: dict
250 suboptions:
251 name:
252 description: Specify the interface id
253 type: str
254 hundredgige:
255 description: Specify HundredGigE/IEEE 802.3 interface(s)
256 type: list
257 elements: dict
258 suboptions:
259 name:
260 description: Specify the interface id
261 type: str
262 mgmteth:
263 description: Specify MgmtEth/IEEE 802.3 interface(s)
264 type: list
265 elements: dict
266 suboptions:
267 name:
268 description: Specify the interface id
269 type: str
270 multilink:
271 description: Specify Multilink network interface(s)
272 type: list
273 elements: dict
274 suboptions:
275 name:
276 description: Specify the interface id
277 type: str
278 pw_ether:
279 description: Specify PWHE Ethernet Interface
280 type: list
281 elements: dict
282 suboptions:
283 name:
284 description: Specify the interface id
285 type: int
286 pw_iw:
287 description: Specify PWHE VC11 IP Interworking Interface
288 type: list
289 elements: dict
290 suboptions:
291 name:
292 description: Specify the interface id
293 type: int
294 srp:
295 description: Specify SRP interface(s)
296 type: list
297 elements: dict
298 suboptions:
299 name:
300 description: Specify the interface id
301 type: str
302 serial:
303 description: Specify Serial network interface(s)
304 type: list
305 elements: dict
306 suboptions:
307 name:
308 description: Specify the interface id
309 type: str
310 tengige:
311 description: Specify TenGigabitEthernet/IEEE 802.3 interface(s)
312 type: list
313 elements: dict
314 suboptions:
315 name:
316 description: Specify the interface id
317 type: str
318 twentyfivegige:
319 description: Specify TwentyFiveGigabitEthernet/IEEE 802.3 interface(s)
320 type: list
321 elements: dict
322 suboptions:
323 name:
324 description: Specify the interface id
325 type: str
326 twohundredgige:
327 description: Specify TwoHundredGigE/IEEE 802.3 interface(s)
328 type: list
329 elements: dict
330 suboptions:
331 name:
332 description: Specify the interface id
333 type: str
334 nve:
335 description: Specify Network Virtualization Endpoint Interface(s)
336 type: list
337 elements: dict
338 suboptions:
339 name:
340 description: Specify the interface id
341 type: int
342 tunnel_ip:
343 description: Specify GRE/IPinIP Tunnel Interface(s)
344 type: list
345 elements: dict
346 suboptions:
347 name:
348 description: Specify the interface id
349 type: int
350 tunnel_ipsec:
351 description: Specify IPSec Tunnel interface(s)
352 type: list
353 elements: dict
354 suboptions:
355 name:
356 description: Specify the interface id
357 type: int
358 tunnel_mte:
359 description: Specify MPLS Traffic Engineering P2MP Tunnel interface(s)
360 type: list
361 elements: dict
362 suboptions:
363 name:
364 description: Specify the interface id
365 type: int
366 tunnel_mpls:
367 description: MPLS Transport Protocol Tunnel interface
368 type: list
369 elements: dict
370 suboptions:
371 name:
372 description: Specify the interface id
373 type: str
374 flood_reduction:
375 description: Enable/Disable flood reduction
376 type: bool
377 hello_interval:
378 description: Specify Time between HELLO packets
379 type: int
380 link_down_fast_detect:
381 description: Configure interface down parameters
382 type: bool
383 message_digest_key:
384 description: Message digest authentication password (key)
385 type: dict
386 suboptions:
387 id:
388 description: Key ID
389 type: int
390 required: true
391 md5:
392 description: Use MD5 Algorithm
393 type: dict
394 required: true
395 suboptions:
396 password:
397 description: The OSPFv2 password (key)
398 type: str
399 clear:
400 description: Specifies an UNENCRYPTED password (key) will follow
401 type: bool
402 encrypted:
403 description: Specifies an ENCRYPTED password (key) will follow
404 type: bool
405 mpls_ldp_sync:
406 description: Enable/Disable MPLS LDP Sync
407 type: bool
408 mtu_ignore:
409 description: Enable/Disable ignoring of MTU in DBD packets
410 type: bool
411 network:
412 description: Specify Network type
413 type: str
414 choices: ["broadcast", "non-broadcast", "point-to-multipoint", "point-to-point"]
415 neighbors:
416 description: Specify a neighbor routers
417 type: list
418 elements: dict
419 suboptions:
420 neighbor_id:
421 description: Specify Neighbor address (name)
422 type: str
423 cost:
424 description: Specify OSPF cost for point-to-multipoint neighbor
425 type: int
426 db_filter_all_out:
427 description: Specify Filter OSPF LSA during synchronization and flooding for point-to-multipoint neighbor
428 type: bool
429 poll_interval:
430 description: Specify OSPF dead-router polling interval
431 type: int
432 priority:
433 description: Specify OSPF priority of non-broadcast neighbor
434 type: int
435 packet_size:
436 description: Customize size of OSPF packets upto MTU
437 type: int
438 passive:
439 description: Enable/Disable passive
440 type: bool
441 prefix_suppression:
442 description: Suppress advertisement of the prefixes
443 type: bool
444 priority:
445 description: Specify Router priority
446 type: int
447 retransmit_interval:
448 description: Specify time between retransmitting lost link state advertisements
449 type: int
450 security_ttl:
451 description: Enable security
452 type: dict
453 suboptions:
454 set:
455 description: Enable ttl security
456 type: bool
457 hops:
458 description: Maximum number of IP hops allowed <1-254>
459 type: int
460 transmit_delay:
461 description: Specify estimated time needed to send link-state update packet
462 type: int
463 state:
464 description:
465 - The state the configuration should be left in.
466 type: str
467 choices:
468 - merged
469 - replaced
470 - overridden
471 - deleted
472 - gathered
473 - parsed
474 - rendered
475 default: merged
476 """
477 EXAMPLES = """
478 # Using merged
479
480 # Before state:
481 # -------------
482 #
483 # RP/0/RP0/CPU0:anton#show running-config router ospf
484 # % No such configuration item(s)
485 #
486
487 - name: Merge provided OSPF interfaces configuration with the existing configuration
488 cisco.iosxr.iosxr_ospf_interfaces:
489 config:
490 - name: GigabitEthernet0/0/0/0
491 type: gigabitethernet
492 address_family:
493 - afi: ipv4
494 processes:
495 - process_id: LAB3
496 area:
497 area_id: 0.0.0.3
498 cost: 20
499 authentication:
500 message_digest:
501 keychain: cisco
502 - afi: ipv6
503 processes:
504 - process_id: LAB3
505 area:
506 area_id: 0.0.0.2
507 cost: 30
508 state: merged
509
510 #
511 #
512 # Task Output:
513 # ------------
514 #
515 # before: []
516 #
517 # commands:
518 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20
519 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest
520 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco
521 # - router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30
522 #
523 # after:
524 # - address_family:
525 # - afi: ipv4
526 # authentication:
527 # message_digest:
528 # keychain: cisco
529 # cost: 20
530 # processes:
531 # - area:
532 # area_id: 0.0.0.3
533 # process_id: LAB3
534 # - afi: ipv6
535 # cost: 30
536 # processes:
537 # - area:
538 # area_id: 0.0.0.2
539 # process_id: LAB3
540 # name: GigabitEthernet0/0/0/0
541 # type: gigabitethernet
542 #
543 # After state:
544 # ------------
545 #
546 # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
547 # Thu Oct 23 06:00:57.217 UTC
548 # router ospf LAB3
549 # area 0.0.0.3
550 # interface GigabitEthernet0/0/0/0
551 # cost 20
552 # authentication message-digest keychain cisco
553 # !
554 # !
555 # !
556 # router ospfv3 LAB3
557 # area 0.0.0.2
558 # interface GigabitEthernet0/0/0/0
559 # cost 30
560 # !
561 # !
562 # !
563
564 # Using replaced
565 #
566 # Before state:
567 # -------------
568 #
569 #
570 # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
571 # Thu Oct 23 06:00:57.217 UTC
572 # router ospf LAB3
573 # area 0.0.0.3
574 # interface GigabitEthernet0/0/0/0
575 # cost 20
576 # authentication message-digest keychain cisco
577 # !
578 # !
579 # !
580 # router ospfv3 LAB3
581 # area 0.0.0.2
582 # interface GigabitEthernet0/0/0/0
583 # cost 30
584 # !
585 # !
586 # !
587
588 - name: Replace OSPF interfaces configuration
589 cisco.iosxr.iosxr_ospf_interfaces:
590 config:
591 - name: GigabitEthernet0/0/0/0
592 type: gigabitethernet
593 address_family:
594 - afi: ipv4
595 processes:
596 - process_id: LAB3
597 area:
598 area_id: 0.0.0.3
599 cost: 30
600 authentication:
601 message_digest:
602 keychain: ciscoiosxr
603 - afi: ipv6
604 processes:
605 - process_id: LAB3
606 area:
607 area_id: 0.0.0.2
608 cost: 30
609 state: replaced
610 #
611 # Task Output:
612 # ------------
613 #
614 # before:
615 # - address_family:
616 # - afi: ipv4
617 # authentication:
618 # message_digest:
619 # keychain: cisco
620 # cost: 20
621 # processes:
622 # - area:
623 # area_id: 0.0.0.3
624 # process_id: LAB3
625 # - afi: ipv6
626 # cost: 30
627 # processes:
628 # - area:
629 # area_id: 0.0.0.2
630 # process_id: LAB3
631 # name: GigabitEthernet0/0/0/0
632 # type: gigabitethernet
633 #
634 # commands:
635 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 30
636 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest
637 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain ciscoiosxr
638 #
639 # after:
640 # - address_family:
641 # - afi: ipv4
642 # authentication:
643 # message_digest:
644 # keychain: ciscoiosxr
645 # cost: 30
646 # processes:
647 # - area:
648 # area_id: 0.0.0.3
649 # process_id: LAB3
650 # - afi: ipv6
651 # cost: 30
652 # processes:
653 # - area:
654 # area_id: 0.0.0.2
655 # process_id: LAB3
656 # name: GigabitEthernet0/0/0/0
657 # type: gigabitethernet
658 #
659 # After state:
660 # ------------
661 #
662 # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
663 # Thu Oct 23 06:10:39.827 UTC
664 # router ospf LAB3
665 # area 0.0.0.3
666 # interface GigabitEthernet0/0/0/0
667 # cost 30
668 # authentication message-digest keychain ciscoiosxr
669 # !
670 # router ospfv3 LAB3
671 # area 0.0.0.2
672 # interface GigabitEthernet0/0/0/0
673 # cost 30
674 # !
675 # !
676 # !
677
678 # Using overridden
679 #
680 # Before state
681 # ------------
682 #
683 - name: Override existing OSPF interfaces configuration
684 cisco.iosxr.iosxr_ospf_interfaces:
685 config:
686 - name: GigabitEthernet0/0/0/1
687 type: gigabitethernet
688 address_family:
689 - afi: ipv4
690 processes:
691 - process_id: LAB1
692 area:
693 area_id: 0.0.0.3
694 cost: 10
695 authentication:
696 message_digest:
697 keychain: iosxr
698 state: overridden
699
700 #
701 #
702 # Task Output:
703 # ------------
704 #
705 # before:
706 # - address_family:
707 # - afi: ipv4
708 # authentication:
709 # message_digest:
710 # keychain: ciscoiosxr
711 # cost: 30
712 # processes:
713 # - area:
714 # area_id: 0.0.0.3
715 # process_id: LAB3
716 # - afi: ipv6
717 # cost: 30
718 # processes:
719 # - area:
720 # area_id: 0.0.0.2
721 # process_id: LAB3
722 # name: GigabitEthernet0/0/0/0
723 # type: gigabitethernet
724 #
725 # commands:
726 # - no router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0
727 # - no router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0
728 # - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 cost 10
729 # - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest
730 # - router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1 authentication message-digest keychain iosxr
731 #
732 # after:
733 # - address_family:
734 # - afi: ipv4
735 # authentication:
736 # message_digest:
737 # keychain: iosxr
738 # cost: 10
739 # processes:
740 # - area:
741 # area_id: 0.0.0.3
742 # process_id: LAB1
743 # name: GigabitEthernet0/0/0/1
744 # type: gigabitethernet
745 #
746 # After state:
747 # ------------
748 #
749 # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
750 # Thu Oct 23 06:28:15.025 UTC
751 # router ospf LAB1
752 # area 0.0.0.3
753 # interface GigabitEthernet0/0/0/1
754 # cost 10
755 # authentication message-digest keychain iosxr
756 # !
757 # !
758 # !
759 # router ospf LAB3
760 # area 0.0.0.3
761 # !
762 # !
763 # router ospfv3 LAB3
764 # area 0.0.0.2
765 # !
766 # !
767
768 # Using deleted
769 #
770 # Before state:
771 # -------------
772 #
773 #
774 # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
775 # Thu Oct 23 06:28:15.025 UTC
776 # router ospf LAB1
777 # area 0.0.0.3
778 # interface GigabitEthernet0/0/0/1
779 # cost 10
780 # authentication message-digest keychain iosxr
781 # !
782 # !
783 # !
784 # router ospf LAB3
785 # area 0.0.0.3
786 # interface GigabitEthernet0/0/0/0
787 # cost 20
788 # authentication message-digest keychain cisco
789 # !
790 # !
791 # !
792 # router ospfv3 LAB3
793 # area 0.0.0.2
794 # interface GigabitEthernet0/0/0/0
795 # cost 30
796 # !
797 # !
798 # !
799
800 - name: Deleted existing OSPF interfaces from the device
801 cisco.iosxr.iosxr_ospf_interfaces:
802 config:
803 - name: GigabitEthernet0/0/0/1
804 type: gigabitethernet
805 state: deleted
806
807 #
808 # Task Output:
809 # ------------
810 #
811 # before:
812 # - address_family:
813 # - afi: ipv4
814 # authentication:
815 # message_digest:
816 # keychain: iosxr
817 # cost: 10
818 # processes:
819 # - area:
820 # area_id: 0.0.0.3
821 # process_id: LAB1
822 # name: GigabitEthernet0/0/0/1
823 # type: gigabitethernet
824 # - address_family:
825 # - afi: ipv4
826 # authentication:
827 # message_digest:
828 # keychain: cisco
829 # cost: 20
830 # processes:
831 # - area:
832 # area_id: 0.0.0.3
833 # process_id: LAB3
834 # - afi: ipv6
835 # cost: 30
836 # processes:
837 # - area:
838 # area_id: 0.0.0.2
839 # process_id: LAB3
840 # name: GigabitEthernet0/0/0/0
841 # type: gigabitethernet
842 #
843 # commands:
844 # - no router ospf LAB1 area 0.0.0.3 interface GigabitEthernet 0/0/0/1]
845 #
846 # after:
847 # - address_family:
848 # - afi: ipv4
849 # authentication:
850 # message_digest:
851 # keychain: cisco
852 # cost: 20
853 # processes:
854 # - area:
855 # area_id: 0.0.0.3
856 # process_id: LAB3
857 # - afi: ipv6
858 # cost: 30
859 # processes:
860 # - area:
861 # area_id: 0.0.0.2
862 # process_id: LAB3
863 # name: GigabitEthernet0/0/0/0
864 # type: gigabitethernet
865 #
866 # After state:
867 # ------------
868 #
869 # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
870 # Thu Oct 23 06:34:38.319 UTC
871 # router ospf LAB1
872 # area 0.0.0.3
873 # !
874 # !
875 # router ospf LAB3
876 # area 0.0.0.3
877 # interface GigabitEthernet0/0/0/0
878 # cost 20
879 # authentication message-digest keychain cisco
880 # !
881 # !
882 # !
883 # router ospfv3 LAB3
884 # area 0.0.0.2
885 # interface GigabitEthernet0/0/0/0
886 # cost 30
887 # !
888 # !
889 # !
890
891 # Using parsed
892 #
893 # parsed.cfg
894 # ------------
895 # router ospf LAB
896 # area 0.0.0.0
897 # !
898 # area 0.0.0.9
899 # !
900 # !
901 # router ospf LAB1
902 # area 0.0.0.1
903 # !
904 # area 0.0.0.3
905 # !
906 # !
907 # router ospf LAB3
908 # area 0.0.0.3
909 # interface GigabitEthernet0/0/0/0
910 # cost 20
911 # authentication message-digest keychain cisco
912 # !
913 # !
914 # !
915 # router ospf ipv4
916 # !
917 - name: Parsed running config and display structured facts.
918 cisco.iosxr.iosxr_ospf_interfaces:
919 running_config: "{{ lookup('file', './parsed.cfg') }}"
920 state: parsed
921 #
922 # Task Output:
923 # ------------
924 #
925 # parsed:
926 # - address_family:
927 # - afi: ipv4
928 # authentication:
929 # message_digest:
930 # keychain: cisco
931 # cost: 20
932 # processes:
933 # - area:
934 # area_id: 0.0.0.3
935 # process_id: LAB3
936 # name: GigabitEthernet0/0/0/0
937 # type: gigabitethernet
938
939 # Using rendered
940 #
941 - name: Render the commands for provided configuration
942 cisco.iosxr.iosxr_ospf_interfaces:
943 config:
944 - name: GigabitEthernet0/0/0/0
945 type: gigabitethernet
946 address_family:
947 - afi: ipv4
948 processes:
949 - process_id: LAB3
950 area:
951 area_id: 0.0.0.3
952 cost: 20
953 authentication:
954 message_digest:
955 keychain: cisco
956 - afi: ipv6
957 processes:
958 - process_id: LAB3
959 area:
960 area_id: 0.0.0.2
961 cost: 30
962 state: rendered
963
964 #
965 # Task Output:
966 # ------------
967 #
968 # rendered:
969 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20
970 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest
971 # - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest keychain cisco
972 # - router ospfv3 LAB3 area 0.0.0.2 interface GigabitEthernet 0/0/0/0 cost 30
973
974 # Using gathered
975 #
976 # Before state:
977 # -------------
978 #
979 # RP/0/0/CPU0:an-iosxr-02#show running-config router ospf
980 # Thu Oct 23 06:50:38.743 UTC
981 # router ospf LAB3
982 # area 0.0.0.3
983 # interface GigabitEthernet0/0/0/0
984 # cost 20
985 # authentication message-digest keychain cisco
986 # !
987 # !
988 # !
989 # router ospfv3 LAB3
990 # area 0.0.0.2
991 # interface GigabitEthernet0/0/0/0
992 # cost 30
993 # !
994 # !
995 # !
996
997
998 - name: Gather ospf_interfaces routes configuration
999 cisco.iosxr.iosxr_ospf_interfaces:
1000 state: gathered
1001 #
1002 # Task Output:
1003 # ------------
1004 #
1005 # gathered:
1006 # - address_family:
1007 # - afi: ipv4
1008 # authentication:
1009 # message_digest:
1010 # keychain: cisco
1011 # cost: 20
1012 # processes:
1013 # - area:
1014 # area_id: 0.0.0.3
1015 # process_id: LAB3
1016 # - afi: ipv6
1017 # cost: 30
1018 # processes:
1019 # - area:
1020 # area_id: 0.0.0.2
1021 # process_id: LAB3
1022 # name: GigabitEthernet0/0/0/0
1023 # type: gigabitethernet
1024 """
1025 RETURN = """
1026 before:
1027 description: The configuration prior to the model invocation.
1028 returned: always
1029 type: list
1030 sample: >
1031 The configuration returned will always be in the same format
1032 of the parameters above.
1033 after:
1034 description: The resulting configuration model invocation.
1035 returned: when changed
1036 type: list
1037 sample: >
1038 The configuration returned will always be in the same format
1039 of the parameters above.
1040 commands:
1041 description: The set of commands pushed to the remote device.
1042 returned: always
1043 type: list
1044 sample:
1045 - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20
1046 - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 authentication message-digest
1047
1048 rendered:
1049 description: The provided configuration in the task rendered in device-native format (offline).
1050 returned: when I(state) is C(rendered)
1051 type: list
1052 sample:
1053 - router ospf LAB3 area 0.0.0.3 interface GigabitEthernet 0/0/0/0 cost 20
1054
1055 gathered:
1056 description: Facts about the network resource gathered from the remote device as structured data.
1057 returned: when I(state) is C(gathered)
1058 type: list
1059 sample: >
1060 This output will always be in the same format as the
1061 module argspec.
1062 parsed:
1063 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1064 returned: when I(state) is C(parsed)
1065 type: list
1066 sample: >
1067 This output will always be in the same format as the
1068 module argspec.
1069 """
1070
1071 from ansible.module_utils.basic import AnsibleModule
1072
1073 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.ospf_interfaces.ospf_interfaces import (
1074 Ospf_interfacesArgs,
1075 )
1076 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.ospf_interfaces.ospf_interfaces import (
1077 Ospf_interfaces,
1078 )
1079
1080
1081 def main():
1082 """
1083 Main entry point for module execution
1084
1085 :returns: the result form module invocation
1086 """
1087 module = AnsibleModule(
1088 argument_spec=Ospf_interfacesArgs.argument_spec,
1089 mutually_exclusive=[["config", "running_config"]],
1090 required_if=[
1091 ["state", "merged", ["config"]],
1092 ["state", "replaced", ["config"]],
1093 ["state", "overridden", ["config"]],
1094 ["state", "rendered", ["config"]],
1095 ["state", "parsed", ["running_config"]],
1096 ],
1097 supports_check_mode=True,
1098 )
1099
1100 result = Ospf_interfaces(module).execute_module()
1101 module.exit_json(**result)
1102
1103
1104 if __name__ == "__main__":
1105 main()