Debian Codegraph @

ansible_collections/cisco/nxos/plugins/modules/nxos_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 nxos_ospf_interfaces
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: nxos_ospf_interfaces
18 version_added: 1.3.0
19 short_description: OSPF Interfaces Resource Module.
20 description:
21 - This module manages OSPF(v2/v3) configuration of interfaces on devices running Cisco NX-OS.
22 notes:
23 - Unsupported for Cisco MDS
24 author: Nilashish Chakraborty (@NilashishC)
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 NX-OS device
30 by executing the command B(show running-config | section "^interface").
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 address_family:
46 description:
47 - OSPF settings on the interfaces in address-family context.
48 type: list
49 elements: dict
50 suboptions:
51 afi:
52 description:
53 - Address Family Identifier (AFI) for OSPF settings on the interfaces.
54 type: str
55 choices: ['ipv4', 'ipv6']
56 required: true
57 processes:
58 description:
59 - Interfaces configuration for an OSPF process.
60 type: list
61 elements: dict
62 suboptions:
63 process_id:
64 description:
65 - OSPF process tag.
66 type: str
67 required: true
68 area:
69 description:
70 - Area associated with interface.
71 type: dict
72 suboptions:
73 area_id:
74 description:
75 - Area ID in IP address format.
76 type: str
77 required: true
78 secondaries:
79 description:
80 - Do not include secondary IPv4/IPv6 addresses.
81 type: bool
82 multi_areas:
83 description:
84 - Multi-Areas associated with interface.
85 - Valid values are Area Ids as an integer or IP address.
86 type: list
87 elements: str
88 multi_areas:
89 description:
90 - Multi-Areas associated with interface (not tied to OSPF process).
91 - Valid values are Area Ids as an integer or IP address.
92 type: list
93 elements: str
94 authentication:
95 description:
96 - Authentication settings on the interface.
97 type: dict
98 suboptions:
99 key_chain:
100 description:
101 - Authentication password key-chain.
102 type: str
103 message_digest:
104 description:
105 - Use message-digest authentication.
106 type: bool
107 enable:
108 description:
109 - Enable/disable authentication on the interface.
110 type: bool
111 null_auth:
112 description:
113 - Use null(disable) authentication.
114 type: bool
115 authentication_key:
116 description:
117 - Configure the authentication key for the interface.
118 type: dict
119 suboptions:
120 encryption:
121 description:
122 - 0 Specifies an UNENCRYPTED authentication key will follow.
123 - 3 Specifies an 3DES ENCRYPTED authentication key will follow.
124 - 7 Specifies a Cisco type 7 ENCRYPTED authentication key will follow.
125 type: int
126 key:
127 description:
128 - Authentication key.
129 - Valid values are Cisco type 7 ENCRYPTED password, 3DES ENCRYPTED password
130 and UNENCRYPTED (cleartext) password based on the value of encryption key.
131 type: str
132 required: true
133 message_digest_key:
134 description:
135 - Message digest authentication password (key) settings.
136 type: dict
137 suboptions:
138 key_id:
139 description:
140 - Key ID.
141 type: int
142 required: true
143 encryption:
144 description:
145 - 0 Specifies an UNENCRYPTED ospf password (key) will follow.
146 - 3 Specifies an 3DES ENCRYPTED ospf password (key) will follow.
147 - 7 Specifies a Cisco type 7 ENCRYPTED the ospf password (key) will follow.
148 type: int
149 key:
150 description:
151 - Authentication key.
152 - Valid values are Cisco type 7 ENCRYPTED password, 3DES ENCRYPTED password
153 and UNENCRYPTED (cleartext) password based on the value of encryption key.
154 type: str
155 required: true
156 cost:
157 description:
158 - Cost associated with interface.
159 type: int
160 dead_interval:
161 description:
162 - Dead interval value (in seconds).
163 type: int
164 hello_interval:
165 description:
166 - Hello interval value (in seconds).
167 type: int
168 instance:
169 description:
170 - Instance identifier.
171 type: int
172 mtu_ignore:
173 description:
174 - Enable/disable OSPF MTU mismatch detection.
175 type: bool
176 network:
177 description:
178 - Network type.
179 type: str
180 choices: ["broadcast", "point-to-point"]
181 passive_interface:
182 description:
183 - Suppress routing updates on the interface.
184 - This option is mutually exclusive with I(default_passive_interface).
185 type: bool
186 default_passive_interface:
187 description:
188 - Set passive-interface attribute on this interface to default.
189 - This option is mutually exclusive with I(passive_interface).
190 type: bool
191 priority:
192 description:
193 - Router priority.
194 type: int
195 retransmit_interval:
196 description:
197 - Packet retransmission interval.
198 type: int
199 shutdown:
200 description:
201 - Shutdown OSPF on this interface.
202 type: bool
203 transmit_delay:
204 description:
205 - Packet transmission delay.
206 type: int
207 state:
208 description:
209 - The state the configuration should be left in.
210 type: str
211 choices:
212 - merged
213 - replaced
214 - overridden
215 - deleted
216 - gathered
217 - parsed
218 - rendered
219 default: merged
220 """
221 EXAMPLES = """
222 # Using merged
223
224 # Before state:
225 # -------------
226 # NXOS# show running-config | section ^interface
227 # interface Ethernet1/1
228 # no switchport
229 # interface Ethernet1/2
230 # no switchport
231 # interface Ethernet1/3
232 # no switchport
233
234 - name: Merge the provided configuration with the existing running configuration
235 cisco.nxos.nxos_ospf_interfaces:
236 config:
237 - name: Ethernet1/1
238 address_family:
239 - afi: ipv4
240 processes:
241 - process_id: '100'
242 area:
243 area_id: 1.1.1.1
244 secondaries: false
245 multi_areas:
246 - 11.11.11.11
247 - afi: ipv6
248 processes:
249 - process_id: '200'
250 area:
251 area_id: 2.2.2.2
252 multi_areas:
253 - 21.0.0.0
254 - process_id: '300'
255 multi_areas:
256 - 50.50.50.50
257 multi_areas:
258 - 16.10.10.10
259 - name: Ethernet1/2
260 address_family:
261 - afi: ipv4
262 authentication:
263 enable: true
264 key_chain: test-1
265 message_digest_key:
266 key_id: 10
267 encryption: 3
268 key: abc01d272be25d29
269 cost: 100
270 - afi: ipv6
271 network: broadcast
272 shutdown: true
273 - name: Ethernet1/3
274 address_family:
275 - afi: ipv4
276 authentication_key:
277 encryption: 7
278 key: 12090404011C03162E
279 state: merged
280
281 # Task output:
282 # ------------
283 # before:
284 # - name: Ethernet1/1
285 # - name: Ethernet1/2
286 # - name: Ethernet1/3
287 #
288 # commands:
289 # - interface Ethernet1/1
290 # - ip router ospf multi-area 11.11.11.11
291 # - ip router ospf 100 area 1.1.1.1 secondaries none
292 # - ipv6 router ospfv3 multi-area 16.10.10.10
293 # - ipv6 router ospfv3 200 area 2.2.2.2
294 # - ipv6 router ospfv3 200 multi-area 21.0.0.0
295 # - ipv6 router ospfv3 300 multi-area 50.50.50.50
296 # - interface Ethernet1/2
297 # - ip ospf authentication key-chain test-1
298 # - ip ospf authentication
299 # - ip ospf message-digest-key 10 md5 3 abc01d272be25d29
300 # - ip ospf cost 100
301 # - ospfv3 network broadcast
302 # - ospfv3 shutdown
303 # - interface Ethernet1/3
304 # - ip ospf authentication-key 7 12090404011C03162E
305 #
306 # after:
307 # - address_family:
308 # - afi: ipv4
309 # multi_areas:
310 # - 11.11.11.11
311 # processes:
312 # - area:
313 # area_id: 1.1.1.1
314 # secondaries: false
315 # process_id: '100'
316 # - afi: ipv6
317 # multi_areas:
318 # - 16.10.10.10
319 # processes:
320 # - area:
321 # area_id: 2.2.2.2
322 # multi_areas:
323 # - 21.0.0.0
324 # process_id: '200'
325 # - multi_areas:
326 # - 50.50.50.50
327 # process_id: '300'
328 # name: Ethernet1/1
329 # - address_family:
330 # - afi: ipv4
331 # authentication:
332 # enable: true
333 # key_chain: test-1
334 # cost: 100
335 # message_digest_key:
336 # encryption: 3
337 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
338 # key_id: 10
339 # - afi: ipv6
340 # network: broadcast
341 # shutdown: true
342 # name: Ethernet1/2
343 # - address_family:
344 # - afi: ipv4
345 # authentication_key:
346 # encryption: 7
347 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
348 # name: Ethernet1/3
349
350 # After state:
351 # ------------
352 # NXOS# show running-config | section ^interface
353 # interface Ethernet1/1
354 # no switchport
355 # ip router ospf 100 area 1.1.1.1 secondaries none
356 # ip router ospf multi-area 11.11.11.11
357 # ipv6 router ospfv3 200 area 2.2.2.2
358 # ipv6 router ospfv3 multi-area 16.10.10.10
359 # ipv6 router ospfv3 200 multi-area 21.0.0.0
360 # ipv6 router ospfv3 300 multi-area 50.50.50.50
361 # interface Ethernet1/2
362 # no switchport
363 # ip ospf authentication
364 # ip ospf authentication key-chain test-1
365 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
366 # ip ospf cost 100
367 # ospfv3 network broadcast
368 # ospfv3 shutdown
369 # interface Ethernet1/3
370 # no switchport
371 # ip ospf authentication-key 7 12090404011C03162E
372
373
374 # Using replaced
375
376 # Before state:
377 # -------------
378 # NXOS# show running-config | section ^interface
379 # interface Ethernet1/1
380 # no switchport
381 # ip router ospf 100 area 1.1.1.1 secondaries none
382 # ip router ospf multi-area 11.11.11.11
383 # ipv6 router ospfv3 200 area 2.2.2.2
384 # ipv6 router ospfv3 multi-area 16.10.10.10
385 # ipv6 router ospfv3 200 multi-area 21.0.0.0
386 # ipv6 router ospfv3 300 multi-area 50.50.50.50
387 # interface Ethernet1/2
388 # no switchport
389 # ip ospf authentication
390 # ip ospf authentication key-chain test-1
391 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
392 # ip ospf cost 100
393 # ospfv3 network broadcast
394 # ospfv3 shutdown
395 # interface Ethernet1/3
396 # no switchport
397 # ip ospf authentication-key 7 12090404011C03162E
398
399 - name: Replace OSPF configurations of listed interfaces with provided configurations
400 cisco.nxos.nxos_ospf_interfaces:
401 config:
402 - name: Ethernet1/1
403 address_family:
404 - afi: ipv4
405 processes:
406 - process_id: "100"
407 area:
408 area_id: 1.1.1.1
409 secondaries: false
410 multi_areas:
411 - 11.11.11.12
412 - name: Ethernet1/3
413 state: replaced
414
415 # Task output:
416 # ------------
417 # before:
418 # - address_family:
419 # - afi: ipv4
420 # multi_areas:
421 # - 11.11.11.11
422 # processes:
423 # - area:
424 # area_id: 1.1.1.1
425 # secondaries: false
426 # process_id: '100'
427 # - afi: ipv6
428 # multi_areas:
429 # - 16.10.10.10
430 # processes:
431 # - area:
432 # area_id: 2.2.2.2
433 # multi_areas:
434 # - 21.0.0.0
435 # process_id: '200'
436 # - multi_areas:
437 # - 50.50.50.50
438 # process_id: '300'
439 # name: Ethernet1/1
440 # - address_family:
441 # - afi: ipv4
442 # authentication:
443 # enable: true
444 # key_chain: test-1
445 # cost: 100
446 # message_digest_key:
447 # encryption: 3
448 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
449 # key_id: 10
450 # - afi: ipv6
451 # network: broadcast
452 # shutdown: true
453 # name: Ethernet1/2
454 # - address_family:
455 # - afi: ipv4
456 # authentication_key:
457 # encryption: 7
458 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
459 # name: Ethernet1/3
460 #
461 # commands:
462 # - interface Ethernet1/1
463 # - ip router ospf multi-area 11.11.11.12
464 # - no ip router ospf multi-area 11.11.11.11
465 # - no ipv6 router ospfv3 multi-area 16.10.10.10
466 # - no ipv6 router ospfv3 200 area 2.2.2.2
467 # - no ipv6 router ospfv3 200 multi-area 21.0.0.0
468 # - no ipv6 router ospfv3 300 multi-area 50.50.50.50
469 # - interface Ethernet1/3
470 # - no ip ospf authentication-key 7 12090404011C03162E
471 #
472 # after:
473 # - address_family:
474 # - afi: ipv4
475 # multi_areas:
476 # - 11.11.11.12
477 # processes:
478 # - area:
479 # area_id: 1.1.1.1
480 # secondaries: false
481 # process_id: '100'
482 # name: Ethernet1/1
483 # - address_family:
484 # - afi: ipv4
485 # authentication:
486 # enable: true
487 # key_chain: test-1
488 # cost: 100
489 # message_digest_key:
490 # encryption: 3
491 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
492 # key_id: 10
493 # - afi: ipv6
494 # network: broadcast
495 # shutdown: true
496 # name: Ethernet1/2
497 # - name: Ethernet1/3
498 #
499 # After state:
500 # ------------
501 # NXOS# show running-config | section ^interface
502 # interface Ethernet1/1
503 # no switchport
504 # ip router ospf 100 area 1.1.1.1 secondaries none
505 # ip router ospf multi-area 11.11.11.12
506 # interface Ethernet1/2
507 # no switchport
508 # ip ospf authentication
509 # ip ospf authentication key-chain test-1
510 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
511 # ip ospf cost 100
512 # ospfv3 network broadcast
513 # ospfv3 shutdown
514 # interface Ethernet1/3
515 # no switchport
516
517
518 # Using overridden
519
520 # Before state:
521 # -------------
522 # NXOS# show running-config | section ^interface
523 # interface Ethernet1/1
524 # no switchport
525 # ip router ospf 100 area 1.1.1.1 secondaries none
526 # ip router ospf multi-area 11.11.11.11
527 # ipv6 router ospfv3 200 area 2.2.2.2
528 # ipv6 router ospfv3 multi-area 16.10.10.10
529 # ipv6 router ospfv3 200 multi-area 21.0.0.0
530 # ipv6 router ospfv3 300 multi-area 50.50.50.50
531 # interface Ethernet1/2
532 # no switchport
533 # ip ospf authentication
534 # ip ospf authentication key-chain test-1
535 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
536 # ip ospf cost 100
537 # ospfv3 network broadcast
538 # ospfv3 shutdown
539 # interface Ethernet1/3
540 # no switchport
541 # ip ospf authentication-key 7 12090404011C03162E
542
543 - name: Override all OSPF interfaces configuration with provided configuration
544 cisco.nxos.nxos_ospf_interfaces:
545 config:
546 - name: Ethernet1/1
547 address_family:
548 - afi: ipv4
549 processes:
550 - process_id: "100"
551 area:
552 area_id: 1.1.1.1
553 secondaries: false
554 multi_areas:
555 - 11.11.11.12
556 state: overridden
557
558 # Task output:
559 # ------------
560 # before:
561 # - address_family:
562 # - afi: ipv4
563 # multi_areas:
564 # - 11.11.11.11
565 # processes:
566 # - area:
567 # area_id: 1.1.1.1
568 # secondaries: false
569 # process_id: '100'
570 # - afi: ipv6
571 # multi_areas:
572 # - 16.10.10.10
573 # processes:
574 # - area:
575 # area_id: 2.2.2.2
576 # multi_areas:
577 # - 21.0.0.0
578 # process_id: '200'
579 # - multi_areas:
580 # - 50.50.50.50
581 # process_id: '300'
582 # name: Ethernet1/1
583 # - address_family:
584 # - afi: ipv4
585 # authentication:
586 # enable: true
587 # key_chain: test-1
588 # cost: 100
589 # message_digest_key:
590 # encryption: 3
591 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
592 # key_id: 10
593 # - afi: ipv6
594 # network: broadcast
595 # shutdown: true
596 # name: Ethernet1/2
597 # - address_family:
598 # - afi: ipv4
599 # authentication_key:
600 # encryption: 7
601 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
602 # name: Ethernet1/3
603 #
604 # commands:
605 # - interface Ethernet1/2
606 # - no ip ospf authentication key-chain test-1
607 # - no ip ospf authentication
608 # - no ip ospf message-digest-key 10 md5 3 abc01d272be25d29
609 # - no ip ospf cost 100
610 # - no ospfv3 network broadcast
611 # - no ospfv3 shutdown
612 # - interface Ethernet1/3
613 # - no ip ospf authentication-key 7 12090404011C03162E
614 # - interface Ethernet1/1
615 # - ip router ospf multi-area 11.11.11.12
616 # - no ip router ospf multi-area 11.11.11.11
617 # - no ipv6 router ospfv3 multi-area 16.10.10.10
618 # - no ipv6 router ospfv3 200 area 2.2.2.2
619 # - no ipv6 router ospfv3 200 multi-area 21.0.0.0
620 # - no ipv6 router ospfv3 300 multi-area 50.50.50.50
621 #
622 # after:
623 # - address_family:
624 # - afi: ipv4
625 # multi_areas:
626 # - 11.11.11.12
627 # processes:
628 # - area:
629 # area_id: 1.1.1.1
630 # secondaries: false
631 # process_id: '100'
632 # name: Ethernet1/1
633 # - name: Ethernet1/2
634 # - name: Ethernet1/3
635
636 # After state:
637 # -------------
638 # NXOS# show running-config | section ^interface
639 # interface Ethernet1/1
640 # no switchport
641 # ip router ospf 100 area 1.1.1.1 secondaries none
642 # ip router ospf multi-area 11.11.11.12
643 # interface Ethernet1/2
644 # no switchport
645 # interface Ethernet1/3
646 # no switchport
647
648 # Using deleted to delete OSPF config of a single interface
649
650 # Before state:
651 # -------------
652 # NXOS# show running-config | section ^interface
653 # interface Ethernet1/1
654 # no switchport
655 # ip router ospf 100 area 1.1.1.1 secondaries none
656 # ip router ospf multi-area 11.11.11.11
657 # ipv6 router ospfv3 200 area 2.2.2.2
658 # ipv6 router ospfv3 multi-area 16.10.10.10
659 # ipv6 router ospfv3 200 multi-area 21.0.0.0
660 # ipv6 router ospfv3 300 multi-area 50.50.50.50
661 # interface Ethernet1/2
662 # no switchport
663 # ip ospf authentication
664 # ip ospf authentication key-chain test-1
665 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
666 # ip ospf cost 100
667 # ospfv3 network broadcast
668 # ospfv3 shutdown
669 # interface Ethernet1/3
670 # no switchport
671 # ip ospf authentication-key 7 12090404011C03162E
672
673 - name: Delete OSPF config from a single interface
674 cisco.nxos.nxos_ospf_interfaces:
675 config:
676 - name: Ethernet1/1
677 state: deleted
678
679 # Task output:
680 # ------------
681 # before:
682 # - address_family:
683 # - afi: ipv4
684 # multi_areas:
685 # - 11.11.11.11
686 # processes:
687 # - area:
688 # area_id: 1.1.1.1
689 # secondaries: false
690 # process_id: '100'
691 # - afi: ipv6
692 # multi_areas:
693 # - 16.10.10.10
694 # processes:
695 # - area:
696 # area_id: 2.2.2.2
697 # multi_areas:
698 # - 21.0.0.0
699 # process_id: '200'
700 # - multi_areas:
701 # - 50.50.50.50
702 # process_id: '300'
703 # name: Ethernet1/1
704 # - address_family:
705 # - afi: ipv4
706 # authentication:
707 # enable: true
708 # key_chain: test-1
709 # cost: 100
710 # message_digest_key:
711 # encryption: 3
712 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
713 # key_id: 10
714 # - afi: ipv6
715 # network: broadcast
716 # shutdown: true
717 # name: Ethernet1/2
718 # - address_family:
719 # - afi: ipv4
720 # authentication_key:
721 # encryption: 7
722 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
723 # name: Ethernet1/3
724 #
725 # commands:
726 # - interface Ethernet1/1
727 # - no ip router ospf multi-area 11.11.11.11
728 # - no ip router ospf 100 area 1.1.1.1 secondaries none
729 # - no ipv6 router ospfv3 multi-area 16.10.10.10
730 # - no ipv6 router ospfv3 200 area 2.2.2.2
731 # - no ipv6 router ospfv3 200 multi-area 21.0.0.0
732 # - no ipv6 router ospfv3 300 multi-area 50.50.50.50
733 #
734 # after:
735 # - name: Ethernet1/1
736 # - address_family:
737 # - afi: ipv4
738 # authentication:
739 # enable: true
740 # key_chain: test-1
741 # cost: 100
742 # message_digest_key:
743 # encryption: 3
744 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
745 # key_id: 10
746 # - afi: ipv6
747 # network: broadcast
748 # shutdown: true
749 # name: Ethernet1/2
750 # - address_family:
751 # - afi: ipv4
752 # authentication_key:
753 # encryption: 7
754 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
755 # name: Ethernet1/3
756
757
758 # After state:
759 # ------------
760 # NXOS# show running-config | section ^interface
761 # interface Ethernet1/1
762 # no switchport
763 # interface Ethernet1/2
764 # no switchport
765 # ip ospf authentication
766 # ip ospf authentication key-chain test-1
767 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
768 # ip ospf cost 100
769 # ospfv3 network broadcast
770 # ospfv3 shutdown
771 # interface Ethernet1/3
772 # no switchport
773 # ip ospf authentication-key 7 12090404011C03162E
774
775 # Using deleted to delete OSPF config from all interfaces
776
777 # Before state:
778 # -------------
779 # NXOS# show running-config | section ^interface
780 # interface Ethernet1/1
781 # no switchport
782 # ip router ospf 100 area 1.1.1.1 secondaries none
783 # ip router ospf multi-area 11.11.11.11
784 # ipv6 router ospfv3 200 area 2.2.2.2
785 # ipv6 router ospfv3 multi-area 16.10.10.10
786 # ipv6 router ospfv3 200 multi-area 21.0.0.0
787 # ipv6 router ospfv3 300 multi-area 50.50.50.50
788 # interface Ethernet1/2
789 # no switchport
790 # ip ospf authentication
791 # ip ospf authentication key-chain test-1
792 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
793 # ip ospf cost 100
794 # ospfv3 network broadcast
795 # ospfv3 shutdown
796 # interface Ethernet1/3
797 # no switchport
798 # ip ospf authentication-key 7 12090404011C03162E
799
800 - name: Delete OSPF config from all interfaces
801 cisco.nxos.nxos_ospf_interfaces:
802 state: deleted
803
804 # Task output:
805 # ------------
806 # before:
807 # - name: Ethernet1/1
808 # - address_family:
809 # - afi: ipv4
810 # authentication:
811 # enable: true
812 # key_chain: test-1
813 # cost: 100
814 # message_digest_key:
815 # encryption: 3
816 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
817 # key_id: 10
818 # - afi: ipv6
819 # network: broadcast
820 # shutdown: true
821 # name: Ethernet1/2
822 # - address_family:
823 # - afi: ipv4
824 # authentication_key:
825 # encryption: 7
826 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
827 # name: Ethernet1/3
828 #
829 # commands:
830 # - interface Ethernet1/1
831 # - no ip router ospf multi-area 11.11.11.11
832 # - no ip router ospf 100 area 1.1.1.1 secondaries none
833 # - no ipv6 router ospfv3 multi-area 16.10.10.10
834 # - no ipv6 router ospfv3 200 area 2.2.2.2
835 # - no ipv6 router ospfv3 200 multi-area 21.0.0.0
836 # - no ipv6 router ospfv3 300 multi-area 50.50.50.50
837 # - interface Ethernet1/2
838 # - no ip ospf authentication key-chain test-1
839 # - no ip ospf authentication
840 # - no ip ospf message-digest-key 10 md5 3 abc01d272be25d29
841 # - no ip ospf cost 100
842 # - no ospfv3 network broadcast
843 # - no ospfv3 shutdown
844 # - interface Ethernet1/3
845 # - no ip ospf authentication-key 7 12090404011C03162E
846 #
847 # after:
848 # - name: Ethernet1/1
849 # - name: Ethernet1/2
850 # - name: Ethernet1/3
851
852 # After state:
853 # ------------
854 # NXOS# show running-config | section ^interface
855 # interface Ethernet1/1
856 # no switchport
857 # interface Ethernet1/2
858 # no switchport
859 # interface Ethernet1/3
860 # no switchport
861
862 # Using rendered
863
864 - name: >-
865 Render platform specific configuration lines with state rendered (without
866 connecting to the device)
867 cisco.nxos.nxos_ospf_interfaces:
868 config:
869 - name: Ethernet1/1
870 address_family:
871 - afi: ipv4
872 processes:
873 - process_id: '100'
874 area:
875 area_id: 1.1.1.1
876 secondaries: false
877 multi_areas:
878 - 11.11.11.11
879 - afi: ipv6
880 processes:
881 - process_id: '200'
882 area:
883 area_id: 2.2.2.2
884 multi_areas:
885 - 21.0.0.0
886 - process_id: '300'
887 multi_areas:
888 - 50.50.50.50
889 multi_areas:
890 - 16.10.10.10
891 - name: Ethernet1/2
892 address_family:
893 - afi: ipv4
894 authentication:
895 enable: true
896 key_chain: test-1
897 message_digest_key:
898 key_id: 10
899 encryption: 3
900 key: abc01d272be25d29
901 cost: 100
902 - afi: ipv6
903 network: broadcast
904 shutdown: true
905 - name: Ethernet1/3
906 address_family:
907 - afi: ipv4
908 authentication_key:
909 encryption: 7
910 key: 12090404011C03162E
911 state: rendered
912
913
914 # Task Output:
915 # ------------
916 # rendered:
917 # - interface Ethernet1/1
918 # - ip router ospf multi-area 11.11.11.11
919 # - ip router ospf 100 area 1.1.1.1 secondaries none
920 # - ipv6 router ospfv3 multi-area 16.10.10.10
921 # - ipv6 router ospfv3 200 area 2.2.2.2
922 # - ipv6 router ospfv3 200 multi-area 21.0.0.0
923 # - ipv6 router ospfv3 300 multi-area 50.50.50.50
924 # - interface Ethernet1/2
925 # - ip ospf authentication key-chain test-1
926 # - ip ospf authentication
927 # - ip ospf message-digest-key 10 md5 3 abc01d272be25d29
928 # - ip ospf cost 100
929 # - ospfv3 network broadcast
930 # - ospfv3 shutdown
931 # - interface Ethernet1/3
932 # - ip ospf authentication-key 7 12090404011C03162E
933
934 # Using parsed
935
936 # parsed.cfg
937 # ------------
938 # interface Ethernet1/1
939 # ip router ospf 100 area 1.1.1.1 secondaries none
940 # ip router ospf multi-area 11.11.11.11
941 # ipv6 router ospfv3 200 area 2.2.2.2
942 # ipv6 router ospfv3 200 multi-area 21.0.0.0
943 # ipv6 router ospfv3 300 multi-area 50.50.50.50
944 # ipv6 router ospfv3 multi-area 16.10.10.10
945 # interface Ethernet1/2
946 # ip ospf authentication
947 # ip ospf authentication key-chain test-1
948 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
949 # ip ospf cost 100
950 # ospfv3 network broadcast
951 # ospfv3 shutdown
952 # interface Ethernet1/3
953 # ip ospf authentication-key 7 12090404011C03162E
954
955 - name: arse externally provided OSPF interfaces config
956 cisco.nxos.nxos_ospf_interfaces:
957 running_config: "{{ lookup('file', 'ospf_interfaces.cfg') }}"
958 state: parsed
959
960 # Task output:
961 # ------------
962 # parsed:
963 # - address_family:
964 # - afi: ipv4
965 # multi_areas:
966 # - 11.11.11.11
967 # processes:
968 # - area:
969 # area_id: 1.1.1.1
970 # secondaries: false
971 # process_id: '100'
972 # - afi: ipv6
973 # multi_areas:
974 # - 16.10.10.10
975 # processes:
976 # - area:
977 # area_id: 2.2.2.2
978 # multi_areas:
979 # - 21.0.0.0
980 # process_id: '200'
981 # - multi_areas:
982 # - 50.50.50.50
983 # process_id: '300'
984 # name: Ethernet1/1
985 # - address_family:
986 # - afi: ipv4
987 # authentication:
988 # enable: true
989 # key_chain: test-1
990 # cost: 100
991 # message_digest_key:
992 # encryption: 3
993 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
994 # key_id: 10
995 # - afi: ipv6
996 # network: broadcast
997 # shutdown: true
998 # name: Ethernet1/2
999 # - address_family:
1000 # - afi: ipv4
1001 # authentication_key:
1002 # encryption: 7
1003 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
1004 # name: Ethernet1/3
1005
1006 # Using gathered
1007
1008 # On-box config
1009
1010 # NXOS# show running-config | section ^interface
1011 # interface Ethernet1/1
1012 # no switchport
1013 # ip router ospf 100 area 1.1.1.1 secondaries none
1014 # ip router ospf multi-area 11.11.11.12
1015 # interface Ethernet1/2
1016 # no switchport
1017 # ip ospf authentication
1018 # ip ospf authentication key-chain test-1
1019 # ip ospf message-digest-key 10 md5 3 abc01d272be25d29
1020 # ip ospf cost 100
1021 # ospfv3 network broadcast
1022 # ospfv3 shutdown
1023 # interface Ethernet1/3
1024 # no switchport
1025
1026 # Task output:
1027 # ------------
1028 # gathered:
1029 # - address_family:
1030 # - afi: ipv4
1031 # multi_areas:
1032 # - 11.11.11.12
1033 # processes:
1034 # - area:
1035 # area_id: 1.1.1.1
1036 # secondaries: false
1037 # process_id: '100'
1038 # name: Ethernet1/1
1039 # - address_family:
1040 # - afi: ipv4
1041 # authentication:
1042 # enable: true
1043 # key_chain: test-1
1044 # cost: 100
1045 # message_digest_key:
1046 # encryption: 3
1047 # key: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
1048 # key_id: 10
1049 # - afi: ipv6
1050 # network: broadcast
1051 # shutdown: true
1052 # name: Ethernet1/2
1053 # - name: Ethernet1/3
1054 """
1055 RETURN = """
1056 before:
1057 description: The configuration prior to the model invocation.
1058 returned: always
1059 type: list
1060 sample: >
1061 The configuration returned will always be in the same format
1062 of the parameters above.
1063 after:
1064 description: The resulting configuration model invocation.
1065 returned: when changed
1066 type: list
1067 sample: >
1068 The configuration returned will always be in the same format
1069 of the parameters above.
1070 commands:
1071 description: The set of commands pushed to the remote device.
1072 returned: always
1073 type: list
1074 sample:
1075 - interface Ethernet1/1
1076 - ip router ospf multi-area 11.11.11.11
1077 - ip router ospf 100 area 1.1.1.1 secondaries none
1078 - no ipv6 router ospfv3 multi-area 16.10.10.10
1079 - ipv6 router ospfv3 200 area 2.2.2.2
1080 - ipv6 router ospfv3 200 multi-area 21.0.0.0
1081 - ipv6 router ospfv3 300 multi-area 50.50.50.50
1082 - interface Ethernet1/2
1083 - no ip ospf authentication key-chain test-1
1084 - ip ospf authentication
1085 rendered:
1086 description: The provided configuration in the task rendered in device-native format (offline).
1087 returned: when I(state) is C(rendered)
1088 type: list
1089 sample:
1090 - interface Ethernet1/1
1091 - ip router ospf multi-area 11.11.11.11
1092 - ip router ospf 100 area 1.1.1.1 secondaries none
1093 gathered:
1094 description: Facts about the network resource gathered from the remote device as structured data.
1095 returned: when I(state) is C(gathered)
1096 type: list
1097 sample: >
1098 This output will always be in the same format as the
1099 module argspec.
1100 parsed:
1101 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1102 returned: when I(state) is C(parsed)
1103 type: list
1104 sample: >
1105 This output will always be in the same format as the
1106 module argspec.
1107 """
1108
1109 from ansible.module_utils.basic import AnsibleModule
1110
1111 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.argspec.ospf_interfaces.ospf_interfaces import (
1112 Ospf_interfacesArgs,
1113 )
1114 from ansible_collections.cisco.nxos.plugins.module_utils.network.nxos.config.ospf_interfaces.ospf_interfaces import (
1115 Ospf_interfaces,
1116 )
1117
1118
1119 def main():
1120 """
1121 Main entry point for module execution
1122
1123 :returns: the result form module invocation
1124 """
1125 module = AnsibleModule(
1126 argument_spec=Ospf_interfacesArgs.argument_spec,
1127 mutually_exclusive=[["config", "running_config"]],
1128 required_if=[
1129 ["state", "merged", ["config"]],
1130 ["state", "replaced", ["config"]],
1131 ["state", "overridden", ["config"]],
1132 ["state", "rendered", ["config"]],
1133 ["state", "parsed", ["running_config"]],
1134 ],
1135 supports_check_mode=True,
1136 )
1137
1138 result = Ospf_interfaces(module).execute_module()
1139 module.exit_json(**result)
1140
1141
1142 if __name__ == "__main__":
1143 main()