Debian Codegraph @

ansible_collections/cisco/iosxr/plugins/modules/iosxr_logging_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_logging_global
9 """
10
11 from __future__ import absolute_import, division, print_function
12
13
14 __metaclass__ = type
15
16 DOCUMENTATION = """
17 module: iosxr_logging_global
18 version_added: 2.4.0
19 short_description: Resource module to configure logging.
20 description: This module manages the logging attributes of Cisco IOSXR network devices
21 notes:
22 - Tested against IOSXR 7.0.2.
23 - This module works with connection C(network_cli).
24 author: Ashwini Mhatre (@amhatre)
25 options:
26 config:
27 description: A dictionary of logging options.
28 type: dict
29 suboptions:
30 archive:
31 description: logging to a persistent device(disk/harddisk)
32 type: dict
33 suboptions:
34 device:
35 type: str
36 description: Configure the archive device
37 archive_length:
38 type: int
39 description: The maximum no of weeks of log to maintain.
40 archive_size:
41 type: int
42 description: The total size of the archive.
43 file_size:
44 type: int
45 description: The maximum file size for a single log file..
46 frequency:
47 type: str
48 description: The collection interval for logs.
49 choices: ["daily", "weekly"]
50 severity: &severity
51 description: Logging severity level
52 type: str
53 choices:
54 - alerts
55 - critical
56 - debugging
57 - emergencies
58 - errors
59 - informational
60 - notifications
61 - warnings
62 threshold:
63 type: int
64 description: Threshold percent <1-99>.
65 buffered:
66 description: Set buffered logging parameters
67 type: dict
68 suboptions:
69 size: &size
70 description: Logging buffer size
71 type: int
72 severity: *severity
73 discriminator: &discriminator
74 description: Establish MD-Buffer association
75 type: list
76 elements: dict
77 suboptions:
78 match_params:
79 type: str
80 description: Set match/no-match discriminator.
81 choices: ["match1", "match2", "match3", "nomatch1", "nomatch2", "nomatch3"]
82 name:
83 type: str
84 description: discriminator name.
85 console:
86 description: Set console logging parameters
87 type: dict
88 suboptions:
89 state: &state
90 description: Enable or disable logging.
91 type: str
92 choices: [ "enabled", "disabled" ]
93 severity: &severity1
94 description: Logging severity level
95 type: str
96 choices:
97 - alerts
98 - critical
99 - debugging
100 - emergencies
101 - errors
102 - informational
103 - notifications
104 - warning
105 discriminator: *discriminator
106 correlator:
107 description: Configure properties of the event correlator
108 type: dict
109 suboptions:
110 buffer_size:
111 type: int
112 description: Configure size of the correlator buffer.
113 rules:
114 type: list
115 elements: dict
116 description: Configure a specified correlation rule.
117 suboptions:
118 rule_name:
119 type: str
120 description: name of rule.
121 rule_type:
122 type: str
123 choices: ["stateful", "nonstateful"]
124 description: type of rule - stateful or nonstateful.
125 timeout:
126 type: int
127 description: Specify timeout.
128 timeout_rootcause:
129 type: int
130 description: Specify timeout for root-cause.
131 context_correlation:
132 type: bool
133 description: Specify enable correlation on context.
134 reissue_nonbistate:
135 type: bool
136 description: Specify reissue of non-bistate alarms on parent clear.This option is allowed for the rules whose type is stateful.
137 reparent:
138 type: bool
139 description: Specify reparent of alarm on parent clear.This option is allowed for the rules whose type is stateful.
140 rule_sets:
141 type: list
142 elements: dict
143 description: Configure a specified correlation ruleset.
144 suboptions:
145 name:
146 type: str
147 description: Name of the ruleset
148 rulename:
149 type: list
150 elements: str
151 description: Name of the rule
152 events:
153 type: dict
154 description: Configure event monitoring parameters.
155 suboptions:
156 buffer_size:
157 type: int
158 description: Set size of the local event buffer.
159 display_location:
160 type: bool
161 description: Include alarm source location in message text.
162 filter_match:
163 type: list
164 elements: str
165 description: Configure filter.
166 severity: *severity
167 threshold:
168 type: int
169 description: Capacity alarm threshold.
170 facility:
171 description: Facility parameter for syslog messages
172 type: str
173 choices:
174 - auth
175 - cron
176 - daemon
177 - kern
178 - local0
179 - local1
180 - local2
181 - local3
182 - local4
183 - local5
184 - local6
185 - local7
186 - lpr
187 - mail
188 - news
189 - sys10
190 - sys11
191 - sys12
192 - sys13
193 - sys14
194 - sys9
195 - syslog
196 - user
197 - uucp
198 files:
199 type: list
200 elements: dict
201 description: Set file logging.
202 suboptions:
203 name:
204 description: name of file.
205 type: str
206 path:
207 description: Set file path.
208 type: str
209 maxfilesize:
210 type: int
211 description: Set max file size.
212 severity:
213 description: Logging severity level
214 type: str
215 choices:
216 - alerts
217 - critical
218 - debugging
219 - emergencies
220 - errors
221 - info
222 - notifications
223 - warning
224 format:
225 type: bool
226 description: Enable to send the syslog message rfc5424 format .
227 history:
228 description: Configure syslog history table
229 type: dict
230 suboptions:
231 state: *state
232 size: *size
233 severity:
234 description: Logging severity level
235 type: str
236 choices:
237 - alerts
238 - critical
239 - debugging
240 - emergencies
241 - errors
242 - informational
243 - notifications
244 - warnings
245 hostnameprefix:
246 type: str
247 description: Hostname prefix to add on msgs to servers.
248 ipv4: &ip
249 description: Mark the dscp/precedence bit for ipv4 packets.
250 type: dict
251 suboptions:
252 dscp:
253 description: Set IP DSCP (DiffServ CodePoint).Please refer vendor document for valid entries.
254 type: str
255 precedence:
256 description: Set precedence Please refer vendor document for valid entries.
257 type: str
258 ipv6: *ip
259 localfilesize:
260 type: int
261 description: Set size of the local log file
262 monitor:
263 description: Set terminal line (monitor) logging parameters
264 type: dict
265 suboptions:
266 state: *state
267 discriminator: *discriminator
268 severity: *severity1
269 source_interfaces:
270 description: Specify interface for source address in logging transactions
271 type: list
272 elements: dict
273 suboptions:
274 interface:
275 description: Interface name with number
276 type: str
277 vrf:
278 description: VPN Routing/Forwarding instance name
279 type: str
280 suppress:
281 type: dict
282 description: Suppress logging behaviour.
283 suboptions:
284 apply_rule:
285 type: str
286 description: Apply suppression rule.
287 duplicates:
288 type: bool
289 description: Suppress consecutive duplicate messages.
290 tls_servers:
291 type: list
292 elements: dict
293 description: Secure server over tls.
294 suboptions:
295 name:
296 type: str
297 description: Name for the tls peer configuration.
298 severity: *severity
299 tls_hostname:
300 type: str
301 description: Name of the logging host.
302 trustpoint:
303 type: str
304 description: Name of the trustpoint configured.
305 vrf:
306 type: str
307 description: name of vrf.
308 trap:
309 description: Set syslog server logging level
310 type: dict
311 suboptions:
312 state: *state
313 severity: *severity1
314 hosts:
315 description: Set syslog server IP address and parameters
316 type: list
317 elements: dict
318 suboptions:
319 severity:
320 description: Logging severity level
321 type: str
322 choices:
323 - alerts
324 - critical
325 - debugging
326 - emergencies
327 - error
328 - info
329 - notifications
330 - warning
331 host:
332 description: IPv4/Ipv6 address or hostname of the syslog server
333 type: str
334 port:
335 description: Set <0-65535> non-default Port.
336 type: str
337 default: default
338 vrf:
339 description: Set VRF option
340 type: str
341 default: default
342 running_config:
343 description:
344 - This option is used only with state I(parsed).
345 - The value of this option should be the output received from the IOS device by
346 executing the command B(show running-config | include logging).
347 - The state I(parsed) reads the configuration from C(running_config) option and
348 transforms it into Ansible structured data as per the resource module's argspec
349 and the value is then returned in the I(parsed) key within the result.
350 type: str
351 state:
352 choices:
353 - merged
354 - replaced
355 - overridden
356 - deleted
357 - gathered
358 - parsed
359 - rendered
360 default: merged
361 description:
362 - The state the configuration should be left in
363 type: str
364 """
365 EXAMPLES = """
366 # Using merged
367 # -----------------
368 # Before state
369 # RP/0/0/CPU0:10#show running-config logging
370 # Thu Feb 4 09:38:36.245 UTC
371 # % No such configuration item(s)
372 # RP/0/0/CPU0:10#
373 #
374 #
375 - name: Merge the provided configuration with the existing running configuration
376 cisco.iosxr.iosxr_logging_global:
377 config:
378 buffered:
379 size: 2097152
380 severity: warnings
381 correlator:
382 buffer_size: 1024
383 events:
384 display_location: true
385 files:
386 - maxfilesize: '1024'
387 name: test
388 path: test
389 severity: info
390 hostnameprefix: test
391 hosts:
392 - host: 1.1.1.1
393 port: default
394 severity: critical
395 vrf: default
396 ipv4:
397 dscp: af11
398 localfilesize: 1024
399 monitor:
400 severity: errors
401 source_interfaces:
402 - interface: GigabitEthernet0/0/0/0
403 vrf: test
404 tls_servers:
405 - name: test
406 tls_hostname: test2
407 trustpoint: test2
408 vrf: test
409 trap:
410 severity: informational
411 state: merged
412 #
413 #
414 # After state:
415 # -------------------------------------------
416 # RP/0/0/CPU0:10#show running-config logging
417 # Tue Jul 20 18:09:18.491 UTC
418 # logging tls-server test
419 # vrf test
420 # trustpoint test2
421 # tls-hostname test2
422 # !
423 # logging file test path test maxfilesize 1024 severity info
424 # logging ipv4 dscp af11
425 # logging trap informational
426 # logging events display-location
427 # logging monitor errors
428 # logging buffered 2097152
429 # logging buffered warnings
430 # logging 1.1.1.1 vrf default severity critical port default
431 # logging correlator buffer-size 1024
432 # logging localfilesize 1024
433 # logging source-interface GigabitEthernet0/0/0/0 vrf test
434 # logging hostnameprefix test
435 # ------------------------------------------------
436 # Module execution
437 #
438 # "after": {
439 # "buffered": {
440 # "severity": "errors"
441 # },
442 # "correlator": {
443 # "buffer_size": 1024
444 # },
445 # "files": [
446 # {
447 # "maxfilesize": "1024",
448 # "name": "test",
449 # "path": "test1",
450 # "severity": "info"
451 # }
452 # ],
453 # "hostnameprefix": "test1",
454 # "hosts": [
455 # {
456 # "host": "1.1.1.3",
457 # "port": "default",
458 # "severity": "critical",
459 # "vrf": "default"
460 # }
461 # ],
462 # "ipv6": {
463 # "dscp": "af11"
464 # },
465 # "localfilesize": 1024,
466 # "source_interfaces": [
467 # {
468 # "interface": "GigabitEthernet0/0/0/0",
469 # "vrf": "test1"
470 # }
471 # ],
472 # "tls_servers": [
473 # {
474 # "name": "test",
475 # "tls_hostname": "test2",
476 # "trustpoint": "test",
477 # "vrf": "test"
478 # }
479 # ]
480 # },
481 # "before": {},
482 # "changed": true,
483 # "commands": [
484 # "logging buffered errors",
485 # "logging correlator buffer-size 1024",
486 # "logging hostnameprefix test1",
487 # "logging ipv6 dscp af11",
488 # "logging localfilesize 1024",
489 # "logging trap disable",
490 # "logging monitor disable",
491 # "logging history disable",
492 # "logging console disable",
493 # "logging 1.1.1.3 vrf default severity critical port default",
494 # "logging file test path test1 maxfilesize 1024 severity info",
495 # "logging source-interface GigabitEthernet0/0/0/0 vrf test1",
496 # "logging tls-server test tls-hostname test2",
497 # "logging tls-server test trustpoint test",
498 # "logging tls-server test vrf test"
499 # ],
500 # "invocation": {
501 # "module_args": {
502 # "config": {
503 # "archive": null,
504 # "buffered": {
505 # "discriminator": null,
506 # "severity": "errors",
507 # "size": null
508 # },
509 # "console": {
510 # "discriminator": null,
511 # "severity": null,
512 # "state": "disabled"
513 # },
514 # "correlator": {
515 # "buffer_size": 1024,
516 # "rule_set": null,
517 # "rules": null
518 # },
519 # "events": null,
520 # "facility": null,
521 # "files": [
522 # {
523 # "maxfilesize": "1024",
524 # "name": "test",
525 # "path": "test1",
526 # "severity": "info"
527 # }
528 # ],
529 # "format": null,
530 # "history": {
531 # "severity": null,
532 # "size": null,
533 # "state": "disabled"
534 # },
535 # "hostnameprefix": "test1",
536 # "hosts": [
537 # {
538 # "host": "1.1.1.3",
539 # "port": "default",
540 # "severity": "critical",
541 # "vrf": "default"
542 # }
543 # ],
544 # "ipv4": null,
545 # "ipv6": {
546 # "dscp": "af11",
547 # "precedence": null
548 # },
549 # "localfilesize": 1024,
550 # "monitor": {
551 # "discriminator": null,
552 # "severity": null,
553 # "state": "disabled"
554 # },
555 # "source_interfaces": [
556 # {
557 # "interface": "GigabitEthernet0/0/0/0",
558 # "vrf": "test1"
559 # }
560 # ],
561 # "suppress": null,
562 # "tls_servers": [
563 # {
564 # "name": "test",
565 # "severity": null,
566 # "tls_hostname": "test2",
567 # "trustpoint": "test",
568 # "vrf": "test"
569 # }
570 # ],
571 # "trap": {
572 # "severity": null,
573 # "state": "disabled"
574 # }
575 # },
576 # "running_config": null,
577 # "state": "merged"
578 # }
579 # }
580 # }
581 #
582 # Using replaced:
583 # -----------------------------------------------------------
584 #
585 # Before state
586 # RP/0/0/CPU0:10#show running-config logging
587 # Tue Jul 20 18:09:18.491 UTC
588 # logging tls-server test
589 # vrf test
590 # trustpoint test2
591 # tls-hostname test2
592 # !
593 # logging file test path test maxfilesize 1024 severity info
594 # logging ipv4 dscp af11
595 # logging trap informational
596 # logging events display-location
597 # logging monitor errors
598 # logging buffered 2097152
599 # logging buffered warnings
600 # logging 1.1.1.1 vrf default severity critical port default
601 # logging correlator buffer-size 1024
602 # logging localfilesize 1024
603 # logging source-interface GigabitEthernet0/0/0/0 vrf test
604 # logging hostnameprefix test
605 # -----------------------------------------------------------
606 #
607 - name: Replace BGP configuration with provided configuration
608 cisco.iosxr.iosxr_logging_global:
609 state: replaced
610 config:
611 buffered:
612 severity: errors
613 correlator:
614 buffer_size: 1024
615 files:
616 - maxfilesize: '1024'
617 name: test
618 path: test1
619 severity: info
620 hostnameprefix: test1
621 hosts:
622 - host: 1.1.1.3
623 port: default
624 severity: critical
625 vrf: default
626 ipv6:
627 dscp: af11
628 localfilesize: 1024
629 monitor:
630 severity: errors
631 tls_servers:
632 - name: test
633 tls_hostname: test2
634 trustpoint: test
635 vrf: test
636 trap:
637 severity: critical
638 #
639 # After state:
640 # RP/0/0/CPU0:10#show running-config logging
641 # Tue Jul 20 18:31:51.709 UTC
642 # logging tls-server test
643 # vrf test
644 # trustpoint test
645 # tls-hostname test2
646 # !
647 # logging file test path test1 maxfilesize 1024 severity info
648 # logging ipv6 dscp af11
649 # logging trap critical
650 # logging monitor errors
651 # logging buffered errors
652 # logging 1.1.1.3 vrf default severity critical port default
653 # logging correlator buffer-size 1024
654 # logging localfilesize 1024
655 # logging hostnameprefix test1
656 # -----------------------------------------------------------------
657 #
658 # Module Execution:
659 # "after": {
660 # "buffered": {
661 # "severity": "errors"
662 # },
663 # "correlator": {
664 # "buffer_size": 1024
665 # },
666 # "files": [
667 # {
668 # "maxfilesize": "1024",
669 # "name": "test",
670 # "path": "test1",
671 # "severity": "info"
672 # }
673 # ],
674 # "hostnameprefix": "test1",
675 # "hosts": [
676 # {
677 # "host": "1.1.1.3",
678 # "port": "default",
679 # "severity": "critical",
680 # "vrf": "default"
681 # }
682 # ],
683 # "ipv6": {
684 # "dscp": "af11"
685 # },
686 # "localfilesize": 1024,
687 # "monitor": {
688 # "severity": "errors"
689 # },
690 # "tls_servers": [
691 # {
692 # "name": "test",
693 # "tls_hostname": "test2",
694 # "trustpoint": "test",
695 # "vrf": "test"
696 # }
697 # ],
698 # "trap": {
699 # "severity": "critical"
700 # }
701 # },
702 # "before": {
703 # "buffered": {
704 # "severity": "warnings",
705 # "size": 2097152
706 # },
707 # "correlator": {
708 # "buffer_size": 1024
709 # },
710 # "events": {
711 # "display_location": true
712 # },
713 # "files": [
714 # {
715 # "maxfilesize": "1024",
716 # "name": "test",
717 # "path": "test",
718 # "severity": "info"
719 # }
720 # ],
721 # "hostnameprefix": "test",
722 # "hosts": [
723 # {
724 # "host": "1.1.1.1",
725 # "port": "default",
726 # "severity": "critical",
727 # "vrf": "default"
728 # }
729 # ],
730 # "ipv4": {
731 # "dscp": "af11"
732 # },
733 # "localfilesize": 1024,
734 # "monitor": {
735 # "severity": "errors"
736 # },
737 # "source_interfaces": [
738 # {
739 # "interface": "GigabitEthernet0/0/0/0",
740 # "vrf": "test"
741 # }
742 # ],
743 # "tls_servers": [
744 # {
745 # "name": "test",
746 # "tls_hostname": "test2",
747 # "trustpoint": "test2",
748 # "vrf": "test"
749 # }
750 # ],
751 # "trap": {
752 # "severity": "informational"
753 # }
754 # },
755 # "changed": true,
756 # "commands": [
757 # "no logging buffered 2097152",
758 # "no logging events display-location",
759 # "no logging ipv4 dscp af11",
760 # "no logging 1.1.1.1 vrf default severity critical port default",
761 # "no logging source-interface GigabitEthernet0/0/0/0 vrf test",
762 # "logging buffered errors",
763 # "logging hostnameprefix test1",
764 # "logging ipv6 dscp af11",
765 # "logging trap critical",
766 # "logging 1.1.1.3 vrf default severity critical port default",
767 # "logging file test path test1 maxfilesize 1024 severity info",
768 # "logging tls-server test trustpoint test"
769 # ],
770 #
771 #
772 #
773 # Using deleted:
774 # -----------------------------------------------------------
775 # Before state:
776 # RP/0/0/CPU0:10#show running-config logging
777 # Tue Jul 20 18:09:18.491 UTC
778 # logging tls-server test
779 # vrf test
780 # trustpoint test2
781 # tls-hostname test2
782 # !
783 # logging file test path test maxfilesize 1024 severity info
784 # logging ipv4 dscp af11
785 # logging trap informational
786 # logging events display-location
787 # logging monitor errors
788 # logging buffered 2097152
789 # logging buffered warnings
790 # logging 1.1.1.1 vrf default severity critical port default
791 # logging correlator buffer-size 1024
792 # logging localfilesize 1024
793 # logging source-interface GigabitEthernet0/0/0/0 vrf test
794 # logging hostnameprefix test
795 #
796 # -----------------------------------------------------------
797 - name: Delete given logging_global configuration
798 cisco.iosxr.iosxr_logging_global:
799 state: deleted
800 #
801 # After state:
802 # RP/0/0/CPU0:10#show running-config
803 #
804 # -------------------------------------------------------------
805 # Module Execution:
806 #
807 # "after": {},
808 # "before": {
809 # "buffered": {
810 # "severity": "warnings",
811 # "size": 2097152
812 # },
813 # "correlator": {
814 # "buffer_size": 1024
815 # },
816 # "events": {
817 # "display_location": true
818 # },
819 # "files": [
820 # {
821 # "maxfilesize": "1024",
822 # "name": "test",
823 # "path": "test",
824 # "severity": "info"
825 # }
826 # ],
827 # "hostnameprefix": "test",
828 # "hosts": [
829 # {
830 # "host": "1.1.1.1",
831 # "port": "default",
832 # "severity": "critical",
833 # "vrf": "default"
834 # }
835 # ],
836 # "ipv4": {
837 # "dscp": "af11"
838 # },
839 # "localfilesize": 1024,
840 # "monitor": {
841 # "severity": "errors"
842 # },
843 # "source_interfaces": [
844 # {
845 # "interface": "GigabitEthernet0/0/0/0",
846 # "vrf": "test"
847 # }
848 # ],
849 # "tls_servers": [
850 # {
851 # "name": "test",
852 # "tls_hostname": "test2",
853 # "trustpoint": "test2",
854 # "vrf": "test"
855 # }
856 # ],
857 # "trap": {
858 # "severity": "informational"
859 # }
860 # },
861 # "changed": true,
862 # "commands": [
863 # "no logging buffered 2097152",
864 # "no logging buffered warnings",
865 # "no logging correlator buffer-size 1024",
866 # "no logging events display-location",
867 # "no logging hostnameprefix test",
868 # "no logging ipv4 dscp af11",
869 # "no logging localfilesize 1024",
870 # "no logging monitor errors",
871 # "no logging trap informational",
872 # "no logging 1.1.1.1 vrf default severity critical port default",
873 # "no logging file test path test maxfilesize 1024 severity info",
874 # "no logging source-interface GigabitEthernet0/0/0/0 vrf test",
875 # "no logging tls-server test"
876 # ],
877 # "invocation": {
878 # "module_args": {
879 # "config": null,
880 # "running_config": null,
881 # "state": "deleted"
882 # }
883 # }
884 #
885 #
886 #
887 # using gathered:
888 # ------------------------------------------------------------
889 # Before state:
890 # RP/0/0/CPU0:10#show running-config logging
891 # Tue Jul 20 18:09:18.491 UTC
892 # logging tls-server test
893 # vrf test
894 # trustpoint test2
895 # tls-hostname test2
896 # !
897 # logging file test path test maxfilesize 1024 severity info
898 # logging ipv4 dscp af11
899 # logging trap informational
900 # logging events display-location
901 # logging monitor errors
902 # logging buffered 2097152
903 # logging buffered warnings
904 # logging 1.1.1.1 vrf default severity critical port default
905 # logging correlator buffer-size 1024
906 # logging localfilesize 1024
907 # logging source-interface GigabitEthernet0/0/0/0 vrf test
908 # logging hostnameprefix test
909 #
910 #
911 - name: Gather iosxr_logging_global facts using gathered state
912 cisco.iosxr.iosxr_logging_global:
913 state: gathered
914 #
915 # -------------------------------------------------------------
916 # Module Execution:
917 #
918 # "changed": false,
919 # "gathered": {
920 # "buffered": {
921 # "severity": "warnings",
922 # "size": 2097152
923 # },
924 # "correlator": {
925 # "buffer_size": 1024
926 # },
927 # "events": {
928 # "display_location": true
929 # },
930 # "files": [
931 # {
932 # "maxfilesize": "1024",
933 # "name": "test",
934 # "path": "test",
935 # "severity": "info"
936 # }
937 # ],
938 # "hostnameprefix": "test",
939 # "hosts": [
940 # {
941 # "host": "1.1.1.1",
942 # "port": "default",
943 # "severity": "critical",
944 # "vrf": "default"
945 # }
946 # ],
947 # "ipv4": {
948 # "dscp": "af11"
949 # },
950 # "localfilesize": 1024,
951 # "monitor": {
952 # "severity": "errors"
953 # },
954 # "source_interfaces": [
955 # {
956 # "interface": "GigabitEthernet0/0/0/0",
957 # "vrf": "test"
958 # }
959 # ],
960 # "tls_servers": [
961 # {
962 # "name": "test",
963 # "tls_hostname": "test2",
964 # "trustpoint": "test2",
965 # "vrf": "test"
966 # }
967 # ],
968 # "trap": {
969 # "severity": "informational"
970 # }
971 # },
972 # "invocation": {
973 # "module_args": {
974 # "config": null,
975 # "running_config": null,
976 # "state": "gathered"
977 # }
978 # }
979 #
980 #
981 # Using parsed:
982 # ---------------------------------------------------------------
983 #
984 # parsed.cfg
985 #
986 # logging tls-server test
987 # vrf test
988 # trustpoint test2
989 # tls-hostname test2
990 # !
991 # logging file test path test maxfilesize 1024 severity info
992 # logging ipv4 dscp af11
993 # logging trap informational
994 # logging events display-location
995 # logging monitor errors
996 # logging buffered 2097152
997 # logging buffered warnings
998 # logging 1.1.1.1 vrf default severity critical port default
999 # logging correlator buffer-size 1024
1000 # logging localfilesize 1024
1001 # logging source-interface GigabitEthernet0/0/0/0 vrf test
1002 # logging hostnameprefix test
1003 #
1004 #
1005 - name: Parse externally provided Logging global config to agnostic model
1006 cisco.iosxr.iosxr_logging_global:
1007 running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}"
1008 state: parsed
1009 # ----------------------------------------------------------------
1010 # Module execution:
1011 # "changed": false,
1012 # "parsed": {
1013 # "buffered": {
1014 # "severity": "warnings",
1015 # "size": 2097152
1016 # },
1017 # "correlator": {
1018 # "buffer_size": 1024
1019 # },
1020 # "events": {
1021 # "display_location": true
1022 # },
1023 # "files": [
1024 # {
1025 # "maxfilesize": "1024",
1026 # "name": "test",
1027 # "path": "test",
1028 # "severity": "info"
1029 # }
1030 # ],
1031 # "hostnameprefix": "test",
1032 # "hosts": [
1033 # {
1034 # "host": "1.1.1.1",
1035 # "port": "default",
1036 # "severity": "critical",
1037 # "vrf": "default"
1038 # }
1039 # ],
1040 # "ipv4": {
1041 # "dscp": "af11"
1042 # },
1043 # "localfilesize": 1024,
1044 # "monitor": {
1045 # "severity": "errors"
1046 # },
1047 # "source_interfaces": [
1048 # {
1049 # "interface": "GigabitEthernet0/0/0/0",
1050 # "vrf": "test"
1051 # }
1052 # ],
1053 # "tls_servers": [
1054 # {
1055 # "name": "test",
1056 # "tls_hostname": "test2",
1057 # "trustpoint": "test2",
1058 # "vrf": "test"
1059 # }
1060 # ],
1061 # "trap": {
1062 # "severity": "informational"
1063 # }
1064 # }
1065 #
1066 #
1067 # Using rendered:
1068 # ----------------------------------------------------------------------------
1069 - name: >-
1070 Render platform specific configuration lines with state rendered (without
1071 connecting to the device)
1072 cisco.iosxr.iosxr_logging_global:
1073 state: rendered
1074 config:
1075 buffered:
1076 size: 2097152
1077 severity: warnings
1078 correlator:
1079 buffer_size: 1024
1080 events:
1081 display_location: true
1082 files:
1083 - maxfilesize: '1024'
1084 name: test
1085 path: test
1086 severity: info
1087 hostnameprefix: test
1088 hosts:
1089 - host: 1.1.1.1
1090 port: default
1091 severity: critical
1092 vrf: default
1093 ipv4:
1094 dscp: af11
1095 localfilesize: 1024
1096 monitor:
1097 severity: errors
1098 source_interfaces:
1099 - interface: GigabitEthernet0/0/0/0
1100 vrf: test
1101 tls_servers:
1102 - name: test
1103 tls_hostname: test2
1104 trustpoint: test2
1105 vrf: test
1106 trap:
1107 severity: informational
1108 # ----------------------------------------------------------------
1109 # Module Execution:
1110 # "rendered": [
1111 # "logging buffered errors",
1112 # "logging correlator buffer-size 1024",
1113 # "logging hostnameprefix test1",
1114 # "logging ipv6 dscp af11",
1115 # "logging localfilesize 1024",
1116 # "logging trap disable",
1117 # "logging monitor disable",
1118 # "logging history disable",
1119 # "logging console disable",
1120 # "logging 1.1.1.3 vrf default severity critical port default",
1121 # "logging file test path test1 maxfilesize 1024 severity info",
1122 # "logging source-interface GigabitEthernet0/0/0/0 vrf test1",
1123 # "logging tls-server test tls-hostname test2",
1124 # "logging tls-server test trustpoint test",
1125 # "logging tls-server test vrf test"
1126 # ]
1127 #
1128 # Using overridden:
1129 # ---------------------------------------------------------------------------------
1130 # Before state:
1131 # RP/0/0/CPU0:10#show running-config logging
1132 # Tue Jul 20 18:09:18.491 UTC
1133 # logging tls-server test
1134 # vrf test
1135 # trustpoint test2
1136 # tls-hostname test2
1137 # !
1138 # logging file test path test maxfilesize 1024 severity info
1139 # logging ipv4 dscp af11
1140 # logging trap informational
1141 # logging events display-location
1142 # logging monitor errors
1143 # logging buffered 2097152
1144 # logging buffered warnings
1145 # logging 1.1.1.1 vrf default severity critical port default
1146 # logging correlator buffer-size 1024
1147 # logging localfilesize 1024
1148 # logging source-interface GigabitEthernet0/0/0/0 vrf test
1149 # logging hostnameprefix test
1150 #
1151 # -----------------------------------------------------------
1152 #
1153 - name: Overridde logging global configuration with provided configuration
1154 cisco.iosxr.iosxr_logging_global:
1155 state: overridden
1156 config:
1157 buffered:
1158 severity: errors
1159 correlator:
1160 buffer_size: 1024
1161 files:
1162 - maxfilesize: '1024'
1163 name: test
1164 path: test1
1165 severity: info
1166 hostnameprefix: test1
1167 hosts:
1168 - host: 1.1.1.3
1169 port: default
1170 severity: critical
1171 vrf: default
1172 ipv6:
1173 dscp: af11
1174 localfilesize: 1024
1175 monitor:
1176 severity: errors
1177 tls_servers:
1178 - name: test
1179 tls_hostname: test2
1180 trustpoint: test
1181 vrf: test
1182 trap:
1183 severity: critical
1184 #
1185 # After state:
1186 # RP/0/0/CPU0:10#show running-config logging
1187 # Tue Jul 20 18:31:51.709 UTC
1188 # logging tls-server test
1189 # vrf test
1190 # trustpoint test
1191 # tls-hostname test2
1192 # !
1193 # logging file test path test1 maxfilesize 1024 severity info
1194 # logging ipv6 dscp af11
1195 # logging trap critical
1196 # logging monitor errors
1197 # logging buffered errors
1198 # logging 1.1.1.3 vrf default severity critical port default
1199 # logging correlator buffer-size 1024
1200 # logging localfilesize 1024
1201 # logging hostnameprefix test1
1202 # -----------------------------------------------------------------
1203 #
1204 # Module Execution:
1205 # "after": {
1206 # "buffered": {
1207 # "severity": "errors"
1208 # },
1209 # "correlator": {
1210 # "buffer_size": 1024
1211 # },
1212 # "files": [
1213 # {
1214 # "maxfilesize": "1024",
1215 # "name": "test",
1216 # "path": "test1",
1217 # "severity": "info"
1218 # }
1219 # ],
1220 # "hostnameprefix": "test1",
1221 # "hosts": [
1222 # {
1223 # "host": "1.1.1.3",
1224 # "port": "default",
1225 # "severity": "critical",
1226 # "vrf": "default"
1227 # }
1228 # ],
1229 # "ipv6": {
1230 # "dscp": "af11"
1231 # },
1232 # "localfilesize": 1024,
1233 # "monitor": {
1234 # "severity": "errors"
1235 # },
1236 # "tls_servers": [
1237 # {
1238 # "name": "test",
1239 # "tls_hostname": "test2",
1240 # "trustpoint": "test",
1241 # "vrf": "test"
1242 # }
1243 # ],
1244 # "trap": {
1245 # "severity": "critical"
1246 # }
1247 # },
1248 # "before": {
1249 # "buffered": {
1250 # "severity": "warnings",
1251 # "size": 2097152
1252 # },
1253 # "correlator": {
1254 # "buffer_size": 1024
1255 # },
1256 # "events": {
1257 # "display_location": true
1258 # },
1259 # "files": [
1260 # {
1261 # "maxfilesize": "1024",
1262 # "name": "test",
1263 # "path": "test",
1264 # "severity": "info"
1265 # }
1266 # ],
1267 # "hostnameprefix": "test",
1268 # "hosts": [
1269 # {
1270 # "host": "1.1.1.1",
1271 # "port": "default",
1272 # "severity": "critical",
1273 # "vrf": "default"
1274 # }
1275 # ],
1276 # "ipv4": {
1277 # "dscp": "af11"
1278 # },
1279 # "localfilesize": 1024,
1280 # "monitor": {
1281 # "severity": "errors"
1282 # },
1283 # "source_interfaces": [
1284 # {
1285 # "interface": "GigabitEthernet0/0/0/0",
1286 # "vrf": "test"
1287 # }
1288 # ],
1289 # "tls_servers": [
1290 # {
1291 # "name": "test",
1292 # "tls_hostname": "test2",
1293 # "trustpoint": "test2",
1294 # "vrf": "test"
1295 # }
1296 # ],
1297 # "trap": {
1298 # "severity": "informational"
1299 # }
1300 # },
1301 # "changed": true,
1302 # "commands": [
1303 # "no logging buffered 2097152",
1304 # "no logging events display-location",
1305 # "no logging ipv4 dscp af11",
1306 # "no logging 1.1.1.1 vrf default severity critical port default",
1307 # "no logging source-interface GigabitEthernet0/0/0/0 vrf test",
1308 # "logging buffered errors",
1309 # "logging hostnameprefix test1",
1310 # "logging ipv6 dscp af11",
1311 # "logging trap critical",
1312 # "logging 1.1.1.3 vrf default severity critical port default",
1313 # "logging file test path test1 maxfilesize 1024 severity info",
1314 # "logging tls-server test trustpoint test"
1315 # ],
1316 #
1317 """
1318
1319 RETURN = """
1320 before:
1321 description: The configuration prior to the module execution.
1322 returned: when state is I(merged), I(replaced), I(overridden), I(deleted) or I(purged)
1323 type: dict
1324 sample: >
1325 This output will always be in the same format as the
1326 module argspec.
1327 after:
1328 description: The resulting configuration after module execution.
1329 returned: when changed
1330 type: dict
1331 sample: >
1332 This output will always be in the same format as the
1333 module argspec.
1334 commands:
1335 description: The set of commands pushed to the remote device.
1336 returned: when state is I(merged), I(replaced), I(overridden), I(deleted) or I(purged)
1337 type: list
1338 sample:
1339 - "logging file test path test1 maxfilesize 1024 severity info"
1340 - "logging ipv6 dscp af11"
1341 - "logging trap critical"
1342 - "logging monitor errors"
1343 - "logging buffered errors"
1344 - "logging 1.1.1.3 vrf default severity critical port default"
1345 rendered:
1346 description: The provided configuration in the task rendered in device-native format (offline).
1347 returned: when state is I(rendered)
1348 type: list
1349 sample:
1350 - "logging buffered errors"
1351 - "logging correlator buffer-size 1024"
1352 - "logging hostnameprefix test1"
1353 - "logging ipv6 dscp af11"
1354 - "logging localfilesize 1024"
1355 - "logging trap disable"
1356 - "logging monitor disable"
1357 - "logging history disable"
1358 - "logging console disable"
1359 gathered:
1360 description: Facts about the network resource gathered from the remote device as structured data.
1361 returned: when state is I(gathered)
1362 type: list
1363 sample: >
1364 This output will always be in the same format as the
1365 module argspec.
1366 parsed:
1367 description: The device native config provided in I(running_config) option parsed into structured data as per module argspec.
1368 returned: when state is I(parsed)
1369 type: list
1370 sample: >
1371 This output will always be in the same format as the
1372 module argspec.
1373 """
1374
1375 from ansible.module_utils.basic import AnsibleModule
1376
1377 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.argspec.logging_global.logging_global import (
1378 Logging_globalArgs,
1379 )
1380 from ansible_collections.cisco.iosxr.plugins.module_utils.network.iosxr.config.logging_global.logging_global import (
1381 Logging_global,
1382 )
1383
1384
1385 def main():
1386 """
1387 Main entry point for module execution
1388
1389 :returns: the result form module invocation
1390 """
1391 module = AnsibleModule(
1392 argument_spec=Logging_globalArgs.argument_spec,
1393 mutually_exclusive=[["config", "running_config"]],
1394 required_if=[
1395 ["state", "merged", ["config"]],
1396 ["state", "replaced", ["config"]],
1397 ["state", "overridden", ["config"]],
1398 ["state", "rendered", ["config"]],
1399 ["state", "parsed", ["running_config"]],
1400 ],
1401 supports_check_mode=True,
1402 )
1403
1404 result = Logging_global(module).execute_module()
1405 module.exit_json(**result)
1406
1407
1408 if __name__ == "__main__":
1409 main()