Debian Codegraph @

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

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 # Copyright 2021 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_ntp_global
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 ---
18 module: iosxr_ntp_global
19 short_description: Resource module to configure NTP.
20 description: This module configures and manages the attributes of ntp on Cisco
21 IOSXR platforms.
22 version_added: 2.5.0
23 author: Ashwini Mhatre (@amhatre)
24 notes:
25 - Tested against IOSXR 7.0.2.
26 - This module works with connection C(network_cli).
27 options:
28 config:
29 description: A dictionary of ntp options
30 type: dict
31 suboptions:
32 access_group:
33 description: Control NTP access
34 type: dict
35 suboptions:
36 ipv4: &ipv4
37 type: dict
38 description: Configure IPv4 access
39 suboptions:
40 peer: &peer
41 type: str
42 description: Provide full access
43 query_only: &query_only
44 type: str
45 description: Allow only control queries.
46 serve: &serve
47 type: str
48 description: Provide server and query access.
49 serve_only: &serve_only
50 type: str
51 description: Provide only server access.
52 ipv6: &ipv6
53 type: dict
54 description: Configure IPv6 access
55 suboptions:
56 peer: *peer
57 query_only: *query_only
58 serve: *serve
59 serve_only: *serve_only
60 vrfs:
61 type: list
62 elements: dict
63 description: Specify non-default VRF.
64 suboptions:
65 name:
66 type: str
67 description: Specify non-default VRF.
68 ipv4: *ipv4
69 ipv6: *ipv6
70 authenticate:
71 description: Authenticate time sources
72 type: bool
73 authentication_keys:
74 description: Authentication key for trusted time sources
75 type: list
76 elements: dict
77 suboptions:
78 id:
79 description: <1-65535> Key number
80 type: int
81 key:
82 description: Authentication key.
83 type: str
84 encryption:
85 description: Type of key encrypted or clear-text.
86 type: bool
87 broadcastdelay:
88 type: int
89 description: Estimated round-trip delay in microseconds.
90 drift:
91 type: dict
92 description: Drift(cisco-support)
93 suboptions:
94 aging_time:
95 type: int
96 description: Aging time in hours.
97 file:
98 description: File for drift values.
99 type: str
100 interfaces:
101 type: list
102 elements: dict
103 description: Configure NTP on an interface.
104 suboptions:
105 name:
106 type: str
107 description: Name of the interface.
108 vrf:
109 type: str
110 description: Name of the vrf.
111 broadcast_client:
112 type: bool
113 description: Listen to NTP broadcasts
114 broadcast_destination:
115 type: str
116 description: Configure broadcast destination address.
117 broadcast_key:
118 type: int
119 description: Broadcast key number.
120 broadcast_version:
121 type: int
122 description: <2-4> NTP version number.
123 multicast_key:
124 type: int
125 description: Configure multicast authentication key.
126 multicast_ttl:
127 type: int
128 description: Configure TTL to use.
129 multicast_client:
130 type: str
131 description: Configure multicast client
132 multicast_destination:
133 type: str
134 description: Configure multicast destination
135 multicast_version:
136 type: int
137 description: <2-4> NTP version number.
138 ipv4: &ip
139 description: Mark the dscp/precedence bit for ipv4 packets.
140 type: dict
141 suboptions:
142 dscp:
143 description: Set IP DSCP (DiffServ CodePoint).Please refer vendor document for valid entries.
144 type: str
145 precedence:
146 description: Set precedence Please refer vendor document for valid entries.
147 type: str
148 choices: [ "critical", "flash", "flash-override", "immediate", "internet", "network", "priority", "routine" ]
149 ipv6: *ip
150 log_internal_sync:
151 type: bool
152 description: Logs internal synchronization changes.
153 master:
154 description: Act as NTP master clock
155 type: dict
156 suboptions:
157 stratum:
158 description: Use NTP as clock source with stratum number <1-15>
159 type: int
160 max_associations:
161 type: int
162 description: <0-4294967295> Number of associations.
163 passive:
164 type: bool
165 description: Enable the passive associations.
166 trusted_keys:
167 type: list
168 elements: dict
169 description: list of Key numbers for trusted time sources.
170 suboptions:
171 key_id:
172 type: int
173 description: Key numbers for trusted time sources.
174 update_calendar:
175 type: bool
176 description: Periodically update calendar with NTP time.
177 source_interface:
178 type: str
179 description: Configure default interface.
180 source_vrfs:
181 type: list
182 elements: dict
183 description: Configure default interface.
184 suboptions:
185 name:
186 type: str
187 description: Name of source interface.
188 vrf:
189 type: str
190 description: vrf name.
191 servers:
192 description: Configure NTP server.
193 type: list
194 elements: dict
195 suboptions:
196 vrf: &vrf
197 description: vrf name.
198 type: str
199 server: &host
200 description: Hostname or A.B.C.D or A:B:C:D:E:F:G:H.
201 type: str
202 required: True
203 burst: &burst
204 description: Use burst mode.
205 type: bool
206 iburst: &iburst
207 description: Use initial burst mode.
208 type: bool
209 key_id: &key
210 description: SConfigure peer authentication key
211 type: int
212 source: &source
213 description: Interface for source address.
214 type: str
215 maxpoll: &maxpoll
216 description: configure Maximum poll interval.
217 type: int
218 minpoll: &minpoll
219 description: configure Minimum poll interval.
220 type: int
221 prefer: &prefer
222 description: Prefer this peer when possible
223 type: bool
224 version: &version
225 description: NTP version.
226 type: int
227 peers:
228 description: Configure NTP peer.
229 type: list
230 elements: dict
231 suboptions:
232 vrf: *vrf
233 peer: *host
234 burst: *burst
235 iburst: *iburst
236 key_id: *key
237 source: *source
238 maxpoll: *maxpoll
239 minpoll: *minpoll
240 prefer: *prefer
241 version: *version
242 running_config:
243 description:
244 - This option is used only with state I(parsed).
245 - The value of this option should be the output received from the IOSXR device by
246 executing the command B(show running-config ntp).
247 - The state I(parsed) reads the configuration from C(running_config) option and
248 transforms it into Ansible structured data as per the resource module's argspec
249 and the value is then returned in the I(parsed) key within the result.
250 type: str
251 state:
252 description:
253 - The state the configuration should be left in.
254 type: str
255 choices:
256 - deleted
257 - merged
258 - overridden
259 - replaced
260 - gathered
261 - rendered
262 - parsed
263 default: merged
264 """
265
266 EXAMPLES = """
267 # Using state: merged
268 # Before state:
269 # -------------
270 # RP/0/0/CPU0:10#show running-config ntp
271 # --------------------- EMPTY -----------------
272 # Merged play:
273 # ------------
274 - name: Merge the provided configuration with the existing running configuration
275 cisco.iosxr.iosxr_ntp_global:
276 config:
277 access_group:
278 ipv4:
279 peer: PeerAcl1
280 query_only: QueryOnlyAcl1
281 serve: ServeAcl1
282 serve_only: ServeOnlyAcl1
283 vrfs:
284 - ipv4:
285 peer: PeerAcl3
286 serve: ServeAcl2
287 name: siteA
288 authenticate: true
289 broadcastdelay: 1
290 drift:
291 aging_time: 0
292 file: apphost
293 interfaces:
294 - name: GigabitEthernet0/0/0/0
295 multicast_client: 224.0.0.8
296 multicast_destination: 224.0.0.8
297 broadcast_client: true
298 ipv4:
299 dscp: af11
300 ipv6:
301 precedence: routine
302 log_internal_sync: true
303 master: 1
304 max_associations: 10
305 passive: true
306 peers:
307 - iburst: true
308 peer: 192.0.2.1
309 vrf: siteC
310 servers:
311 - burst: true
312 server: 192.0.2.2
313 vrf: siteD
314 source: GigabitEthernet0/0/0/0
315 source_vrfs:
316 - name: GigabitEthernet0/0/0/0
317 vrf: siteE
318 trusted_keys:
319 - key_id: 1
320 update_calendar: true
321 # Commands Fired:
322 # ------------
323 # "commands": [
324 # "ntp peer vrf siteC 192.0.2.1 iburst ",
325 # "ntp server vrf siteD 192.0.2.2 burst ",
326 # "ntp trusted-key 1",
327 # "ntp interface GigabitEthernet0/0/0/0 broadcast client",
328 # "ntp interface GigabitEthernet0/0/0/0 multicast destination 224.0.0.8",
329 # "ntp interface GigabitEthernet0/0/0/0 multicast client 224.0.0.8",
330 # "ntp vrf siteE source GigabitEthernet0/0/0/0",
331 # "ntp access-group vrf siteA ipv4 serve ServeAcl2",
332 # "ntp access-group vrf siteA ipv4 peer PeerAcl3",
333 # "ntp access-group ipv4 peer PeerAcl1",
334 # "ntp access-group ipv4 serve ServeAcl1",
335 # "ntp access-group ipv4 serve-only ServeOnlyAcl1",
336 # "ntp access-group ipv4 query-only QueryOnlyAcl1",
337 # "ntp authenticate",
338 # "ntp log-internal-sync",
339 # "ntp broadcastdelay 1",
340 # "ntp drift aging time 0",
341 # "ntp drift file apphost",
342 # "ntp ipv4 dscp af11",
343 # "ntp ipv6 precedence routine",
344 # "ntp max-associations 10",
345 # "ntp master 1",
346 # "ntp passive",
347 # "ntp update-calendar",
348 # "ntp source GigabitEthernet0/0/0/0"
349 # ],
350 # After state:
351 # ------------
352 # RP/0/0/CPU0:10#show running-config ntp
353 # ntp
354 # max-associations 10
355 # interface GigabitEthernet0/0/0/0
356 # broadcast client
357 # multicast client 224.0.0.8
358 # multicast destination 224.0.0.8
359 # !
360 # authenticate
361 # trusted-key 1
362 # ipv4 dscp af11
363 # ipv6 precedence routine
364 # peer vrf siteC 192.0.2.1 iburst
365 # server vrf siteD 192.0.2.2 burst
366 # drift file apphost
367 # drift aging time 0
368 # master 1
369 # access-group vrf siteA ipv4 peer PeerAcl3
370 # access-group vrf siteA ipv4 serve ServeAcl2
371 # access-group ipv4 peer PeerAcl1
372 # access-group ipv4 serve ServeAcl1
373 # access-group ipv4 serve-only ServeOnlyAcl1
374 # access-group ipv4 query-only QueryOnlyAcl1
375 # source vrf siteE GigabitEthernet0/0/0/0
376 # source GigabitEthernet0/0/0/0
377 # passive
378 # broadcastdelay 1
379 # update-calendar
380 # log-internal-sync
381 # !
382 # Using state: deleted
383 # Before state:
384 # -------------
385 # RP/0/0/CPU0:10#show running-config ntp
386 # ntp
387 # max-associations 10
388 # interface GigabitEthernet0/0/0/0
389 # broadcast client
390 # multicast client 224.0.0.8
391 # multicast destination 224.0.0.8
392 # !
393 # authenticate
394 # trusted-key 1
395 # ipv4 dscp af11
396 # ipv6 precedence routine
397 # peer vrf siteC 192.0.2.1 iburst
398 # server vrf siteD 192.0.2.2 burst
399 # drift file apphost
400 # drift aging time 0
401 # master 1
402 # access-group vrf siteA ipv4 peer PeerAcl3
403 # access-group vrf siteA ipv4 serve ServeAcl2
404 # access-group ipv4 peer PeerAcl1
405 # access-group ipv4 serve ServeAcl1
406 # access-group ipv4 serve-only ServeOnlyAcl1
407 # access-group ipv4 query-only QueryOnlyAcl1
408 # source vrf siteE GigabitEthernet0/0/0/0
409 # source GigabitEthernet0/0/0/0
410 # passive
411 # broadcastdelay 1
412 # update-calendar
413 # log-internal-sync
414 # !
415 # Deleted play:
416 # -------------
417 - name: Remove all existing configuration
418 cisco.iosxr.iosxr_ntp_global:
419 state: deleted
420 # Commands Fired:
421 # ---------------
422 # "commands": [
423 # "no ntp peer vrf siteC 192.0.2.1 iburst ",
424 # "no ntp server vrf siteD 192.0.2.2 burst ",
425 # "no ntp trusted-key 1",
426 # "no ntp interface GigabitEthernet0/0/0/0",
427 # "no ntp vrf siteE source GigabitEthernet0/0/0/0",
428 # "no ntp access-group vrf siteA ipv4 serve ServeAcl2",
429 # "no ntp access-group vrf siteA ipv4 peer PeerAcl3",
430 # "no ntp access-group ipv4 peer PeerAcl1",
431 # "no ntp access-group ipv4 serve ServeAcl1",
432 # "no ntp access-group ipv4 serve-only ServeOnlyAcl1",
433 # "no ntp access-group ipv4 query-only QueryOnlyAcl1",
434 # "no ntp authenticate",
435 # "no ntp log-internal-sync",
436 # "no ntp broadcastdelay 1",
437 # "no ntp drift aging time 0",
438 # "no ntp drift file apphost",
439 # "no ntp ipv4 dscp af11",
440 # "no ntp ipv6 precedence routine",
441 # "no ntp max-associations 10",
442 # "no ntp master 1",
443 # "no ntp passive",
444 # "no ntp update-calendar",
445 # "no ntp source GigabitEthernet0/0/0/0"
446 # ],
447 # After state:
448 # ------------
449 # RP/0/0/CPU0:10#show running-config ntp
450 # --------------------- EMPTY -----------------
451 # Using state: overridden
452 # Before state:
453 # -------------
454 # RP/0/0/CPU0:10#show running-config ntp
455 # ntp
456 # max-associations 10
457 # interface GigabitEthernet0/0/0/0
458 # broadcast client
459 # multicast client 224.0.0.8
460 # multicast destination 224.0.0.8
461 # !
462 # authenticate
463 # trusted-key 1
464 # ipv4 dscp af11
465 # ipv6 precedence routine
466 # peer vrf siteC 192.0.2.1 iburst
467 # server vrf siteD 192.0.2.2 burst
468 # drift file apphost
469 # drift aging time 0
470 # master 1
471 # access-group vrf siteA ipv4 peer PeerAcl3
472 # access-group vrf siteA ipv4 serve ServeAcl2
473 # access-group ipv4 peer PeerAcl1
474 # access-group ipv4 serve ServeAcl1
475 # access-group ipv4 serve-only ServeOnlyAcl1
476 # access-group ipv4 query-only QueryOnlyAcl1
477 # source vrf siteE GigabitEthernet0/0/0/0
478 # source GigabitEthernet0/0/0/0
479 # passive
480 # broadcastdelay 1
481 # update-calendar
482 # log-internal-sync
483 # !
484 # Overridden play:
485 # ----------------
486 - name: Override BGP configuration with provided configuration
487 cisco.iosxr.iosxr_ntp_global:
488 state: overridden
489 config:
490 access_group:
491 ipv4:
492 peer: PeerAcl1
493 query_only: QueryOnlyAcl1
494 serve: ServeAcl4
495 serve_only: ServeOnlyAcl1
496 vrfs:
497 - ipv4:
498 peer: PeerAcl3
499 serve: ServeAcl2
500 name: siteA
501 authenticate: true
502 broadcastdelay: 1
503 drift:
504 aging_time: 0
505 file: apphost
506 interfaces:
507 - name: GigabitEthernet0/0/0/1
508 multicast_client: 224.0.0.8
509 multicast_destination: 224.0.0.8
510 broadcast_client: true
511 ipv4:
512 dscp: af12
513 ipv6:
514 precedence: routine
515 log_internal_sync: true
516 master: 1
517 max_associations: 10
518 passive: true
519 peers:
520 - iburst: true
521 peer: 192.0.2.3
522 vrf: siteC
523 servers:
524 - burst: true
525 server: 192.0.2.2
526 vrf: siteD
527 source: GigabitEthernet0/0/0/1
528 source_vrfs:
529 - name: GigabitEthernet0/0/0/0
530 vrf: siteE
531 trusted_keys:
532 - key_id: 1
533 update_calendar: true
534 # Commands Fired:
535 # ---------------
536 # "commands": [
537 # "no ntp peer vrf siteC 192.0.2.1 iburst ",
538 # "no ntp interface GigabitEthernet0/0/0/0",
539 # "ntp peer vrf siteC 192.0.2.3 iburst ",
540 # "ntp interface GigabitEthernet0/0/0/1 broadcast client",
541 # "ntp interface GigabitEthernet0/0/0/1 multicast destination 224.0.0.8",
542 # "ntp interface GigabitEthernet0/0/0/1 multicast client 224.0.0.8",
543 # "ntp access-group ipv4 serve ServeAcl4",
544 # "ntp ipv4 dscp af12",
545 # "ntp source GigabitEthernet0/0/0/1"
546 # ],
547 # After state:
548 # ------------
549 # RP/0/RP0/CPU0:ios#show running-config ntp
550 # Mon Sep 13 10:38:22.690 UTC
551 # ntp
552 # max-associations 10
553 # interface GigabitEthernet0/0/0/1
554 # broadcast client
555 # multicast client 224.0.0.8
556 # multicast destination 224.0.0.8
557 # !
558 # authentication-key 1 md5 encrypted testkey
559 # authenticate
560 # trusted-key 1
561 # ipv4 dscp af12
562 # ipv6 precedence routine
563 # peer vrf siteC 192.0.2.3 iburst
564 # server vrf siteD 192.0.2.2 burst
565 # drift file apphost
566 # drift aging time 0
567 # master 1
568 # access-group vrf siteA ipv4 peer PeerAcl3
569 # access-group vrf siteA ipv4 serve ServeAcl2
570 # access-group ipv4 peer PeerAcl1
571 # access-group ipv4 serve ServeAcl4
572 # access-group ipv4 serve-only ServeOnlyAcl1
573 # access-group ipv4 query-only QueryOnlyAcl1
574 # source vrf siteE GigabitEthernet0/0/0/0
575 # source GigabitEthernet0/0/0/1
576 # passive
577 # broadcastdelay 1
578 # update-calendar
579 # log-internal-sync
580 # !
581 #
582 # Using state: replaced
583 # Before state:
584 # -------------
585 # RP/0/0/CPU0:10#show running-config ntp
586 # ntp
587 # max-associations 10
588 # interface GigabitEthernet0/0/0/0
589 # broadcast client
590 # multicast client 224.0.0.8
591 # multicast destination 224.0.0.8
592 # !
593 # authenticate
594 # trusted-key 1
595 # ipv4 dscp af11
596 # ipv6 precedence routine
597 # peer vrf siteC 192.0.2.1 iburst
598 # server vrf siteD 192.0.2.2 burst
599 # drift file apphost
600 # drift aging time 0
601 # master 1
602 # access-group vrf siteA ipv4 peer PeerAcl3
603 # access-group vrf siteA ipv4 serve ServeAcl2
604 # access-group ipv4 peer PeerAcl1
605 # access-group ipv4 serve ServeAcl1
606 # access-group ipv4 serve-only ServeOnlyAcl1
607 # access-group ipv4 query-only QueryOnlyAcl1
608 # source vrf siteE GigabitEthernet0/0/0/0
609 # source GigabitEthernet0/0/0/0
610 # passive
611 # broadcastdelay 1
612 # update-calendar
613 # log-internal-sync
614 # !
615 # Replaced play:
616 # ----------------
617 - name: Replaced BGP configuration with provided configuration
618 cisco.iosxr.iosxr_ntp_global:
619 state: replaced
620 config:
621 access_group:
622 ipv4:
623 peer: PeerAcl1
624 query_only: QueryOnlyAcl1
625 serve: ServeAcl4
626 serve_only: ServeOnlyAcl1
627 vrfs:
628 - ipv4:
629 peer: PeerAcl3
630 serve: ServeAcl2
631 name: siteA
632 authenticate: true
633 broadcastdelay: 1
634 drift:
635 aging_time: 0
636 file: apphost
637 interfaces:
638 - name: GigabitEthernet0/0/0/1
639 multicast_client: 224.0.0.8
640 multicast_destination: 224.0.0.8
641 broadcast_client: true
642 ipv4:
643 dscp: af12
644 ipv6:
645 precedence: routine
646 log_internal_sync: true
647 master: 1
648 max_associations: 10
649 passive: true
650 peers:
651 - iburst: true
652 peer: 192.0.2.3
653 vrf: siteC
654 servers:
655 - burst: true
656 server: 192.0.2.2
657 vrf: siteD
658 source: GigabitEthernet0/0/0/1
659 source_vrfs:
660 - name: GigabitEthernet0/0/0/0
661 vrf: siteE
662 trusted_keys:
663 - key_id: 1
664 update_calendar: true
665 # Commands Fired:
666 # ---------------
667 # "commands": [
668 # "no ntp peer vrf siteC 192.0.2.1 iburst ",
669 # "no ntp interface GigabitEthernet0/0/0/0",
670 # "ntp peer vrf siteC 192.0.2.3 iburst ",
671 # "ntp interface GigabitEthernet0/0/0/1 broadcast client",
672 # "ntp interface GigabitEthernet0/0/0/1 multicast destination 224.0.0.8",
673 # "ntp interface GigabitEthernet0/0/0/1 multicast client 224.0.0.8",
674 # "ntp access-group ipv4 serve ServeAcl4",
675 # "ntp ipv4 dscp af12",
676 # "ntp source GigabitEthernet0/0/0/1"
677 # ],
678 # After state:
679 # ------------
680 # RP/0/RP0/CPU0:ios#show running-config ntp
681 # Mon Sep 13 10:38:22.690 UTC
682 # ntp
683 # max-associations 10
684 # interface GigabitEthernet0/0/0/1
685 # broadcast client
686 # multicast client 224.0.0.8
687 # multicast destination 224.0.0.8
688 # !
689 # authentication-key 1 md5 encrypted testkey
690 # authenticate
691 # trusted-key 1
692 # ipv4 dscp af12
693 # ipv6 precedence routine
694 # peer vrf siteC 192.0.2.3 iburst
695 # server vrf siteD 192.0.2.2 burst
696 # drift file apphost
697 # drift aging time 0
698 # master 1
699 # access-group vrf siteA ipv4 peer PeerAcl3
700 # access-group vrf siteA ipv4 serve ServeAcl2
701 # access-group ipv4 peer PeerAcl1
702 # access-group ipv4 serve ServeAcl4
703 # access-group ipv4 serve-only ServeOnlyAcl1
704 # access-group ipv4 query-only QueryOnlyAcl1
705 # source vrf siteE GigabitEthernet0/0/0/0
706 # source GigabitEthernet0/0/0/1
707 # passive
708 # broadcastdelay 1
709 # update-calendar
710 # log-internal-sync
711 # !
712 # Using state: gathered
713 # Before state:
714 # -------------
715 # RP/0/0/CPU0:10#show running-config ntp
716 # ntp
717 # max-associations 10
718 # interface GigabitEthernet0/0/0/0
719 # broadcast client
720 # multicast client 224.0.0.8
721 # multicast destination 224.0.0.8
722 # !
723 # authenticate
724 # trusted-key 1
725 # ipv4 dscp af11
726 # ipv6 precedence routine
727 # peer vrf siteC 192.0.2.1 iburst
728 # server vrf siteD 192.0.2.2 burst
729 # drift file apphost
730 # drift aging time 0
731 # master 1
732 # access-group vrf siteA ipv4 peer PeerAcl3
733 # access-group vrf siteA ipv4 serve ServeAcl2
734 # access-group ipv4 peer PeerAcl1
735 # access-group ipv4 serve ServeAcl1
736 # access-group ipv4 serve-only ServeOnlyAcl1
737 # access-group ipv4 query-only QueryOnlyAcl1
738 # source vrf siteE GigabitEthernet0/0/0/0
739 # source GigabitEthernet0/0/0/0
740 # passive
741 # broadcastdelay 1
742 # update-calendar
743 # log-internal-sync
744 # !
745 # Gathered play:
746 # --------------
747 - name: Gather listed ntp config
748 cisco.iosxr.iosxr_ntp_global:
749 state: gathered
750 # Module Execution Result:
751 # ------------------------
752 # "gathered":{
753 # "access_group": {
754 # "ipv4": {
755 # "peer": "PeerAcl1",
756 # "query_only": "QueryOnlyAcl1",
757 # "serve": "ServeAcl1",
758 # "serve_only": "ServeOnlyAcl1"
759 # },
760 # "vrfs": [
761 # {
762 # "ipv4": {
763 # "peer": "PeerAcl3",
764 # "serve": "ServeAcl2"
765 # },
766 # "name": "siteA"
767 # }
768 # ]
769 # },
770 # "authenticate": true,
771 # "broadcastdelay": 1,
772 # "drift": {
773 # "aging_time": 0,
774 # "file": "apphost"
775 # },
776 # "interfaces": [
777 # {
778 # "broadcast_client": true,
779 # "multicast_client": "224.0.0.8",
780 # "multicast_destination": "224.0.0.8",
781 # "name": "GigabitEthernet0/0/0/0"
782 # }
783 # ],
784 # "ipv4": {
785 # "dscp": "af11"
786 # },
787 # "ipv6": {
788 # "precedence": "routine"
789 # },
790 # "log_internal_sync": true,
791 # "master": 1,
792 # "max_associations": 10,
793 # "passive": true,
794 # "peers": [
795 # {
796 # "iburst": true,
797 # "peer": "192.0.2.1",
798 # "vrf": "siteC"
799 # }
800 # ],
801 # "servers": [
802 # {
803 # "burst": true,
804 # "server": "192.0.2.2",
805 # "vrf": "siteD"
806 # }
807 # ],
808 # "source": "GigabitEthernet0/0/0/0",
809 # "source_vrfs": [
810 # {
811 # "name": "GigabitEthernet0/0/0/0",
812 # "vrf": "siteE"
813 # }
814 # ],
815 # "trusted_keys": [
816 # {
817 # "key_id": 1
818 # }
819 # ],
820 # "update_calendar": true
821 # }
822 # Using state: rendered
823 # Rendered play:
824 # --------------
825 - name: >-
826 Render platform specific configuration lines with state rendered (without
827 connecting to the device)
828 cisco.iosxr.iosxr_ntp_global:
829 state: rendered
830 config:
831 access_group:
832 ipv4:
833 peer: PeerAcl1
834 query_only: QueryOnlyAcl1
835 serve: ServeAcl1
836 serve_only: ServeOnlyAcl1
837 vrfs:
838 - ipv4:
839 peer: PeerAcl3
840 serve: ServeAcl2
841 name: siteA
842 authenticate: true
843 broadcastdelay: 1
844 drift:
845 aging_time: 0
846 file: apphost
847 interfaces:
848 - name: GigabitEthernet0/0/0/0
849 multicast_client: 224.0.0.8
850 multicast_destination: 224.0.0.8
851 broadcast_client: true
852 ipv4:
853 dscp: af11
854 ipv6:
855 precedence: routine
856 log_internal_sync: true
857 master: 1
858 max_associations: 10
859 passive: true
860 peers:
861 - iburst: true
862 peer: 192.0.2.1
863 vrf: siteC
864 servers:
865 - burst: true
866 server: 192.0.2.2
867 vrf: siteD
868 source: GigabitEthernet0/0/0/0
869 source_vrfs:
870 - name: GigabitEthernet0/0/0/0
871 vrf: siteE
872 trusted_keys:
873 - key_id: 1
874 update_calendar: true
875 register: result
876 # Module Execution Result:
877 # ------------------------
878 # "rendered": [
879 # "ntp peer vrf siteC 192.0.2.1 iburst ",
880 # "ntp server vrf siteD 192.0.2.2 burst ",
881 # "ntp trusted-key 1",
882 # "ntp interface GigabitEthernet0/0/0/0 broadcast client",
883 # "ntp interface GigabitEthernet0/0/0/0 multicast destination 224.0.0.8",
884 # "ntp interface GigabitEthernet0/0/0/0 multicast client 224.0.0.8",
885 # "ntp vrf siteE source GigabitEthernet0/0/0/0",
886 # "ntp access-group vrf siteA ipv4 serve ServeAcl2",
887 # "ntp access-group vrf siteA ipv4 peer PeerAcl3",
888 # "ntp access-group ipv4 peer PeerAcl1",
889 # "ntp access-group ipv4 serve ServeAcl1",
890 # "ntp access-group ipv4 serve-only ServeOnlyAcl1",
891 # "ntp access-group ipv4 query-only QueryOnlyAcl1",
892 # "ntp authenticate",
893 # "ntp log-internal-sync",
894 # "ntp broadcastdelay 1",
895 # "ntp drift aging time 0",
896 # "ntp drift file apphost",
897 # "ntp ipv4 dscp af11",
898 # "ntp ipv6 precedence routine",
899 # "ntp max-associations 10",
900 # "ntp master 1",
901 # "ntp passive",
902 # "ntp update-calendar",
903 # "ntp source GigabitEthernet0/0/0/0"
904 # ],
905 # Using state: parsed
906 # File: parsed.cfg
907 # ----------------
908 # ntp
909 # max-associations 10
910 # interface GigabitEthernet0/0/0/0
911 # broadcast client
912 # multicast client 224.0.0.8
913 # multicast destination 224.0.0.8
914 # !
915 # authenticate
916 # trusted-key 1
917 # ipv4 dscp af11
918 # ipv6 precedence routine
919 # peer vrf siteC 192.0.2.1 iburst
920 # server vrf siteD 192.0.2.2 burst
921 # drift file apphost
922 # drift aging time 0
923 # master 1
924 # access-group vrf siteA ipv4 peer PeerAcl3
925 # access-group vrf siteA ipv4 serve ServeAcl2
926 # access-group ipv4 peer PeerAcl1
927 # access-group ipv4 serve ServeAcl1
928 # access-group ipv4 serve-only ServeOnlyAcl1
929 # access-group ipv4 query-only QueryOnlyAcl1
930 # source vrf siteE GigabitEthernet0/0/0/0
931 # source GigabitEthernet0/0/0/0
932 # passive
933 # broadcastdelay 1
934 # update-calendar
935 # log-internal-sync
936 # !
937 # Parsed play:
938 # ------------
939 - name: Parse the provided configuration with the existing running configuration
940 cisco.iosxr.iosxr_ntp_global:
941 running_config: "{{ lookup('file', 'parsed.cfg') }}"
942 state: parsed
943 # Module Execution Result:
944 # ------------------------
945 # "parsed":{
946 # "access_group": {
947 # "ipv4": {
948 # "peer": "PeerAcl1",
949 # "query_only": "QueryOnlyAcl1",
950 # "serve": "ServeAcl1",
951 # "serve_only": "ServeOnlyAcl1"
952 # },
953 # "vrfs": [
954 # {
955 # "ipv4": {
956 # "peer": "PeerAcl3",
957 # "serve": "ServeAcl2"
958 # },
959 # "name": "siteA"
960 # }
961 # ]
962 # },
963 # "authenticate": true,
964 # "broadcastdelay": 1,
965 # "drift": {
966 # "aging_time": 0,
967 # "file": "apphost"
968 # },
969 # "interfaces": [
970 # {
971 # "broadcast_client": true,
972 # "multicast_client": "224.0.0.8",
973 # "multicast_destination": "224.0.0.8",
974 # "name": "GigabitEthernet0/0/0/0"
975 # }
976 # ],
977 # "ipv4": {
978 # "dscp": "af11"
979 # },
980 # "ipv6": {
981 # "precedence": "routine"
982 # },
983 # "log_internal_sync": true,
984 # "master": 1,
985 # "max_associations": 10,
986 # "passive": true,
987 # "peers": [
988 # {
989 # "iburst": true,
990 # "peer": "192.0.2.1",
991 # "vrf": "siteC"
992 # }
993 # ],
994 # "servers": [
995 # {
996 # "burst": true,
997 # "server": "192.0.2.2",
998 # "vrf": "siteD"
999 # }
1000 # ],
1001 # "source": "GigabitEthernet0/0/0/0",
1002 # "source_vrfs": [
1003 # {
1004 # "name": "GigabitEthernet0/0/0/0",
1005 # "vrf": "siteE"
1006 # }
1007 # ],
1008 # "trusted_keys": [
1009 # {
1010 # "key_id": 1
1011 # }
1012 # ],
1013 # "update_calendar": true
1014 # }
1015 """
1016
1017 RETURN = """
1018 before:
1019 description: The configuration prior to the module execution.
1020 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1021 type: dict
1022 sample: >
1023 This output will always be in the same format as the
1024 module argspec.
1025 after:
1026 description: The resulting configuration after module execution.
1027 returned: when changed
1028 type: dict
1029 sample: >
1030 This output will always be in the same format as the
1031 module argspec.
1032 commands:
1033 description: The set of commands pushed to the remote device.
1034 returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged)
1035 type: list
1036 sample:
1037 - sample command 1
1038 - sample command 2
1039 - sample command 3
1040 rendered:
1041 description: The provided configuration in the task rendered in device-native format (offline).
1042 returned: when I(state) is C(rendered)
1043 type: list
1044 sample:
1045 - sample command 1
1046 - sample command 2
1047 - sample command 3
1048 gathered:
1049 description: Facts about the network resource gathered from the remote device as structured data.
1050 returned: when I(state) is C(gathered)
1051 type: list
1052 sample: >
1053 This output will always be in the same format as the
1054 module argspec.
1055 parsed:
1056 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1057 returned: when I(state) is C(parsed)
1058 type: list
1059 sample: >
1060 This output will always be in the same format as the
1061 module argspec.
1062 """
1063
1064 from ansible.module_utils.basic import AnsibleModule
1065
1066 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.ntp_global.ntp_global import (
1067 Ntp_globalArgs,
1068 )
1069 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.ntp_global.ntp_global import (
1070 Ntp_global,
1071 )
1072
1073
1074 def main():
1075 """
1076 Main entry point for module execution
1077
1078 :returns: the result form module invocation
1079 """
1080 module = AnsibleModule(
1081 argument_spec=Ntp_globalArgs.argument_spec,
1082 mutually_exclusive=[["config", "running_config"]],
1083 required_if=[
1084 ["state", "merged", ["config"]],
1085 ["state", "replaced", ["config"]],
1086 ["state", "overridden", ["config"]],
1087 ["state", "rendered", ["config"]],
1088 ["state", "parsed", ["running_config"]],
1089 ],
1090 supports_check_mode=True,
1091 )
1092
1093 result = Ntp_global(module).execute_module()
1094 module.exit_json(**result)
1095
1096
1097 if __name__ == "__main__":
1098 main()