cisco.iosxr.iosxr_logging_global 模块 – 用于配置日志的资源模块。

注意

此模块是 cisco.iosxr 集合(版本 10.2.2)的一部分。

如果您使用的是 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install cisco.iosxr

要在 playbook 中使用它,请指定:cisco.iosxr.iosxr_logging_global

cisco.iosxr 2.4.0 中的新增功能

概要

  • 此模块管理 Cisco IOSXR 网络设备的日志记录属性

参数

参数

注释

config

字典

日志记录选项的字典。

archive

字典

记录到持久设备(磁盘/硬盘)

archive_length

整数

要维护的最大日志周数。

archive_size

整数

存档的总大小。

device

字符串

配置存档设备

file_size

整数

单个日志文件的最大文件大小。

frequency

字符串

日志的收集间隔。

选择

  • "daily"

  • "weekly"

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warnings"

threshold

整数

阈值百分比 <1-99>。

buffered

字典

设置缓冲日志记录参数

discriminator

列表 / elements=字典

建立 MD-Buffer 关联

match_params

字符串

设置匹配/不匹配的鉴别器。

选择

  • "match1"

  • "match2"

  • "match3"

  • "nomatch1"

  • "nomatch2"

  • "nomatch3"

name

字符串

鉴别器名称。

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warnings"

size

整数

日志缓冲区大小

console

字典

设置控制台日志记录参数

discriminator

列表 / elements=字典

建立 MD-Buffer 关联

match_params

字符串

设置匹配/不匹配的鉴别器。

选择

  • "match1"

  • "match2"

  • "match3"

  • "nomatch1"

  • "nomatch2"

  • "nomatch3"

name

字符串

鉴别器名称。

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warning"

state

字符串

启用或禁用日志记录。

选择

  • "enabled"

  • "disabled"

correlator

字典

配置事件相关器的属性

buffer_size

整数

配置相关器缓冲区的大小。

rule_sets

列表 / elements=字典

配置指定的关联规则集。

name

字符串

规则集的名称

rulename

列表 / elements=字符串

规则的名称

rules

列表 / elements=字典

配置指定的关联规则。

context_correlation

布尔值

指定在上下文中启用关联。

选择

  • false

  • true

reissue_nonbistate

布尔值

指定在父项清除时重新发出非双稳态警报。此选项允许用于类型为有状态的规则。

选择

  • false

  • true

reparent

布尔值

指定在父项清除时重新设置警报的父项。此选项允许用于类型为有状态的规则。

选择

  • false

  • true

rule_name

字符串

规则的名称。

rule_type

字符串

规则的类型 - 有状态或无状态。

选择

  • "stateful"

  • "nonstateful"

timeout

整数

指定超时。

timeout_rootcause

整数

指定根本原因的超时。

events

字典

配置事件监视参数。

buffer_size

整数

设置本地事件缓冲区的大小。

display_location

布尔值

在消息文本中包含警报源位置。

选择

  • false

  • true

filter_match

列表 / elements=字符串

配置过滤器。

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warnings"

threshold

整数

容量警报阈值。

facility

字符串

syslog 消息的 Facility 参数

选择

  • "auth"

  • "cron"

  • "daemon"

  • "kern"

  • "local0"

  • "local1"

  • "local2"

  • "local3"

  • "local4"

  • "local5"

  • "local6"

  • "local7"

  • "lpr"

  • "mail"

  • "news"

  • "sys10"

  • "sys11"

  • "sys12"

  • "sys13"

  • "sys14"

  • "sys9"

  • "syslog"

  • "user"

  • "uucp"

files

列表 / elements=字典

设置文件日志记录。

maxfilesize

整数

设置最大文件大小。

name

字符串

文件名称。

path

字符串

设置文件路径。

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "info"

  • "notifications"

  • "warning"

format

布尔值

启用以发送 syslog 消息 rfc5424 格式。

选择

  • false

  • true

history

字典

配置 syslog 历史表

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warnings"

size

整数

日志缓冲区大小

state

字符串

启用或禁用日志记录。

选择

  • "enabled"

  • "disabled"

hostnameprefix

字符串

要添加到服务器消息中的主机名前缀。

hosts

列表 / elements=字典

设置 syslog 服务器 IP 地址和参数

host

字符串

syslog 服务器的 IPv4/Ipv6 地址或主机名

port

字符串

设置 <0-65535> 非默认端口。

默认值: "default"

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "error"

  • "info"

  • "notifications"

  • "warning"

vrf

字符串

设置 VRF 选项

默认值: "default"

ipv4

字典

为 ipv4 数据包标记 dscp/优先级位。

dscp

字符串

设置 IP DSCP(DiffServ 代码点)。请参考供应商文档以获取有效条目。

precedence

字符串

设置优先级。请参考供应商文档以获取有效条目。

ipv6

字典

为 ipv4 数据包标记 dscp/优先级位。

dscp

字符串

设置 IP DSCP(DiffServ 代码点)。请参考供应商文档以获取有效条目。

precedence

字符串

设置优先级。请参考供应商文档以获取有效条目。

localfilesize

整数

设置本地日志文件的大小

monitor

字典

设置终端线路(监视器)日志记录参数

discriminator

列表 / elements=字典

建立 MD-Buffer 关联

match_params

字符串

设置匹配/不匹配的鉴别器。

选择

  • "match1"

  • "match2"

  • "match3"

  • "nomatch1"

  • "nomatch2"

  • "nomatch3"

name

字符串

鉴别器名称。

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warning"

state

字符串

启用或禁用日志记录。

选择

  • "enabled"

  • "disabled"

source_interfaces

列表 / elements=字典

指定日志记录事务中源地址的接口

interface

字符串

带编号的接口名称

vrf

字符串

VPN 路由/转发实例名称

suppress

字典

禁止日志记录行为。

apply_rule

字符串

应用禁止规则。

duplicates

布尔值

禁止连续重复消息。

选择

  • false

  • true

tls_servers

列表 / elements=字典

通过 tls 保护服务器安全。

name

字符串

tls 对等配置的名称。

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warnings"

tls_hostname

字符串

日志主机的名称。

trustpoint

字符串

配置的信任点名称。

vrf

字符串

VRF 的名称。

陷阱

字典

设置 syslog 服务器日志级别

severity

字符串

日志严重级别

选择

  • "alerts"

  • "critical"

  • "debugging"

  • "emergencies"

  • "errors"

  • "informational"

  • "notifications"

  • "warning"

state

字符串

启用或禁用日志记录。

选择

  • "enabled"

  • "disabled"

running_config

字符串

此选项仅在状态为parsed时使用。

此选项的值应是通过执行命令 show running-config | include logging 从 IOS 设备接收到的输出。

状态parsedrunning_config 选项读取配置,并按照资源模块的 argspec 将其转换为 Ansible 结构化数据,然后将该值返回到结果中的 parsed 键中。

state

字符串

配置应保持的状态

选择

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "parsed"

  • "rendered"

备注

注意

  • 已针对 IOSXR 7.0.2 进行测试。

  • 此模块与连接 network_cli 配合使用。

示例

# Using merged
# -----------------
# Before state
# RP/0/0/CPU0:10#show running-config logging
# Thu Feb  4 09:38:36.245 UTC
# % No such configuration item(s)
# RP/0/0/CPU0:10#
#
#
- name: Merge the provided configuration with the existing running configuration
  cisco.iosxr.iosxr_logging_global:
    config:
      buffered:
        size: 2097152
        severity: warnings
      correlator:
        buffer_size: 1024
      events:
        display_location: true
      files:
        - maxfilesize: '1024'
          name: test
          path: test
          severity: info
      hostnameprefix: test
      hosts:
        - host: 1.1.1.1
          port: default
          severity: critical
          vrf: default
      ipv4:
        dscp: af11
      localfilesize: 1024
      monitor:
        severity: errors
      source_interfaces:
        - interface: GigabitEthernet0/0/0/0
          vrf: test
      tls_servers:
        - name: test
          tls_hostname: test2
          trustpoint: test2
          vrf: test
      trap:
        severity: informational
    state: merged
#
#
# After state:
# -------------------------------------------
# RP/0/0/CPU0:10#show running-config logging
# Tue Jul 20 18:09:18.491 UTC
# logging tls-server test
#  vrf test
#  trustpoint test2
#  tls-hostname test2
# !
# logging file test path test maxfilesize 1024 severity info
# logging ipv4 dscp af11
# logging trap informational
# logging events display-location
# logging monitor errors
# logging buffered 2097152
# logging buffered warnings
# logging 1.1.1.1 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging source-interface GigabitEthernet0/0/0/0 vrf test
# logging hostnameprefix test
# ------------------------------------------------
# Module execution
#
#     "after": {
#         "buffered": {
#             "severity": "errors"
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test1",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test1",
#         "hosts": [
#             {
#                 "host": "1.1.1.3",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv6": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "source_interfaces": [
#             {
#                 "interface": "GigabitEthernet0/0/0/0",
#                 "vrf": "test1"
#             }
#         ],
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test",
#                 "vrf": "test"
#             }
#         ]
#     },
#     "before": {},
#     "changed": true,
#     "commands": [
#         "logging buffered errors",
#         "logging correlator buffer-size 1024",
#         "logging hostnameprefix test1",
#         "logging ipv6 dscp af11",
#         "logging localfilesize 1024",
#         "logging trap disable",
#         "logging monitor disable",
#         "logging history disable",
#         "logging console disable",
#         "logging 1.1.1.3 vrf default severity critical port default",
#         "logging file test path test1 maxfilesize 1024 severity info",
#         "logging source-interface GigabitEthernet0/0/0/0 vrf test1",
#         "logging tls-server test tls-hostname test2",
#         "logging tls-server test trustpoint test",
#         "logging tls-server test vrf test"
#     ],
#     "invocation": {
#         "module_args": {
#             "config": {
#                 "archive": null,
#                 "buffered": {
#                     "discriminator": null,
#                     "severity": "errors",
#                     "size": null
#                 },
#                 "console": {
#                     "discriminator": null,
#                     "severity": null,
#                     "state": "disabled"
#                 },
#                 "correlator": {
#                     "buffer_size": 1024,
#                     "rule_set": null,
#                     "rules": null
#                 },
#                 "events": null,
#                 "facility": null,
#                 "files": [
#                     {
#                         "maxfilesize": "1024",
#                         "name": "test",
#                         "path": "test1",
#                         "severity": "info"
#                     }
#                 ],
#                 "format": null,
#                 "history": {
#                     "severity": null,
#                     "size": null,
#                     "state": "disabled"
#                 },
#                 "hostnameprefix": "test1",
#                 "hosts": [
#                     {
#                         "host": "1.1.1.3",
#                         "port": "default",
#                         "severity": "critical",
#                         "vrf": "default"
#                     }
#                 ],
#                 "ipv4": null,
#                 "ipv6": {
#                     "dscp": "af11",
#                     "precedence": null
#                 },
#                 "localfilesize": 1024,
#                 "monitor": {
#                     "discriminator": null,
#                     "severity": null,
#                     "state": "disabled"
#                 },
#                 "source_interfaces": [
#                     {
#                         "interface": "GigabitEthernet0/0/0/0",
#                         "vrf": "test1"
#                     }
#                 ],
#                 "suppress": null,
#                 "tls_servers": [
#                     {
#                         "name": "test",
#                         "severity": null,
#                         "tls_hostname": "test2",
#                         "trustpoint": "test",
#                         "vrf": "test"
#                     }
#                 ],
#                 "trap": {
#                     "severity": null,
#                     "state": "disabled"
#                 }
#             },
#             "running_config": null,
#             "state": "merged"
#         }
#     }
# }
#
# Using replaced:
# -----------------------------------------------------------
#
# Before state
# RP/0/0/CPU0:10#show running-config logging
# Tue Jul 20 18:09:18.491 UTC
# logging tls-server test
#  vrf test
#  trustpoint test2
#  tls-hostname test2
# !
# logging file test path test maxfilesize 1024 severity info
# logging ipv4 dscp af11
# logging trap informational
# logging events display-location
# logging monitor errors
# logging buffered 2097152
# logging buffered warnings
# logging 1.1.1.1 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging source-interface GigabitEthernet0/0/0/0 vrf test
# logging hostnameprefix test
# -----------------------------------------------------------
#
- name: Replace BGP configuration with provided configuration
  cisco.iosxr.iosxr_logging_global:
    state: replaced
    config:
      buffered:
        severity: errors
      correlator:
        buffer_size: 1024
      files:
        - maxfilesize: '1024'
          name: test
          path: test1
          severity: info
      hostnameprefix: test1
      hosts:
        - host: 1.1.1.3
          port: default
          severity: critical
          vrf: default
      ipv6:
        dscp: af11
      localfilesize: 1024
      monitor:
        severity: errors
      tls_servers:
        - name: test
          tls_hostname: test2
          trustpoint: test
          vrf: test
      trap:
        severity: critical
#
# After state:
# RP/0/0/CPU0:10#show running-config logging
# Tue Jul 20 18:31:51.709 UTC
# logging tls-server test
#  vrf test
#  trustpoint test
#  tls-hostname test2
# !
# logging file test path test1 maxfilesize 1024 severity info
# logging ipv6 dscp af11
# logging trap critical
# logging monitor errors
# logging buffered errors
# logging 1.1.1.3 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging hostnameprefix test1
# -----------------------------------------------------------------
#
# Module Execution:
# "after": {
#         "buffered": {
#             "severity": "errors"
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test1",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test1",
#         "hosts": [
#             {
#                 "host": "1.1.1.3",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv6": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "monitor": {
#             "severity": "errors"
#         },
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test",
#                 "vrf": "test"
#             }
#         ],
#         "trap": {
#             "severity": "critical"
#         }
#     },
#     "before": {
#         "buffered": {
#             "severity": "warnings",
#             "size": 2097152
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "events": {
#             "display_location": true
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test",
#         "hosts": [
#             {
#                 "host": "1.1.1.1",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv4": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "monitor": {
#             "severity": "errors"
#         },
#         "source_interfaces": [
#             {
#                 "interface": "GigabitEthernet0/0/0/0",
#                 "vrf": "test"
#             }
#         ],
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test2",
#                 "vrf": "test"
#             }
#         ],
#         "trap": {
#             "severity": "informational"
#         }
#     },
#     "changed": true,
#     "commands": [
#         "no logging buffered 2097152",
#         "no logging events display-location",
#         "no logging ipv4 dscp af11",
#         "no logging 1.1.1.1 vrf default severity critical port default",
#         "no logging source-interface GigabitEthernet0/0/0/0 vrf test",
#         "logging buffered errors",
#         "logging hostnameprefix test1",
#         "logging ipv6 dscp af11",
#         "logging trap critical",
#         "logging 1.1.1.3 vrf default severity critical port default",
#         "logging file test path test1 maxfilesize 1024 severity info",
#         "logging tls-server test trustpoint test"
#     ],
#
#
#
# Using deleted:
# -----------------------------------------------------------
# Before state:
# RP/0/0/CPU0:10#show running-config logging
# Tue Jul 20 18:09:18.491 UTC
# logging tls-server test
#  vrf test
#  trustpoint test2
#  tls-hostname test2
# !
# logging file test path test maxfilesize 1024 severity info
# logging ipv4 dscp af11
# logging trap informational
# logging events display-location
# logging monitor errors
# logging buffered 2097152
# logging buffered warnings
# logging 1.1.1.1 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging source-interface GigabitEthernet0/0/0/0 vrf test
# logging hostnameprefix test
#
# -----------------------------------------------------------
- name: Delete given logging_global configuration
  cisco.iosxr.iosxr_logging_global:
    state: deleted
#
# After state:
# RP/0/0/CPU0:10#show running-config
#
# -------------------------------------------------------------
# Module Execution:
#
# "after": {},
#     "before": {
#         "buffered": {
#             "severity": "warnings",
#             "size": 2097152
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "events": {
#             "display_location": true
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test",
#         "hosts": [
#             {
#                 "host": "1.1.1.1",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv4": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "monitor": {
#             "severity": "errors"
#         },
#         "source_interfaces": [
#             {
#                 "interface": "GigabitEthernet0/0/0/0",
#                 "vrf": "test"
#             }
#         ],
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test2",
#                 "vrf": "test"
#             }
#         ],
#         "trap": {
#             "severity": "informational"
#         }
#     },
#     "changed": true,
#     "commands": [
#         "no logging buffered 2097152",
#         "no logging buffered warnings",
#         "no logging correlator buffer-size 1024",
#         "no logging events display-location",
#         "no logging hostnameprefix test",
#         "no logging ipv4 dscp af11",
#         "no logging localfilesize 1024",
#         "no logging monitor errors",
#         "no logging trap informational",
#         "no logging 1.1.1.1 vrf default severity critical port default",
#         "no logging file test path test maxfilesize 1024 severity info",
#         "no logging source-interface GigabitEthernet0/0/0/0 vrf test",
#         "no logging tls-server test"
#     ],
#     "invocation": {
#         "module_args": {
#             "config": null,
#             "running_config": null,
#             "state": "deleted"
#         }
#     }
#
#
#
# using gathered:
# ------------------------------------------------------------
# Before state:
# RP/0/0/CPU0:10#show running-config logging
# Tue Jul 20 18:09:18.491 UTC
# logging tls-server test
#  vrf test
#  trustpoint test2
#  tls-hostname test2
# !
# logging file test path test maxfilesize 1024 severity info
# logging ipv4 dscp af11
# logging trap informational
# logging events display-location
# logging monitor errors
# logging buffered 2097152
# logging buffered warnings
# logging 1.1.1.1 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging source-interface GigabitEthernet0/0/0/0 vrf test
# logging hostnameprefix test
#
#
- name: Gather iosxr_logging_global facts using gathered state
  cisco.iosxr.iosxr_logging_global:
    state: gathered
#
# -------------------------------------------------------------
# Module Execution:
#
# "changed": false,
# "gathered": {
#         "buffered": {
#             "severity": "warnings",
#             "size": 2097152
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "events": {
#             "display_location": true
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test",
#         "hosts": [
#             {
#                 "host": "1.1.1.1",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv4": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "monitor": {
#             "severity": "errors"
#         },
#         "source_interfaces": [
#             {
#                 "interface": "GigabitEthernet0/0/0/0",
#                 "vrf": "test"
#             }
#         ],
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test2",
#                 "vrf": "test"
#             }
#         ],
#         "trap": {
#             "severity": "informational"
#         }
#     },
#     "invocation": {
#         "module_args": {
#             "config": null,
#             "running_config": null,
#             "state": "gathered"
#         }
# }
#
#
# Using parsed:
# ---------------------------------------------------------------
#
# parsed.cfg
#
# logging tls-server test
#  vrf test
#  trustpoint test2
#  tls-hostname test2
# !
# logging file test path test maxfilesize 1024 severity info
# logging ipv4 dscp af11
# logging trap informational
# logging events display-location
# logging monitor errors
# logging buffered 2097152
# logging buffered warnings
# logging 1.1.1.1 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging source-interface GigabitEthernet0/0/0/0 vrf test
# logging hostnameprefix test
#
#
- name: Parse externally provided Logging global config to agnostic model
  cisco.iosxr.iosxr_logging_global:
    running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}"
    state: parsed
# ----------------------------------------------------------------
# Module execution:
# "changed": false,
# "parsed": {
#         "buffered": {
#             "severity": "warnings",
#             "size": 2097152
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "events": {
#             "display_location": true
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test",
#         "hosts": [
#             {
#                 "host": "1.1.1.1",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv4": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "monitor": {
#             "severity": "errors"
#         },
#         "source_interfaces": [
#             {
#                 "interface": "GigabitEthernet0/0/0/0",
#                 "vrf": "test"
#             }
#         ],
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test2",
#                 "vrf": "test"
#             }
#         ],
#         "trap": {
#             "severity": "informational"
#         }
#     }
#
#
# Using rendered:
# ----------------------------------------------------------------------------
- name: >-
    Render platform specific configuration lines with state rendered (without
    connecting to the device)
  cisco.iosxr.iosxr_logging_global:
    state: rendered
    config:
      buffered:
        size: 2097152
        severity: warnings
      correlator:
        buffer_size: 1024
      events:
        display_location: true
      files:
        - maxfilesize: '1024'
          name: test
          path: test
          severity: info
      hostnameprefix: test
      hosts:
        - host: 1.1.1.1
          port: default
          severity: critical
          vrf: default
      ipv4:
        dscp: af11
      localfilesize: 1024
      monitor:
        severity: errors
      source_interfaces:
        - interface: GigabitEthernet0/0/0/0
          vrf: test
      tls_servers:
        - name: test
          tls_hostname: test2
          trustpoint: test2
          vrf: test
      trap:
        severity: informational
# ----------------------------------------------------------------
# Module Execution:
# "rendered": [
#         "logging buffered errors",
#         "logging correlator buffer-size 1024",
#         "logging hostnameprefix test1",
#         "logging ipv6 dscp af11",
#         "logging localfilesize 1024",
#         "logging trap disable",
#         "logging monitor disable",
#         "logging history disable",
#         "logging console disable",
#         "logging 1.1.1.3 vrf default severity critical port default",
#         "logging file test path test1 maxfilesize 1024 severity info",
#         "logging source-interface GigabitEthernet0/0/0/0 vrf test1",
#         "logging tls-server test tls-hostname test2",
#         "logging tls-server test trustpoint test",
#         "logging tls-server test vrf test"
#     ]
#
# Using overridden:
# ---------------------------------------------------------------------------------
# Before state:
# RP/0/0/CPU0:10#show running-config logging
# Tue Jul 20 18:09:18.491 UTC
# logging tls-server test
#  vrf test
#  trustpoint test2
#  tls-hostname test2
# !
# logging file test path test maxfilesize 1024 severity info
# logging ipv4 dscp af11
# logging trap informational
# logging events display-location
# logging monitor errors
# logging buffered 2097152
# logging buffered warnings
# logging 1.1.1.1 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging source-interface GigabitEthernet0/0/0/0 vrf test
# logging hostnameprefix test
#
# -----------------------------------------------------------
#
- name: Overridde logging global configuration with provided configuration
  cisco.iosxr.iosxr_logging_global:
    state: overridden
    config:
      buffered:
        severity: errors
      correlator:
        buffer_size: 1024
      files:
        - maxfilesize: '1024'
          name: test
          path: test1
          severity: info
      hostnameprefix: test1
      hosts:
        - host: 1.1.1.3
          port: default
          severity: critical
          vrf: default
      ipv6:
        dscp: af11
      localfilesize: 1024
      monitor:
        severity: errors
      tls_servers:
        - name: test
          tls_hostname: test2
          trustpoint: test
          vrf: test
      trap:
        severity: critical
#
# After state:
# RP/0/0/CPU0:10#show running-config logging
# Tue Jul 20 18:31:51.709 UTC
# logging tls-server test
#  vrf test
#  trustpoint test
#  tls-hostname test2
# !
# logging file test path test1 maxfilesize 1024 severity info
# logging ipv6 dscp af11
# logging trap critical
# logging monitor errors
# logging buffered errors
# logging 1.1.1.3 vrf default severity critical port default
# logging correlator buffer-size 1024
# logging localfilesize 1024
# logging hostnameprefix test1
# -----------------------------------------------------------------
#
# Module Execution:
# "after": {
#         "buffered": {
#             "severity": "errors"
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test1",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test1",
#         "hosts": [
#             {
#                 "host": "1.1.1.3",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv6": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "monitor": {
#             "severity": "errors"
#         },
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test",
#                 "vrf": "test"
#             }
#         ],
#         "trap": {
#             "severity": "critical"
#         }
#     },
#     "before": {
#         "buffered": {
#             "severity": "warnings",
#             "size": 2097152
#         },
#         "correlator": {
#             "buffer_size": 1024
#         },
#         "events": {
#             "display_location": true
#         },
#         "files": [
#             {
#                 "maxfilesize": "1024",
#                 "name": "test",
#                 "path": "test",
#                 "severity": "info"
#             }
#         ],
#         "hostnameprefix": "test",
#         "hosts": [
#             {
#                 "host": "1.1.1.1",
#                 "port": "default",
#                 "severity": "critical",
#                 "vrf": "default"
#             }
#         ],
#         "ipv4": {
#             "dscp": "af11"
#         },
#         "localfilesize": 1024,
#         "monitor": {
#             "severity": "errors"
#         },
#         "source_interfaces": [
#             {
#                 "interface": "GigabitEthernet0/0/0/0",
#                 "vrf": "test"
#             }
#         ],
#         "tls_servers": [
#             {
#                 "name": "test",
#                 "tls_hostname": "test2",
#                 "trustpoint": "test2",
#                 "vrf": "test"
#             }
#         ],
#         "trap": {
#             "severity": "informational"
#         }
#     },
#     "changed": true,
#     "commands": [
#         "no logging buffered 2097152",
#         "no logging events display-location",
#         "no logging ipv4 dscp af11",
#         "no logging 1.1.1.1 vrf default severity critical port default",
#         "no logging source-interface GigabitEthernet0/0/0/0 vrf test",
#         "logging buffered errors",
#         "logging hostnameprefix test1",
#         "logging ipv6 dscp af11",
#         "logging trap critical",
#         "logging 1.1.1.3 vrf default severity critical port default",
#         "logging file test path test1 maxfilesize 1024 severity info",
#         "logging tls-server test trustpoint test"
#     ],
#

返回值

常用返回值记录在此处,以下是此模块特有的字段

描述

after

字典

模块执行后的最终配置。

返回: 当发生更改时

示例: "此输出将始终与模块 argspec 的格式相同。\n"

before

字典

模块执行之前的配置。

返回: 当状态为 *merged*、*replaced*、*overridden*、*deleted* 或 *purged* 时

示例: "此输出将始终与模块 argspec 的格式相同。\n"

commands

列表 / elements=字符串

推送到远程设备的命令集。

返回: 当状态为 *merged*、*replaced*、*overridden*、*deleted* 或 *purged* 时

示例: ["logging file test path test1 maxfilesize 1024 severity info", "logging ipv6 dscp af11", "logging trap critical", "logging monitor errors", "logging buffered errors", "logging 1.1.1.3 vrf default severity critical port default"]

gathered

列表 / elements=字符串

从远程设备收集的关于网络资源的结构化数据的事实。

返回: 当状态为 *gathered* 时

示例: ["此输出将始终与模块 argspec 的格式相同。\n"]

parsed

列表 / elements=字符串

running_config 选项中提供的设备原生配置按照模块 argspec 解析为结构化数据。

返回: 当状态为 *parsed* 时

示例: ["此输出将始终与模块 argspec 的格式相同。\n"]

rendered

列表 / elements=字符串

任务中提供的配置以设备原生格式呈现(离线)。

返回: 当状态为 *rendered* 时

示例: ["logging buffered errors", "logging correlator buffer-size 1024", "logging hostnameprefix test1", "logging ipv6 dscp af11", "logging localfilesize 1024", "logging trap disable", "logging monitor disable", "logging history disable", "logging console disable"]

作者

  • Ashwini Mhatre (@amhatre)