Debian Codegraph @

ansible_collections/cisco/ios/plugins/modules/ios_ospf_interfaces.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2023 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 ios_ospf_interfaces
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: ios_ospf_interfaces
18 short_description: Resource module to configure OSPF interfaces.
19 description:
20 This module configures and manages the Open Shortest Path First (OSPF)
21 version 2 on IOS platforms.
22 version_added: 1.0.0
23 author:
24 - Sagar Paul (@KB-perByte)
25 - Sumit Jaiswal (@justjais)
26 notes:
27 - Tested against Cisco IOSXE Version 17.3 on CML.
28 - This module works with connection C(network_cli).
29 See U(https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html)
30 options:
31 config:
32 description: A dictionary of OSPF interfaces options.
33 type: list
34 elements: dict
35 suboptions:
36 name:
37 description:
38 - Full name of the interface excluding any logical unit number,
39 i.e. GigabitEthernet0/1.
40 type: str
41 required: true
42 address_family:
43 description:
44 - OSPF interfaces settings on the interfaces in address-family
45 context.
46 type: list
47 elements: dict
48 suboptions:
49 afi:
50 description:
51 - Address Family Identifier (AFI) for OSPF interfaces settings
52 on the interfaces.
53 type: str
54 choices:
55 - ipv4
56 - ipv6
57 required: true
58 process:
59 description: OSPF interfaces process config
60 type: dict
61 suboptions:
62 id:
63 description:
64 - Address Family Identifier (AFI) for OSPF interfaces settings
65 on the interfaces. Please refer vendor documentation of Valid
66 values.
67 type: int
68 area_id:
69 description:
70 - OSPF interfaces area ID as a decimal value. Please
71 refer vendor documentation of Valid values.
72 - OSPF interfaces area ID in IP address format(e.g.
73 A.B.C.D)
74 type: str
75 secondaries:
76 description:
77 - Include or exclude secondary IP addresses.
78 - Valid only with IPv4 config
79 type: bool
80 instance_id:
81 description:
82 - Set the OSPF instance based on ID
83 - Valid only with IPv6 OSPF config
84 type: int
85 adjacency:
86 description: Adjacency staggering
87 type: bool
88 authentication:
89 description: Enable authentication
90 type: dict
91 suboptions:
92 key_chain:
93 description: Use a key-chain for cryptographic
94 authentication keys
95 type: str
96 message_digest:
97 description: Use message-digest authentication
98 type: bool
99 "null":
100 description: Use no authentication
101 type: bool
102 bfd:
103 description:
104 - BFD configuration commands
105 - Enable/Disable BFD on this interface
106 type: bool
107 cost:
108 description: Interface cost
109 type: dict
110 suboptions:
111 interface_cost:
112 description: Interface cost or Route cost of this interface
113 type: int
114 dynamic_cost:
115 description:
116 - Specify dynamic cost options
117 - Valid only with IPv6 OSPF config
118 type: dict
119 suboptions:
120 default:
121 description: Specify default link metric value
122 type: int
123 hysteresis:
124 description: Specify hysteresis value for LSA dampening
125 type: dict
126 suboptions:
127 percent:
128 description: Specify hysteresis percent changed.
129 Please refer vendor documentation of Valid values.
130 type: int
131 threshold:
132 description: Specify hysteresis threshold value.
133 Please refer vendor documentation of Valid values.
134 type: int
135 weight:
136 description: Specify weight to be placed on individual
137 metrics
138 type: dict
139 suboptions:
140 l2_factor:
141 description:
142 - Specify weight to be given to L2-factor metric
143 - Percentage weight of L2-factor metric. Please refer
144 vendor documentation of Valid values.
145 type: int
146 latency:
147 description:
148 - Specify weight to be given to latency metric.
149 - Percentage weight of latency metric. Please refer
150 vendor documentation of Valid values.
151 type: int
152 oc:
153 description:
154 - Specify weight to be given to cdr/mdr for oc
155 - Give 100 percent weightage for current data rate(0
156 for maxdatarate)
157 type: bool
158 resources:
159 description:
160 - Specify weight to be given to resources metric
161 - Percentage weight of resources metric. Please refer
162 vendor documentation of Valid values.
163 type: int
164 throughput:
165 description:
166 - Specify weight to be given to throughput metric
167 - Percentage weight of throughput metric. Please refer
168 vendor documentation of Valid values.
169 type: int
170 database_filter:
171 description: Filter OSPF LSA during synchronization and flooding
172 type: bool
173 dead_interval:
174 description: Interval after which a neighbor is declared dead
175 type: dict
176 suboptions:
177 time:
178 description: time in seconds
179 type: int
180 minimal:
181 description:
182 - Set to 1 second and set multiplier for Hellos
183 - Number of Hellos sent within 1 second. Please refer
184 vendor documentation of Valid values.
185 - Valid only with IP OSPF config
186 type: int
187 demand_circuit:
188 description: OSPF Demand Circuit, enable or disable
189 the demand circuit'
190 type: dict
191 suboptions:
192 enable:
193 description: Enable Demand Circuit
194 type: bool
195 ignore:
196 description: Ignore demand circuit auto-negotiation requests
197 type: bool
198 disable:
199 description:
200 - Disable demand circuit on this interface
201 - Valid only with IPv6 OSPF config
202 type: bool
203 flood_reduction:
204 description: OSPF Flood Reduction
205 type: bool
206 hello_interval:
207 description:
208 - Time between HELLO packets
209 - Please refer vendor documentation of Valid values.
210 type: int
211 lls:
212 description:
213 - Link-local Signaling (LLS) support
214 - Valid only with IP OSPF config
215 type: bool
216 manet:
217 description:
218 - Mobile Adhoc Networking options
219 - MANET Peering options
220 - Valid only with IPv6 OSPF config
221 type: dict
222 suboptions:
223 cost:
224 description: Redundant path cost improvement required to peer
225 type: dict
226 suboptions:
227 percent:
228 description: Relative incremental path cost.
229 Please refer vendor documentation of Valid values.
230 type: int
231 threshold:
232 description: Absolute incremental path cost.
233 Please refer vendor documentation of Valid values.
234 type: int
235 link_metrics:
236 description: Redundant path cost improvement required to peer
237 type: dict
238 suboptions:
239 set:
240 description: Enable link-metrics
241 type: bool
242 cost_threshold:
243 description: Minimum link cost threshold.
244 Please refer vendor documentation of Valid values.
245 type: int
246 mtu_ignore:
247 description: Ignores the MTU in DBD packets
248 type: bool
249 multi_area:
250 description:
251 - Set the OSPF multi-area ID
252 - Valid only with IP OSPF config
253 type: dict
254 suboptions:
255 id:
256 description:
257 - OSPF multi-area ID as a decimal value. Please refer vendor
258 documentation of Valid values.
259 - OSPF multi-area ID in IP address format(e.g. A.B.C.D)
260 type: int
261 cost:
262 description: Interface cost
263 type: int
264 neighbor:
265 description:
266 - OSPF neighbor link-local IPv6 address (X:X:X:X::X)
267 - Valid only with IPv6 OSPF config
268 type: dict
269 suboptions:
270 address:
271 description: Neighbor link-local IPv6 address
272 type: str
273 cost:
274 description: OSPF cost for point-to-multipoint neighbor
275 type: int
276 database_filter:
277 description: Filter OSPF LSA during synchronization and flooding for point-to-multipoint neighbor
278 type: bool
279 poll_interval:
280 description: OSPF dead-router polling interval
281 type: int
282 priority:
283 description: OSPF priority of non-broadcast neighbor
284 type: int
285 network:
286 description: Network type
287 type: dict
288 suboptions:
289 broadcast:
290 description: Specify OSPF broadcast multi-access network
291 type: bool
292 manet:
293 description:
294 - Specify MANET OSPF interface type
295 - Valid only with IPv6 OSPF config
296 type: bool
297 non_broadcast:
298 description: Specify OSPF NBMA network
299 type: bool
300 point_to_multipoint:
301 description: Specify OSPF point-to-multipoint network
302 type: bool
303 point_to_point:
304 description: Specify OSPF point-to-point network
305 type: bool
306 prefix_suppression:
307 description: Enable/Disable OSPF prefix suppression
308 type: bool
309 priority:
310 description: Router priority. Please refer vendor documentation
311 of Valid values.
312 type: int
313 resync_timeout:
314 description: Interval after which adjacency is reset if oob-resync
315 is not started. Please refer vendor documentation of Valid values.
316 type: int
317 retransmit_interval:
318 description: Time between retransmitting lost link state
319 advertisements. Please refer vendor documentation of Valid values.
320 type: int
321 shutdown:
322 description: Set OSPF protocol's state to disable under
323 current interface
324 type: bool
325 transmit_delay:
326 description: Link state transmit delay.
327 Please refer vendor documentation of Valid values.
328 type: int
329 ttl_security:
330 description:
331 - TTL security check
332 - Valid only with IPV4 OSPF config
333 type: dict
334 suboptions:
335 set:
336 description: Enable TTL Security on all interfaces
337 type: bool
338 hops:
339 description:
340 - Maximum number of IP hops allowed
341 - Please refer vendor documentation of Valid values.
342 type: int
343 running_config:
344 description:
345 - This option is used only with state I(parsed).
346 - The value of this option should be the output received from the IOS
347 device by executing the command B(sh running-config | section
348 ^interface).
349 - The state I(parsed) reads the configuration from C(running_config)
350 option and transforms it into Ansible structured data as per the
351 resource module's argspec and the value is then returned in the
352 I(parsed) key within the result.
353 type: str
354 state:
355 description:
356 - The state the configuration should be left in
357 - The states I(rendered), I(gathered) and I(parsed) does not perform any
358 change on the device.
359 - The state I(rendered) will transform the configuration in C(config)
360 option to platform specific CLI commands which will be returned in the
361 I(rendered) key within the result. For state I(rendered) active
362 connection to remote host is not required.
363 - The state I(gathered) will fetch the running configuration from device
364 and transform it into structured data in the format as per the resource
365 module argspec and the value is returned in the I(gathered) key within
366 the result.
367 - The state I(parsed) reads the configuration from C(running_config)
368 option and transforms it into JSON format as per the resource module
369 parameters and the value is returned in the I(parsed) key within the
370 result. The value of C(running_config) option should be the same format
371 as the output of command I(show running-config | section ^interface) executed on device. For state I(parsed) active connection to
372 remote host is not required.
373 type: str
374 choices:
375 - merged
376 - replaced
377 - overridden
378 - deleted
379 - gathered
380 - rendered
381 - parsed
382 default: merged
383 """
384
385 EXAMPLES = """
386 # Using deleted
387
388 # Before state:
389 # -------------
390 #
391 # router-ios#sh running-config | section ^interface
392 # interface GigabitEthernet0/0
393 # interface GigabitEthernet0/1
394 # ipv6 ospf 55 area 105
395 # ipv6 ospf priority 20
396 # ipv6 ospf transmit-delay 30
397 # ipv6 ospf adjacency stagger disable
398 # interface GigabitEthernet0/2
399 # ip ospf priority 40
400 # ip ospf adjacency stagger disable
401 # ip ospf ttl-security hops 50
402 # ip ospf 10 area 20
403 # ip ospf cost 30
404
405 - name: Delete provided OSPF Interface config
406 cisco.ios.ios_ospf_interfaces:
407 config:
408 - name: GigabitEthernet0/1
409 state: deleted
410
411 # Task Output:
412 # ------------
413
414 # before:
415 # - name: GigabitEthernet0/0
416 # - address_family:
417 # - adjacency: true
418 # afi: ipv6
419 # priority: 20
420 # process:
421 # area_id: '105'
422 # id: 55
423 # transmit_delay: 30
424 # name: GigabitEthernet0/1
425 # - address_family:
426 # - adjacency: true
427 # afi: ipv4
428 # cost:
429 # interface_cost: 30
430 # priority: 40
431 # process:
432 # area_id: '20'
433 # id: 10
434 # ttl_security:
435 # hops: 50
436 # set: true
437 # name: GigabitEthernet0/2
438 #
439 # commands:
440 # - interface GigabitEthernet0/1
441 # - no ipv6 ospf 55 area 105
442 # - no ipv6 ospf adjacency stagger disable
443 # - no ipv6 ospf priority 20
444 # - no ipv6 ospf transmit-delay 30
445 #
446 # after:
447 # - name: GigabitEthernet0/0
448 # - name: GigabitEthernet0/1
449 # - address_family:
450 # - adjacency: true
451 # afi: ipv4
452 # cost:
453 # interface_cost: 30
454 # priority: 40
455 # process:
456 # area_id: '20'
457 # id: 10
458 # ttl_security:
459 # hops: 50
460 # set: true
461 # name: GigabitEthernet0/2
462 #
463 # After state:
464 # ------------
465 # router-ios#sh running-config | section ^interface
466 # interface GigabitEthernet0/0
467 # interface GigabitEthernet0/1
468 # interface GigabitEthernet0/2
469 # ip ospf priority 40
470 # ip ospf adjacency stagger disable
471 # ip ospf ttl-security hops 50
472 # ip ospf 10 area 20
473 # ip ospf cost 30
474
475 # Using deleted without any config passed (NOTE: This will delete all OSPF Interfaces configuration from device)
476
477 # Before state:
478 # -------------
479 #
480 # router-ios#sh running-config | section ^interface
481 # interface GigabitEthernet0/0
482 # interface GigabitEthernet0/1
483 # ipv6 ospf 55 area 105
484 # ipv6 ospf priority 20
485 # ipv6 ospf transmit-delay 30
486 # ipv6 ospf adjacency stagger disable
487 # interface GigabitEthernet0/2
488 # ip ospf priority 40
489 # ip ospf adjacency stagger disable
490 # ip ospf ttl-security hops 50
491 # ip ospf 10 area 20
492 # ip ospf cost 30
493
494 - name: Delete all OSPF config from interfaces
495 cisco.ios.ios_ospf_interfaces:
496 state: deleted
497
498 # Task Output:
499 # ------------
500
501 # before:
502 # - name: GigabitEthernet0/0
503 # - address_family:
504 # - adjacency: true
505 # afi: ipv6
506 # priority: 20
507 # process:
508 # area_id: '105'
509 # id: 55
510 # transmit_delay: 30
511 # name: GigabitEthernet0/1
512 # - address_family:
513 # - adjacency: true
514 # afi: ipv4
515 # cost:
516 # interface_cost: 30
517 # priority: 40
518 # process:
519 # area_id: '20'
520 # id: 10
521 # ttl_security:
522 # hops: 50
523 # set: true
524 # name: GigabitEthernet0/2
525 #
526 # commands:
527 # - interface GigabitEthernet0/2
528 # - no ip ospf 10 area 20
529 # - no ip ospf adjacency stagger disable
530 # - no ip ospf cost 30
531 # - no ip ospf priority 40
532 # - no ip ospf ttl-security hops 50
533 # - interface GigabitEthernet0/1
534 # - no ipv6 ospf 55 area 105
535 # - no ipv6 ospf adjacency stagger disable
536 # - no ipv6 ospf priority 20
537 # - no ipv6 ospf transmit-delay 30
538 #
539 # after:
540 # - name: GigabitEthernet0/0
541 # - name: GigabitEthernet0/1
542 # - name: GigabitEthernet0/2
543
544 # After state:
545 # -------------
546 # router-ios#sh running-config | section ^interface
547 # interface GigabitEthernet0/0
548 # interface GigabitEthernet0/1
549 # interface GigabitEthernet0/2
550
551 # Using merged
552
553 # Before state:
554 # -------------
555 #
556 # router-ios#sh running-config | section ^interface
557 # router-ios#
558
559 - name: Merge provided OSPF Interfaces configuration
560 cisco.ios.ios_ospf_interfaces:
561 config:
562 - name: GigabitEthernet0/1
563 address_family:
564 - afi: ipv4
565 process:
566 id: 10
567 area_id: 30
568 adjacency: true
569 bfd: true
570 cost:
571 interface_cost: 5
572 dead_interval:
573 time: 5
574 demand_circuit:
575 ignore: true
576 network:
577 broadcast: true
578 priority: 25
579 resync_timeout: 10
580 shutdown: true
581 ttl_security:
582 hops: 50
583 - afi: ipv6
584 process:
585 id: 35
586 area_id: 45
587 adjacency: true
588 database_filter: true
589 manet:
590 link_metrics:
591 cost_threshold: 10
592 priority: 55
593 transmit_delay: 45
594 state: merged
595
596 # Task Output:
597 # ------------
598 # before: []
599 #
600 # commands:
601 # - interface GigabitEthernet0/1
602 # - ip ospf 10 area 30
603 # - ip ospf adjacency stagger disable
604 # - ip ospf bfd
605 # - ip ospf cost 5
606 # - ip ospf dead-interval 5
607 # - ip ospf demand-circuit ignore
608 # - ip ospf network broadcast
609 # - ip ospf priority 25
610 # - ip ospf resync-timeout 10
611 # - ip ospf shutdown
612 # - ip ospf ttl-security hops 50
613 # - ipv6 ospf 35 area 45
614 # - ipv6 ospf adjacency stagger disable
615 # - ipv6 ospf database-filter all out
616 # - ipv6 ospf manet peering link-metrics 10
617 # - ipv6 ospf priority 55
618 # - ipv6 ospf transmit-delay 45
619 #
620 # after:
621 # - name: GigabitEthernet0/0
622 # - address_family:
623 # - adjacency: true
624 # afi: ipv4
625 # bfd: true
626 # cost:
627 # interface_cost: 5
628 # dead_interval:
629 # time: 5
630 # demand_circuit:
631 # enable: true
632 # ignore: true
633 # network:
634 # broadcast: true
635 # priority: 25
636 # process:
637 # area_id: '30'
638 # id: 10
639 # resync_timeout: 10
640 # shutdown: true
641 # ttl_security:
642 # hops: 50
643 # set: true
644 # - adjacency: true
645 # afi: ipv6
646 # database_filter: true
647 # manet:
648 # link_metrics:
649 # cost_threshold: 10
650 # priority: 55
651 # process:
652 # area_id: '45'
653 # id: 35
654 # transmit_delay: 45
655 # name: GigabitEthernet0/1
656 # - name: GigabitEthernet0/2
657
658 # After state:
659 # -------------
660 #
661 # router-ios#sh running-config | section ^interface
662 # interface GigabitEthernet0/0
663 # interface GigabitEthernet0/1
664 # ip ospf network broadcast
665 # ip ospf resync-timeout 10
666 # ip ospf dead-interval 5
667 # ip ospf priority 25
668 # ip ospf demand-circuit ignore
669 # ip ospf bfd
670 # ip ospf adjacency stagger disable
671 # ip ospf ttl-security hops 50
672 # ip ospf shutdown
673 # ip ospf 10 area 30
674 # ip ospf cost 5
675 # ipv6 ospf 35 area 45
676 # ipv6 ospf priority 55
677 # ipv6 ospf transmit-delay 45
678 # ipv6 ospf database-filter all out
679 # ipv6 ospf adjacency stagger disable
680 # ipv6 ospf manet peering link-metrics 10
681 # interface GigabitEthernet0/2
682
683 # Using overridden
684
685 # Before state:
686 # -------------
687 #
688 # router-ios#sh running-config | section ^interface
689 # interface GigabitEthernet0/0
690 # interface GigabitEthernet0/1
691 # ip ospf network broadcast
692 # ip ospf resync-timeout 10
693 # ip ospf dead-interval 5
694 # ip ospf priority 25
695 # ip ospf demand-circuit ignore
696 # ip ospf bfd
697 # ip ospf adjacency stagger disable
698 # ip ospf ttl-security hops 50
699 # ip ospf shutdown
700 # ip ospf 10 area 30
701 # ip ospf cost 5
702 # ipv6 ospf 35 area 45
703 # ipv6 ospf priority 55
704 # ipv6 ospf transmit-delay 45
705 # ipv6 ospf database-filter all out
706 # ipv6 ospf adjacency stagger disable
707 # ipv6 ospf manet peering link-metrics 10
708 # interface GigabitEthernet0/2
709
710 - name: Override running config with provided OSPF Interfaces configuration
711 cisco.ios.ios_ospf_interfaces:
712 config:
713 - name: GigabitEthernet0/1
714 address_family:
715 - afi: ipv6
716 process:
717 id: 55
718 area_id: 105
719 adjacency: true
720 priority: 20
721 transmit_delay: 30
722 - name: GigabitEthernet0/2
723 address_family:
724 - afi: ipv4
725 process:
726 id: 10
727 area_id: 20
728 adjacency: true
729 cost:
730 interface_cost: 30
731 priority: 40
732 ttl_security:
733 hops: 50
734 state: overridden
735
736 # Task Output:
737 # ------------
738 #
739 # before:
740 # - name: GigabitEthernet0/0
741 # - address_family:
742 # - adjacency: true
743 # afi: ipv4
744 # bfd: true
745 # cost:
746 # interface_cost: 5
747 # dead_interval:
748 # time: 5
749 # demand_circuit:
750 # enable: true
751 # ignore: true
752 # network:
753 # broadcast: true
754 # priority: 25
755 # process:
756 # area_id: '30'
757 # id: 10
758 # resync_timeout: 10
759 # shutdown: true
760 # ttl_security:
761 # hops: 50
762 # set: true
763 # - adjacency: true
764 # afi: ipv6
765 # database_filter: true
766 # manet:
767 # link_metrics:
768 # cost_threshold: 10
769 # priority: 55
770 # process:
771 # area_id: '45'
772 # id: 35
773 # transmit_delay: 45
774 # name: GigabitEthernet0/1
775 # - name: GigabitEthernet0/2
776 #
777 # commands:
778 # - interface GigabitEthernet0/2
779 # - ip ospf 10 area 20
780 # - ip ospf adjacency stagger disable
781 # - ip ospf cost 30
782 # - ip ospf priority 40
783 # - ip ospf ttl-security hops 50
784 # - interface GigabitEthernet0/1
785 # - ipv6 ospf 55 area 105
786 # - no ipv6 ospf database-filter all out
787 # - no ipv6 ospf manet peering link-metrics 10
788 # - ipv6 ospf priority 20
789 # - ipv6 ospf transmit-delay 30
790 # - no ip ospf 10 area 30
791 # - no ip ospf adjacency stagger disable
792 # - no ip ospf bfd
793 # - no ip ospf cost 5
794 # - no ip ospf dead-interval 5
795 # - no ip ospf demand-circuit ignore
796 # - no ip ospf network broadcast
797 # - no ip ospf priority 25
798 # - no ip ospf resync-timeout 10
799 # - no ip ospf shutdown
800 # - no ip ospf ttl-security hops 50
801 #
802 # parsed:
803 # - name: GigabitEthernet0/0
804 # - address_family:
805 # - adjacency: true
806 # afi: ipv6
807 # priority: 20
808 # process:
809 # area_id: '105'
810 # id: 55
811 # transmit_delay: 30
812 # name: GigabitEthernet0/1
813 # - address_family:
814 # - adjacency: true
815 # afi: ipv4
816 # cost:
817 # interface_cost: 30
818 # priority: 40
819 # process:
820 # area_id: '20'
821 # id: 10
822 # ttl_security:
823 # hops: 50
824 # set: true
825 # name: GigabitEthernet0/2
826 #
827 # After state:
828 # -------------
829 #
830 # router-ios#sh running-config | section ^interface
831 # interface GigabitEthernet0/0
832 # interface GigabitEthernet0/1
833 # ipv6 ospf 55 area 105
834 # ipv6 ospf priority 20
835 # ipv6 ospf transmit-delay 30
836 # ipv6 ospf adjacency stagger disable
837 # interface GigabitEthernet0/2
838 # ip ospf priority 40
839 # ip ospf adjacency stagger disable
840 # ip ospf ttl-security hops 50
841 # ip ospf 10 area 20
842 # ip ospf cost 30
843
844 # Using replaced
845
846 # Before state:
847 # -------------
848 #
849 # router-ios#sh running-config | section ^interface
850 # interface GigabitEthernet0/0
851 # interface GigabitEthernet0/1
852 # ip ospf network broadcast
853 # ip ospf resync-timeout 10
854 # ip ospf dead-interval 5
855 # ip ospf priority 25
856 # ip ospf demand-circuit ignore
857 # ip ospf bfd
858 # ip ospf adjacency stagger disable
859 # ip ospf ttl-security hops 50
860 # ip ospf shutdown
861 # ip ospf 10 area 30
862 # ip ospf cost 5
863 # ipv6 ospf 35 area 45
864 # ipv6 ospf priority 55
865 # ipv6 ospf transmit-delay 45
866 # ipv6 ospf database-filter all out
867 # ipv6 ospf adjacency stagger disable
868 # ipv6 ospf manet peering link-metrics 10
869 # interface GigabitEthernet0/2
870
871 - name: Replaced provided OSPF Interfaces configuration
872 cisco.ios.ios_ospf_interfaces:
873 config:
874 - name: GigabitEthernet0/2
875 address_family:
876 - afi: ipv6
877 process:
878 id: 55
879 area_id: 105
880 adjacency: true
881 priority: 20
882 transmit_delay: 30
883 state: replaced
884
885 # Task Output:
886 # ------------
887 #
888 # before:
889 # - name: GigabitEthernet0/0
890 # - address_family:
891 # - adjacency: true
892 # afi: ipv4
893 # bfd: true
894 # cost:
895 # interface_cost: 5
896 # dead_interval:
897 # time: 5
898 # demand_circuit:
899 # enable: true
900 # ignore: true
901 # network:
902 # broadcast: true
903 # priority: 25
904 # process:
905 # area_id: '30'
906 # id: 10
907 # resync_timeout: 10
908 # shutdown: true
909 # ttl_security:
910 # hops: 50
911 # set: true
912 # - adjacency: true
913 # afi: ipv6
914 # database_filter: true
915 # manet:
916 # link_metrics:
917 # cost_threshold: 10
918 # priority: 55
919 # process:
920 # area_id: '45'
921 # id: 35
922 # transmit_delay: 45
923 # name: GigabitEthernet0/1
924 # - name: GigabitEthernet0/2
925 #
926 # commands:
927 # - interface GigabitEthernet0/2
928 # - ipv6 ospf 55 area 105
929 # - ipv6 ospf adjacency stagger disable
930 # - ipv6 ospf priority 20
931 # - ipv6 ospf transmit-delay 30
932 #
933 # after:
934 # - name: GigabitEthernet0/0
935 # - address_family:
936 # - adjacency: true
937 # afi: ipv4
938 # bfd: true
939 # cost:
940 # interface_cost: 5
941 # dead_interval:
942 # time: 5
943 # demand_circuit:
944 # enable: true
945 # ignore: true
946 # network:
947 # broadcast: true
948 # priority: 25
949 # process:
950 # area_id: '30'
951 # id: 10
952 # resync_timeout: 10
953 # shutdown: true
954 # ttl_security:
955 # hops: 50
956 # set: true
957 # - adjacency: true
958 # afi: ipv6
959 # database_filter: true
960 # manet:
961 # link_metrics:
962 # cost_threshold: 10
963 # priority: 55
964 # process:
965 # area_id: '45'
966 # id: 35
967 # transmit_delay: 45
968 # name: GigabitEthernet0/1
969 # - address_family:
970 # - adjacency: true
971 # afi: ipv6
972 # priority: 20
973 # process:
974 # area_id: '105'
975 # id: 55
976 # transmit_delay: 30
977 # name: GigabitEthernet0/2
978
979 # After state:
980 # ------------
981 # router-ios#sh running-config | section ^interface
982 # interface GigabitEthernet0/0
983 # interface GigabitEthernet0/1
984 # ip ospf network broadcast
985 # ip ospf resync-timeout 10
986 # ip ospf dead-interval 5
987 # ip ospf priority 25
988 # ip ospf demand-circuit ignore
989 # ip ospf bfd
990 # ip ospf adjacency stagger disable
991 # ip ospf ttl-security hops 50
992 # ip ospf shutdown
993 # ip ospf 10 area 30
994 # ip ospf cost 5
995 # ipv6 ospf 35 area 45
996 # ipv6 ospf priority 55
997 # ipv6 ospf transmit-delay 45
998 # ipv6 ospf database-filter all out
999 # ipv6 ospf adjacency stagger disable
1000 # ipv6 ospf manet peering link-metrics 10
1001 # interface GigabitEthernet0/2
1002 # ipv6 ospf 55 area 105
1003 # ipv6 ospf priority 20
1004 # ipv6 ospf transmit-delay 30
1005 # ipv6 ospf adjacency stagger disable
1006
1007 # Using Gathered
1008
1009 # Before state:
1010 # -------------
1011 #
1012 # router-ios#sh running-config | section ^interface
1013 # interface GigabitEthernet0/0
1014 # interface GigabitEthernet0/1
1015 # ip ospf network broadcast
1016 # ip ospf resync-timeout 10
1017 # ip ospf dead-interval 5
1018 # ip ospf priority 25
1019 # ip ospf demand-circuit ignore
1020 # ip ospf bfd
1021 # ip ospf adjacency stagger disable
1022 # ip ospf ttl-security hops 50
1023 # ip ospf shutdown
1024 # ip ospf 10 area 30
1025 # ip ospf cost 5
1026 # ipv6 ospf 35 area 45
1027 # ipv6 ospf priority 55
1028 # ipv6 ospf transmit-delay 45
1029 # ipv6 ospf database-filter all out
1030 # ipv6 ospf adjacency stagger disable
1031 # ipv6 ospf manet peering link-metrics 10
1032 # interface GigabitEthernet0/2
1033
1034 - name: Gather OSPF Interfaces provided configurations
1035 cisco.ios.ios_ospf_interfaces:
1036 config:
1037 state: gathered
1038
1039 # Task Output:
1040 # ------------
1041 #
1042 # gathered:
1043 # - name: GigabitEthernet0/0
1044 # - address_family:
1045 # - adjacency: true
1046 # afi: ipv4
1047 # bfd: true
1048 # cost:
1049 # interface_cost: 5
1050 # dead_interval:
1051 # time: 5
1052 # demand_circuit:
1053 # enable: true
1054 # ignore: true
1055 # network:
1056 # broadcast: true
1057 # priority: 25
1058 # process:
1059 # area_id: '30'
1060 # id: 10
1061 # resync_timeout: 10
1062 # shutdown: true
1063 # ttl_security:
1064 # hops: 50
1065 # set: true
1066 # - adjacency: true
1067 # afi: ipv6
1068 # database_filter: true
1069 # manet:
1070 # link_metrics:
1071 # cost_threshold: 10
1072 # priority: 55
1073 # process:
1074 # area_id: '45'
1075 # id: 35
1076 # transmit_delay: 45
1077 # name: GigabitEthernet0/1
1078 # - name: GigabitEthernet0/2
1079
1080 # After state:
1081 # ------------
1082 #
1083 # router-ios#sh running-config | section ^interface
1084 # interface GigabitEthernet0/0
1085 # interface GigabitEthernet0/1
1086 # ip ospf network broadcast
1087 # ip ospf resync-timeout 10
1088 # ip ospf dead-interval 5
1089 # ip ospf priority 25
1090 # ip ospf demand-circuit ignore
1091 # ip ospf bfd
1092 # ip ospf adjacency stagger disable
1093 # ip ospf ttl-security hops 50
1094 # ip ospf shutdown
1095 # ip ospf 10 area 30
1096 # ip ospf cost 5
1097 # ipv6 ospf 35 area 45
1098 # ipv6 ospf priority 55
1099 # ipv6 ospf transmit-delay 45
1100 # ipv6 ospf database-filter all out
1101 # ipv6 ospf adjacency stagger disable
1102 # ipv6 ospf manet peering link-metrics 10
1103 # interface GigabitEthernet0/2
1104
1105 # Using Rendered
1106
1107 - name: Render the commands for provided configuration
1108 cisco.ios.ios_ospf_interfaces:
1109 config:
1110 - name: GigabitEthernet0/1
1111 address_family:
1112 - afi: ipv4
1113 process:
1114 id: 10
1115 area_id: 30
1116 adjacency: true
1117 bfd: true
1118 cost:
1119 interface_cost: 5
1120 dead_interval:
1121 time: 5
1122 demand_circuit:
1123 ignore: true
1124 network:
1125 broadcast: true
1126 priority: 25
1127 resync_timeout: 10
1128 shutdown: true
1129 ttl_security:
1130 hops: 50
1131 - afi: ipv6
1132 process:
1133 id: 35
1134 area_id: 45
1135 adjacency: true
1136 database_filter: true
1137 manet:
1138 link_metrics:
1139 cost_threshold: 10
1140 priority: 55
1141 transmit_delay: 45
1142 state: rendered
1143
1144 # Task Output:
1145 # ------------
1146 #
1147 # rendered:
1148 # - interface GigabitEthernet0/1
1149 # - ip ospf 10 area 30
1150 # - ip ospf adjacency stagger disable
1151 # - ip ospf bfd
1152 # - ip ospf cost 5
1153 # - ip ospf dead-interval 5
1154 # - ip ospf demand-circuit ignore
1155 # - ip ospf network broadcast
1156 # - ip ospf priority 25
1157 # - ip ospf resync-timeout 10
1158 # - ip ospf shutdown
1159 # - ip ospf ttl-security hops 50
1160 # - ipv6 ospf 35 area 45
1161 # - ipv6 ospf adjacency stagger disable
1162 # - ipv6 ospf database-filter all out
1163 # - ipv6 ospf manet peering link-metrics 10
1164 # - ipv6 ospf priority 55
1165 # - ipv6 ospf transmit-delay 45
1166 #
1167
1168 # Using Parsed
1169
1170 # File: parsed.cfg
1171 # ----------------
1172 #
1173 # interface GigabitEthernet0/2
1174 # interface GigabitEthernet0/1
1175 # ip ospf network broadcast
1176 # ip ospf resync-timeout 10
1177 # ip ospf dead-interval 5
1178 # ip ospf priority 25
1179 # ip ospf demand-circuit ignore
1180 # ip ospf bfd
1181 # ip ospf adjacency stagger disable
1182 # ip ospf ttl-security hops 50
1183 # ip ospf shutdown
1184 # ip ospf 10 area 30
1185 # ip ospf cost 5
1186 # ipv6 ospf 35 area 45
1187 # ipv6 ospf priority 55
1188 # ipv6 ospf transmit-delay 45
1189 # ipv6 ospf database-filter all out
1190 # ipv6 ospf adjacency stagger disable
1191 # ipv6 ospf manet peering link-metrics 10
1192 # interface GigabitEthernet0/0
1193
1194 - name: Parse the provided configuration with the existing running configuration
1195 cisco.ios.ios_ospf_interfaces:
1196 running_config: "{{ lookup('file', 'parsed.cfg') }}"
1197 state: parsed
1198
1199 # Task Output:
1200 # ------------
1201 #
1202 # parsed:
1203 # - name: GigabitEthernet0/2
1204 # - address_family:
1205 # - adjacency: true
1206 # afi: ipv4
1207 # bfd: true
1208 # cost:
1209 # interface_cost: 5
1210 # dead_interval:
1211 # time: 5
1212 # demand_circuit:
1213 # enable: true
1214 # ignore: true
1215 # network:
1216 # broadcast: true
1217 # priority: 25
1218 # process:
1219 # area_id: '30'
1220 # id: 10
1221 # resync_timeout: 10
1222 # shutdown: true
1223 # ttl_security:
1224 # hops: 50
1225 # set: true
1226 # - adjacency: true
1227 # afi: ipv6
1228 # database_filter: true
1229 # manet:
1230 # link_metrics:
1231 # cost_threshold: 10
1232 # priority: 55
1233 # process:
1234 # area_id: '45'
1235 # id: 35
1236 # transmit_delay: 45
1237 # name: GigabitEthernet0/1
1238 # - name: GigabitEthernet0/0
1239 """
1240
1241 RETURN = """
1242 before:
1243 description: The configuration prior to the module execution.
1244 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1245 type: list
1246 sample: >
1247 This output will always be in the same format as the
1248 module argspec.
1249 after:
1250 description: The resulting configuration after module execution.
1251 returned: when changed
1252 type: list
1253 sample: >
1254 This output will always be in the same format as the
1255 module argspec.
1256 commands:
1257 description: The set of commands pushed to the remote device.
1258 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1259 type: list
1260 sample:
1261 - interface GigabitEthernet2
1262 - ip ospf priority 40
1263 - ip ospf adjacency stagger disable
1264 rendered:
1265 description: The provided configuration in the task rendered in device-native format (offline).
1266 returned: when I(state) is C(rendered)
1267 type: list
1268 sample:
1269 - interface GigabitEthernet2
1270 - ip ospf priority 40
1271 - ip ospf adjacency stagger disable
1272 gathered:
1273 description: Facts about the network resource gathered from the remote device as structured data.
1274 returned: when I(state) is C(gathered)
1275 type: list
1276 sample: >
1277 This output will always be in the same format as the
1278 module argspec.
1279 parsed:
1280 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1281 returned: when I(state) is C(parsed)
1282 type: list
1283 sample: >
1284 This output will always be in the same format as the
1285 module argspec.
1286 """
1287
1288 from ansible.module_utils.basic import AnsibleModule
1289
1290 from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.ospf_interfaces.ospf_interfaces import (
1291 Ospf_interfacesArgs,
1292 )
1293 from ansible_collections.cisco.ios.plugins.module_utils.network.ios.config.ospf_interfaces.ospf_interfaces import (
1294 Ospf_interfaces,
1295 )
1296
1297
1298 def main():
1299 """
1300 Main entry point for module execution
1301
1302 :returns: the result form module invocation
1303 """
1304 module = AnsibleModule(
1305 argument_spec=Ospf_interfacesArgs.argument_spec,
1306 mutually_exclusive=[["config", "running_config"]],
1307 required_if=[
1308 ["state", "merged", ["config"]],
1309 ["state", "replaced", ["config"]],
1310 ["state", "overridden", ["config"]],
1311 ["state", "rendered", ["config"]],
1312 ["state", "parsed", ["running_config"]],
1313 ],
1314 supports_check_mode=True,
1315 )
1316
1317 result = Ospf_interfaces(module).execute_module()
1318 module.exit_json(**result)
1319
1320
1321 if __name__ == "__main__":
1322 main()