cisco.ios.ios_logging_global 模块 – 用于配置日志记录的资源模块。
注意
此模块是 cisco.ios 集合(版本 9.0.3)的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install cisco.ios
。
要在 playbook 中使用它,请指定:cisco.ios.ios_logging_global
。
cisco.ios 2.2.0 中的新增功能
概要
此模块管理 Cisco IOS 网络设备的日志记录属性
参数
参数 |
注释 |
---|---|
日志记录选项的字典 |
|
设置缓冲日志记录参数 |
|
建立 MD-Buffer 关联 |
|
启用筛选日志记录 选项
|
|
日志记录严重级别 对于 ‘debugging’ 值,此属性不维护幂等性,因为此值未显示在 running-config 中。 选项
|
|
日志缓冲区大小 |
|
启用以 XML 格式记录到 XML 日志缓冲区 选项
|
|
启用 buginf 日志记录以进行调试 选项
|
|
设置 CNS 事件日志记录级别 选项
|
|
设置控制台日志记录参数 |
|
建立 MD-Buffer 关联 |
|
启用筛选日志记录 选项
|
|
日志记录严重级别 选项
|
|
启用以 XML 格式记录到 XML 日志缓冲区 选项
|
|
计数每个日志消息和时间戳上次出现的时间 选项
|
|
将分隔符附加到 syslog 消息 |
|
将分隔符附加到通过 TCP 传输的 syslog 消息 选项
|
|
创建或修改消息区分符 |
|
DMVPN 配置 |
|
以消息/分钟为单位的速率限制,默认值为 600 消息/分钟 (1-10000) |
|
设置 ESM 过滤器限制 |
|
允许/拒绝来自 ESM 过滤器的配置更改 选项
|
|
限制异常刷新输出的大小 (4096-2147483647) |
|
syslog 消息的设施参数 选项
|
|
指定日志筛选器 |
|
传递给筛选器模块的参数。 |
|
筛选器执行顺序 |
|
筛选器统一资源定位符 |
|
配置 syslog 历史记录表 |
|
日志记录严重级别 对于 ‘debugging’ 值,此属性不维护幂等性,因为此值未显示在 running-config 中。 选项
|
|
日志缓冲区大小 |
|
设置 syslog 服务器 IP 地址和参数 |
|
建立 MD-Buffer 关联 |
|
启用筛选日志记录 选项
|
|
syslog 服务器的 IP 地址 |
|
配置 IPv6 syslog 服务器 |
|
在 syslog 消息中包含会话序列号标签 选项
|
|
指定 syslog 消息会话 ID 标记 |
|
在会话 ID 标签中包含主机名 选项
|
|
在会话 ID 标签中包含自定义字符串 |
|
此服务器应仅接收来自编号流的消息 |
|
指定传输协议(默认值=UDP) |
|
传输控制协议 |
|
为此主机设置 IOS 防火墙审核日志记录 选项
|
|
建立 MD-Buffer 关联 |
|
启用筛选日志记录 选项
|
|
指定 TCP 端口号(默认值=601)(1 - 65535) |
|
在 syslog 消息中包含会话序列号标签 选项
|
|
指定 syslog 消息会话 ID 标记 |
|
在会话 ID 标签中包含主机名 选项
|
|
在会话 ID 标签中包含自定义字符串 |
|
此服务器应仅接收来自编号流的消息 |
|
启用以 XML 格式记录到 XML 日志缓冲区 选项
|
|
用户数据报协议 |
|
建立 MD-Buffer 关联 |
|
启用筛选日志记录 选项
|
|
指定 UDP 端口号(默认值=514)(1 - 65535) |
|
在 syslog 消息中包含会话序列号标签 选项
|
|
指定 syslog 消息会话 ID 标记 |
|
在会话 ID 标签中包含主机名 选项
|
|
在会话 ID 标签中包含自定义字符串 |
|
此服务器应仅接收来自编号流的消息 |
|
启用以 XML 格式记录到 XML 日志缓冲区 选项
|
|
设置 VRF 选项 |
|
启用以 XML 格式记录到 XML 日志缓冲区 选项
|
|
启用对所有已启用目标的日志记录 选项
|
|
配置日志消息以包含特定计数器值 选项
|
|
设置终端线路(监视器)日志记录参数 |
|
建立 MD-Buffer 关联 |
|
启用筛选日志记录 选项
|
|
日志记录严重级别 对于 ‘debugging’ 值,此属性不维护幂等性,因为此值未显示在 running-config 中。 选项
|
|
启用以 XML 格式记录到 XML 日志缓冲区 选项
|
|
将源 ID 添加到 syslog 消息 |
|
在会话 ID 标签中包含主机名 选项
|
|
在会话 ID 标签中包含自定义字符串 |
|
设置持久日志记录参数 |
|
设置写入持久存储的批处理大小 (4096-2142715904) |
|
设置单个日志文件的大小 (4096-2142715904) |
|
立即将日志条目写入存储(不缓冲)。 选项
|
|
当 show logging [persistent] 激活时通知。 选项
|
|
消除对 logging-persistent 文件的操作。 选项
|
|
设置用于写入日志消息的磁盘空间 (4096-2142715904) |
|
设置日志持久性的阈值 |
|
存储日志消息的 URL |
|
防火墙配置 |
|
(0-3600)以秒为单位的值,默认值为 30 秒。 |
|
设置记录器消息队列大小 |
|
(100-2147483647)设置新的队列大小 |
|
(100-2147483647)设置新的队列大小 |
|
(100-2147483647)设置新的队列大小 |
|
设置每秒消息限制 |
|
每秒 (1-10000) 条消息 选项
|
|
每秒 (1-10000) 条消息 选项
|
|
此严重性或更高的消息 选项
|
|
每秒 (1-10000) 条消息 |
|
设置重新加载日志记录级别 |
|
消息数量 (1-4294967295) |
|
日志记录严重级别 对于 ‘debugging’ 值,此属性不维护幂等性,因为此值未显示在 running-config 中。 选项
|
|
启用在首次配置时为 syslog 服务器发送 ARP 请求 选项
|
|
设置用于发送 snmp trap 的 syslog 级别 选项
|
|
在日志记录事务中指定源地址的接口 |
|
带编号的接口名称 |
|
VPN 路由/转发实例名称 |
|
设置 syslog 服务器日志记录级别 选项
|
|
启用在启用特权模式时记录用户信息 选项
|
|
此选项仅与状态parsed一起使用。 此选项的值应该是执行命令 show running-config | include logging 从 IOS 设备收到的输出。 状态 parsed 从 |
|
配置应保持的状态 使用状态 replaced,对于运行配置中列出的日志配置,它们可以有多组命令,但如果不在任务中,则会被否定。 使用状态 overridden,运行配置中所有但不在任务中的配置都会被否定。 请参考示例了解更多详情。 选项
|
注意
注意
已在 CML 上针对 Cisco IOSXE 17.3 版本进行了测试。
此模块与连接
network_cli
一起使用。请参阅 https://docs.ansible.org.cn/ansible/latest/network/user_guide/platform_ios.htmlCisco IOS 网络设备的默认配置会阻碍剧本的幂等行为
示例
# Using state: merged
# Before state:
# -------------
# router-ios#show running-config | section logging
# no logging exception
# no logging buffered
# no logging reload
# no logging rate-limit
# no logging console
# no logging monitor
# no logging cns-events
# no logging trap
- name: Apply the provided configuration
cisco.ios.ios_logging_global:
config:
buffered:
severity: notifications
size: 5099
xml: true
console:
severity: critical
xml: true
facility: local5
hosts:
- hostname: 172.16.1.12
- hostname: 172.16.1.11
xml: true
- hostname: 172.16.1.10
filtered: true
stream: 10
- hostname: 172.16.1.13
transport:
tcp:
port: 514
monitor:
severity: warnings
message_counter: log
snmp_trap:
- errors
trap: errors
userinfo: true
policy_firewall:
rate_limit: 10
logging_on: enable
exception: 4099
dmvpn:
rate_limit: 10
cns_events: warnings
state: merged
# Commands Fired:
# ---------------
# "commands": [
# "logging buffered xml 5099 notifications",
# "logging cns-events warnings",
# "logging console xml critical",
# "logging dmvpn rate-limit 10",
# "logging exception 4099",
# "logging facility local5",
# "logging monitor warnings",
# "logging on",
# "logging policy-firewall rate-limit 10",
# "logging trap errors",
# "logging userinfo",
# "logging host 172.16.1.12",
# "logging host 172.16.1.10 filtered stream 10",
# "logging host 172.16.1.13 transport tcp port 514",
# "logging message-counter log",
# "logging snmp-trap errors",
# "logging host 172.16.1.11 xml"
# ],
# After state:
# ------------
# router-ios#show running-config | section logging
# logging exception 4099
# logging message-counter log
# logging userinfo
# logging buffered xml 5099 notifications
# no logging reload
# no logging rate-limit
# logging console xml critical
# logging monitor warnings
# logging cns-events warnings
# logging policy-firewall rate-limit 10
# logging dmvpn rate-limit 10
# logging trap errors
# logging facility local5
# logging snmp-trap errors
# logging snmp-trap warnings
# logging host 172.16.1.13 transport tcp port 514
# logging host 172.16.1.11 xml
# logging host 172.16.1.12
# logging host 172.16.1.10 filtered stream 10
# Using state: deleted
# Before state:
# -------------
# router-ios#show running-config | section logging
# logging exception 4099
# logging message-counter log
# logging userinfo
# logging buffered xml 5099 notifications
# no logging reload
# no logging rate-limit
# logging console xml critical
# logging monitor warnings
# logging cns-events warnings
# logging policy-firewall rate-limit 10
# logging dmvpn rate-limit 10
# logging trap errors
# logging facility local5
# logging snmp-trap errors
# logging host 172.16.1.13 transport tcp port 514
# logging host 172.16.1.11 xml
# logging host 172.16.1.12
# logging host 172.16.1.10 filtered stream 10
- name: Remove all existing configuration
cisco.ios.ios_logging_global:
state: deleted
# Commands Fired:
# ---------------
# "commands": [
# "no logging message-counter log",
# "no logging snmp-trap errors",
# "no logging host 172.16.1.13",
# "no logging host 172.16.1.11",
# "no logging host 172.16.1.12",
# "no logging host 172.16.1.10",
# "no logging exception 4099",
# "no logging userinfo",
# "no logging buffered xml 5099 notifications",
# "no logging console xml critical",
# "no logging monitor warnings",
# "no logging cns-events warnings",
# "no logging policy-firewall rate-limit 10",
# "no logging dmvpn rate-limit 10",
# "no logging trap errors",
# "no logging facility local5"
# ],
# After state:
# ------------
# router-ios#show running-config | section logging
# no logging exception
# no logging buffered
# no logging reload
# no logging rate-limit
# no logging console
# no logging monitor
# no logging cns-events
# no logging trap
# Using state: overridden
# Before state:
# -------------
# router-ios#show running-config | section logging
# logging exception 4099
# logging message-counter log
# logging userinfo
# logging buffered 6000 critical
# no logging reload
# no logging rate-limit
# logging console xml critical
# logging monitor warnings
# logging cns-events warnings
# logging policy-firewall rate-limit 10
# logging dmvpn rate-limit 10
# logging trap errors
# logging facility local6
# logging host 172.16.1.13 transport tcp port 514
# logging host 172.16.1.12
# logging host 172.16.1.10 filtered stream 10
# logging host 172.16.1.25 filtered
- name: Override commands with provided configuration
cisco.ios.ios_logging_global:
config:
hosts:
- hostname: 172.16.1.27
filtered: true
state: overridden
# Commands Fired:
# ---------------
# "commands": [
# "no logging message-counter log",
# "no logging host 172.16.1.12",
# "no logging host 172.16.1.10",
# "no logging host 172.16.1.13",
# "no logging exception 4099",
# "no logging userinfo",
# "no logging console xml critical",
# "no logging monitor warnings",
# "no logging cns-events warnings",
# "no logging policy-firewall rate-limit 10",
# "no logging dmvpn rate-limit 10",
# "no logging trap errors",
# "no logging buffered 6000 critical",
# "no logging facility local6",
# "logging host 172.16.1.27 filtered",
# ],
# After state:
# ------------
# router-ios#show running-config | section logging
# no logging exception
# no logging buffered
# no logging reload
# no logging rate-limit
# no logging console
# no logging monitor
# no logging cns-events
# no logging trap
# logging host 172.16.1.27 filtered
# Using state: replaced
# Before state:
# -------------
# router-ios#show running-config | section logging
# logging exception 4099
# logging message-counter log
# logging userinfo
# logging buffered xml 5099 notifications
# no logging reload
# no logging rate-limit
# logging console xml critical
# logging monitor warnings
# logging cns-events warnings
# logging policy-firewall rate-limit 10
# logging dmvpn rate-limit 10
# logging trap errors
# logging facility local5
# logging snmp-trap errors
# logging host 172.16.1.13 transport tcp port 514
# logging host 172.16.1.11 xml
# logging host 172.16.1.12
# logging host 172.16.1.10 filtered stream 10
- name: Replace commands with provided configuration
cisco.ios.ios_logging_global:
config:
buffered:
severity: alerts
size: 6025
facility: local6
hosts:
- hostname: 172.16.1.19
- hostname: 172.16.1.10
filtered: true
stream: 15
state: replaced
# Commands Fired:
# ---------------
# "commands": [
# "no logging host 172.16.1.13",
# "no logging host 172.16.1.11",
# "no logging host 172.16.1.12",
# "no logging host 172.16.1.10",
# "logging host 172.16.1.19",
# "logging host 172.16.1.10 filtered stream 15",
# "logging buffered 6025 alerts",
# "logging facility local6"
# ],
# After state:
# ------------
# router-ios#show running-config | section logging
# logging exception 4099
# logging message-counter log
# logging userinfo
# logging buffered 6025 alerts
# no logging reload
# no logging rate-limit
# logging console xml critical
# logging monitor warnings
# logging cns-events warnings
# logging policy-firewall rate-limit 10
# logging dmvpn rate-limit 10
# logging trap errors
# logging facility local6
# logging snmp-trap errors
# logging host 172.16.1.19
# Using state: gathered
# Before state:
# -------------
# router-ios#show running-config | section logging
# logging exception 4099
# logging message-counter log
# logging userinfo
# logging buffered xml 5099 notifications
# no logging reload
# no logging rate-limit
# logging console xml critical
# logging monitor warnings
# logging cns-events warnings
# logging policy-firewall rate-limit 10
# logging dmvpn rate-limit 10
# logging trap errors
# logging facility local5
# logging snmp-trap errors
# logging host 172.16.1.13 transport tcp port 514
# logging host 172.16.1.11 xml
# logging host 172.16.1.12
# logging host 172.16.1.10 filtered stream 10
# logging host 172.16.1.25 filtered
- name: Gather listed logging config
cisco.ios.ios_logging_global:
state: gathered
# Module Execution Result:
# ------------------------
# "gathered": {
# "buffered": {
# "severity": "notifications",
# "size": 5099,
# "xml": true
# },
# "cns_events": "warnings",
# "console": {
# "severity": "critical",
# "xml": true
# },
# "dmvpn": {
# "rate_limit": 10
# },
# "exception": 4099,
# "facility": "local5",
# "hosts": [
# {
# "hostname": "172.16.1.11",
# "xml": true
# },
# {
# "hostname": "172.16.1.12"
# },
# {
# "filtered": true,
# "hostname": "172.16.1.10",
# "stream": 10
# },
# {
# "hostname": "172.16.1.13",
# "transport": {
# "tcp": {
# "port": 514
# }
# }
# },
# {
# "filtered": true,
# "hostname": "172.16.1.25"
# }
# ],
# "message_counter": [
# "log"
# ],
# "monitor": {
# "severity": "warnings"
# },
# "policy_firewall": {
# "rate_limit": 10
# },
# "snmp_trap": [
# "errors"
# ],
# "trap": "errors",
# "userinfo": true
# },
# After state:
# -------------
# router-ios#show running-config | section logging
# logging exception 4099
# logging message-counter log
# logging userinfo
# logging buffered xml 5099 notifications
# no logging reload
# no logging rate-limit
# logging console xml critical
# logging monitor warnings
# logging cns-events warnings
# logging policy-firewall rate-limit 10
# logging dmvpn rate-limit 10
# logging trap errors
# logging facility local5
# logging snmp-trap errors
# logging host 172.16.1.13 transport tcp port 514
# logging host 172.16.1.11 xml
# logging host 172.16.1.12
# logging host 172.16.1.10 filtered stream 10
# logging host 172.16.1.25 filtered
# Using state: rendered
- name: Render the commands for provided configuration
cisco.ios.ios_logging_global:
config:
buffered:
severity: notifications
size: 5099
xml: true
console:
severity: critical
xml: true
facility: local5
hosts:
- hostname: 172.16.1.12
- hostname: 172.16.1.11
xml: true
- hostname: 172.16.1.10
filtered: true
stream: 10
- hostname: 172.16.1.13
transport:
tcp:
port: 514
monitor:
severity: warnings
message_counter: log
snmp_trap: errors
trap: errors
userinfo: true
policy_firewall:
rate_limit: 10
logging_on: enable
exception: 10
dmvpn:
rate_limit: 10
cns_events: warnings
state: rendered
# Module Execution Result:
# ------------------------
# "rendered": [
# "logging host 172.16.1.12",
# "logging host 172.16.1.11 xml",
# "logging host 172.16.1.10 filtered stream 10",
# "logging host 172.16.1.13 transport tcp port 514",
# "logging message-counter log",
# "logging snmp-trap errors",
# "logging buffered xml 5099 notifications",
# "logging console xml critical",
# "logging facility local5",
# "logging monitor warnings",
# "logging trap errors",
# "logging userinfo",
# "logging policy-firewall rate-limit 10",
# "logging on",
# "logging exception 10",
# "logging dmvpn rate-limit 10",
# "logging cns-events warnings"
# ]
# Using state: parsed
# File: parsed.cfg
# ----------------
# logging on
# logging count
# logging userinfo
# logging trap errors
# logging reload alerts
# logging host 172.16.1.1
# logging exception 4099
# logging history alerts
# logging facility local5
# logging snmp-trap errors
# logging monitor warnings
# logging origin-id hostname
# logging host 172.16.1.11 xml
# logging cns-events warnings
# logging dmvpn rate-limit 10
# logging message-counter log
# logging console xml critical
# logging message-counter debug
# logging persistent batch 4444
# logging host 172.16.1.25 filtered
# logging source-interface GBit1/0
# logging source-interface CTunnel2
# logging policy-firewall rate-limit 10
# logging buffered xml 5099 notifications
# logging rate-limit all 2 except warnings
# logging host 172.16.1.10 filtered stream 10
# logging host 172.16.1.13 transport tcp port 514
# logging discriminator msglog01 severity includes 5
# logging filter tftp://172.16.2.18/ESM/elate.tcl args TESTInst2
# logging filter tftp://172.16.2.14/ESM/escalate.tcl args TESTInst
- name: Parse the provided configuration with the existing running configuration
cisco.ios.ios_logging_global:
running_config: "{{ lookup('file', 'parsed.cfg') }}"
state: parsed
# Module Execution Result:
# ------------------------
# "parsed": {
# "buffered": {
# "severity": "notifications",
# "size": 5099,
# "xml": true
# },
# "cns_events": "warnings",
# "console": {
# "severity": "critical",
# "xml": true
# },
# "count": true,
# "discriminator": [
# "msglog01 severity includes 5"
# ],
# "dmvpn": {
# "rate_limit": 10
# },
# "exception": 4099,
# "facility": "local5",
# "filter": [
# {
# "args": "TESTInst2",
# "url": "tftp://172.16.2.18/ESM/elate.tcl"
# },
# {
# "args": "TESTInst",
# "url": "tftp://172.16.2.14/ESM/escalate.tcl"
# }
# ],
# "history": {
# "severity": "alerts"
# },
# "hosts": [
# {
# "hostname": "172.16.1.1"
# },
# {
# "hostname": "172.16.1.11",
# "xml": true
# },
# {
# "filtered": true,
# "hostname": "172.16.1.25"
# },
# {
# "filtered": true,
# "hostname": "172.16.1.10",
# "stream": 10
# },
# {
# "hostname": "172.16.1.13",
# "transport": {
# "tcp": {
# "port": 514
# }
# }
# }
# ],
# "logging_on": "enable",
# "message_counter": [
# "log",
# "debug"
# ],
# "monitor": {
# "severity": "warnings"
# },
# "origin_id": {
# "tag": "hostname"
# },
# "persistent": {
# "batch": 4444
# },
# "policy_firewall": {
# "rate_limit": 10
# },
# "rate_limit": {
# "all": true,
# "except_severity": "warnings",
# "size": 2
# },
# "reload": {
# "severity": "alerts"
# },
# "snmp_trap": [
# "errors"
# ],
# "source_interface": [
# {
# "interface": "GBit1/0"
# },
# {
# "interface": "CTunnel2"
# }
# ],
# "trap": "errors",
# "userinfo": true
# }
返回值
常用返回值记录在此处,以下是此模块独有的字段
键 |
描述 |
---|---|
生成的配置模型调用。 返回: 当发生更改时 示例: |
|
模型调用之前的配置。 返回: 始终 示例: |
|
推送到远程设备的命令集。 返回: 始终 示例: |