cisco.nxos.nxos_logging_global 模块 – 日志资源模块。

注意

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

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

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

要在 playbook 中使用它,请指定: cisco.nxos.nxos_logging_global

cisco.nxos 2.5.0 中的新功能

概要

  • 此模块管理运行 Cisco NX-OS 的设备上的日志记录配置。

参数

参数

注释

config

字典

日志配置的字典。

console

字典

设置控制台日志记录参数。

severity

字符串

为控制台设置严重性。

选择

  • “紧急”

  • “警报”

  • “严重”

  • “错误”

  • “警告”

  • “通知”

  • “信息”

  • “调试”

state

字符串

启用或禁用监视器日志记录。

选择

  • “已启用”

  • “已禁用”

event

字典

接口事件。

字典

UPDOWN 和 CHANGE 消息。

布尔值

未显式配置的接口使用的默认日志记录配置。

选择

  • false

  • true

布尔值

启用日志记录以覆盖端口严重性配置。

选择

  • false

  • true

trunk_status

字典

TRUNK 状态消息。

default

布尔值

未显式配置的接口使用的默认日志记录配置。

选择

  • false

  • true

enable

布尔值

启用日志记录以覆盖端口严重性配置。

选择

  • false

  • true

facilities

列表 / 元素=字典

用于 syslog 消息的 Facility 参数。

facility

字符串

Facility 名称。

severity

字符串

为控制台设置严重性。

选择

  • “紧急”

  • “警报”

  • “严重”

  • “错误”

  • “警告”

  • “通知”

  • “信息”

  • “调试”

history

字典

修改历史记录表的严重性或大小。

severity

字符串

为控制台设置严重性。

选择

  • “紧急”

  • “警报”

  • “严重”

  • “错误”

  • “警告”

  • “通知”

  • “信息”

  • “调试”

size

整数

设置历史记录表大小。

hosts

列表 / 元素=字典

启用转发到远程 Syslog 服务器。

facility

字符串

转发到服务器时要使用的 Facility。

host

字符串

远程 Syslog 服务器的主机名/IPv4/IPv6 地址。

port

整数

转发到远程服务器时的目标端口。

secure

字典

启用与远程服务器的安全连接。

trustpoint

字典

Trustpoint 配置。

client_identity

字符串

用于相互身份验证的客户端身份证书。

用于客户端证书身份验证的 Trustpoint。

severity

字符串

为控制台设置严重性。

选择

  • “紧急”

  • “警报”

  • “严重”

  • “错误”

  • “警告”

  • “通知”

  • “信息”

  • “调试”

use_vrf

字符串

显示每个 VRF 的信息。

MDS 交换机不支持此选项。

ip

字典

IP 配置。

MDS 交换机不支持此选项。

access_list

字典

访问列表。

cache

字典

设置缓存设置。

entries

整数

软件中缓存的最大日志条目数。

interval

整数

日志更新间隔(秒)。

threshold

整数

日志更新阈值(命中次数)

detailed

布尔值

详细的 ACL 信息。

选择

  • false

  • true

include

字典

在 syslog 中包含其他字段。

sgt

布尔值

在 syslog 中包含源组标签信息。

选择

  • false

  • true

logfile

字典

设置文件日志记录。

name

字符串

日志文件名。

persistent_threshold

整数

设置持久日志记录利用率警报阈值,以百分比表示。

MDS 交换机不支持此选项。

severity

字符串

为控制台设置严重性。

选择

  • “紧急”

  • “警报”

  • “严重”

  • “错误”

  • “警告”

  • “通知”

  • “信息”

  • “调试”

size

整数

以字节为单位输入日志文件大小。

state

字符串

启用或禁用日志文件。

选择

  • “已启用”

  • “已禁用”

module

字典

设置模块(线卡)日志记录。

severity

字符串

为控制台设置严重性。

选择

  • “紧急”

  • “警报”

  • “严重”

  • “错误”

  • “警告”

  • “通知”

  • “信息”

  • “调试”

state

字符串

启用或禁用模块日志记录。

选择

  • “已启用”

  • “已禁用”

monitor

字典

设置终端行(监视器)日志记录严重性。

severity

字符串

为控制台设置严重性。

选择

  • “紧急”

  • “警报”

  • “严重”

  • “错误”

  • “警告”

  • “通知”

  • “信息”

  • “调试”

state

字符串

启用或禁用监视器日志记录。

选择

  • “已启用”

  • “已禁用”

origin_id

字典

为远程 Syslog 服务器启用源信息。

hostname

布尔值

使用主机名作为日志消息的源 ID。

此选项与 *ip* 和 *string* 互斥。

选择

  • false

  • true

ip

字符串

使用 IP 地址作为日志消息的源 ID。

此选项与 *hostname* 和 *string* 互斥。

字符串

字符串

使用文本字符串作为日志消息的源 ID。

此选项与 *hostname* 和 *ip* 互斥。

rate_limit

字符串

启用或禁用日志消息的速率限制。

选择

  • “已启用”

  • “已禁用”

rfc_strict

布尔值

设置消息应符合的 RFC。

syslog 将符合 RFC 5424。

MDS 交换机不支持此选项。

选择

  • false

  • true

source_interface

字符串

为远程 Syslog 服务器启用源接口。

MDS 交换机不支持此选项。

timestamp

字符串

设置日志时间戳粒度。

选择

  • “微秒”

  • “毫秒”

  • “秒”

running_config

字符串

此选项仅与状态 *parsed* 一起使用。

此选项的值应该是从 NX-OS 设备执行命令 **show running-config | include logging** 收到的输出。

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

state

字符串

应将配置保留在的状态。

状态 *replaced* 和 *overridden* 对于此模块具有相同的行为。

有关更多详细信息,请参阅示例。

选择

  • "merged" ← (默认)

  • “replaced”

  • “overridden”

  • “deleted”

  • “parsed”

  • “gathered”

  • “rendered”

说明

注意

  • 在 Cisco Nexus 交换机上针对 NX-OS 9.3.6 进行了测试。

  • 对 Cisco MDS 的有限支持

  • 此模块适用于连接 network_clihttpapi

  • 使用连接 network_cli 针对 Cisco MDS NX-OS 9.2(2) 进行了测试。

示例

# Using merged

# Before state:
# -------------
# nxos-9k-rdo# show running-config | include logging
# nxos-9k-rdo#

- name: Merge the provided configuration with the existing running configuration
  cisco.nxos.nxos_logging_global:
    config:
      console:
        severity: error
      monitor:
        severity: warning
      ip:
        access_list:
          cache:
            entries: 16384
            interval: 200
            threshold: 5000
      facilities:
        - facility: auth
          severity: critical
        - facility: ospfv3
          severity: alert
        - facility: ftp
          severity: informational
      hosts:
        - host: 203.0.113.100
          severity: alert
          use_vrf: management
        - host: 203.0.113.101
          severity: error
          facility: local6
          use_vrf: default
      origin_id:
        hostname: true

# Task output
# -------------
#  before: {}
#
#  commands:
#    - "logging console 3"
#    - "logging monitor 4"
#    - "logging ip access-list cache entries 16384"
#    - "logging ip access-list cache interval 200"
#    - "logging ip access-list cache threshold 5000"
#    - "logging severity auth 2"
#    - "logging severity ospfv3 1"
#    - "logging severity ftp 6"
#    - "logging server 203.0.113.100 1 use-vrf management"
#    - "logging server 203.0.113.101 3 facility local6 use-vrf default"
#    - "logging origin-id hostname"
#
# after:
#   console:
#      severity: error
#    facilities:
#      - facility: auth
#        severity: critical
#      - facility: ftp
#        severity: informational
#      - facility: ospfv3
#        severity: alert
#    ip:
#      access_list:
#        cache:
#          entries: 16384
#          interval: 200
#          threshold: 5000
#    monitor:
#      severity: warning
#    origin_id:
#      hostname: true
#    hosts:
#      - severity: alert
#        host: 203.0.113.100
#        use_vrf: management
#      - facility: local6
#        severity: error
#        host: 203.0.113.101
#        use_vrf: default

# After state:
# ------------
# nxos-9k-rdo# show running-config | include logging
# logging console 3
# logging monitor 4
# logging ip access-list cache entries 16384
# logging ip access-list cache interval 200
# logging ip access-list cache threshold 5000
# logging severity auth 2
# logging severity ospfv3 1
# logging severity ftp 6
# logging origin-id hostname
# logging server 203.0.113.100 1 use-vrf management
# logging server 203.0.113.101 3 use-vrf default facility local6

# Using replaced

# Before state:
# ------------
# nxos-9k-rdo# show running-config | include logging
# logging console 3
# logging monitor 4
# logging ip access-list cache entries 16384
# logging ip access-list cache interval 200
# logging ip access-list cache threshold 5000
# logging severity auth 2
# logging severity ospfv3 1
# logging severity ftp 6
# logging origin-id hostname
# logging server 203.0.113.100 1 use-vrf management
# logging server 203.0.113.101 3 use-vrf default facility local6

- name: Replace logging configurations with provided config
  cisco.nxos.nxos_logging_global:
    config:
      monitor:
        severity: warning
      ip:
        access_list:
          cache:
            entries: 4096
      facilities:
        - facility: auth
          severity: critical
        - facility: ospfv3
          severity: alert
        - facility: ftp
          severity: informational
      hosts:
        - host: 203.0.113.101
          severity: error
          facility: local6
          use_vrf: default
        - host: 198.51.100.101
          severity: alert
          port: 6538
          use_vrf: management
      origin_id:
        ip: 192.0.2.100
    state: replaced

# Task output
# -------------
# before:
#   console:
#      severity: error
#    facilities:
#      - facility: auth
#        severity: critical
#      - facility: ftp
#        severity: informational
#      - facility: ospfv3
#        severity: alert
#    ip:
#      access_list:
#        cache:
#          entries: 16384
#          interval: 200
#          threshold: 5000
#    monitor:
#      severity: warning
#    origin_id:
#      hostname: true
#    hosts:
#      - severity: alert
#        host: 203.0.113.100
#        use_vrf: management
#      - facility: local6
#        severity: error
#        host: 203.0.113.101
#        use_vrf: default
#
# commands:
#   - "logging console"
#   - "logging ip access-list cache entries 4096"
#   - "no logging ip access-list cache interval 200"
#   - "no logging ip access-list cache threshold 5000"
#   - "no logging origin-id hostname"
#   - "logging origin-id ip 192.0.2.100"
#   - "logging server 198.51.100.101 1 port 6538 use-vrf management"
#   - "no logging server 203.0.113.100 1 use-vrf management"
#
#  after:
#    facilities:
#      - facility: auth
#        severity: critical
#      - facility: ftp
#        severity: informational
#      - facility: ospfv3
#        severity: alert
#    ip:
#      access_list:
#        cache:
#          entries: 4096
#    monitor:
#      severity: warning
#    origin_id:
#      ip: 192.0.2.100
#    hosts:
#      - severity: alert
#        port: 6538
#        host: 198.51.100.101
#        use_vrf: management
#      - facility: local6
#        severity: error
#        host: 203.0.113.101
#        use_vrf: default
#
# After state:
# ------------
# nxos-9k-rdo# show running-config | include logging
# logging monitor 4
# logging ip access-list cache entries 4096
# logging severity auth 2
# logging severity ospfv3 1
# logging severity ftp 6
# logging origin-id ip 192.0.2.100
# logging server 203.0.113.101 3 use-vrf default facility local6
# logging server 198.51.100.101 1 port 6538 use-vrf management

# Using deleted to delete all logging configurations

# Before state:
# ------------
# nxos-9k-rdo# show running-config | include logging
# logging console 3
# logging monitor 4
# logging ip access-list cache entries 16384
# logging ip access-list cache interval 200
# logging ip access-list cache threshold 5000
# logging severity auth 2
# logging severity ospfv3 1
# logging severity ftp 6
# logging origin-id hostname
# logging server 203.0.113.100 1 use-vrf management
# logging server 203.0.113.101 3 use-vrf default facility local6

- name: Delete all logging configuration
  cisco.nxos.nxos_logging_global:
    state: deleted

# Task output
# -------------
# before:
#   console:
#      severity: error
#    facilities:
#      - facility: auth
#        severity: critical
#      - facility: ftp
#        severity: informational
#      - facility: ospfv3
#        severity: alert
#    ip:
#      access_list:
#        cache:
#          entries: 16384
#          interval: 200
#          threshold: 5000
#    monitor:
#      severity: warning
#    origin_id:
#      hostname: true
#    hosts:
#      - severity: alert
#        host: 203.0.113.100
#        use_vrf: management
#      - facility: local6
#        severity: error
#        host: 203.0.113.101
#        use_vrf: default
#
# commands:
#   - "logging console"
#   - "logging monitor"
#   - "no logging ip access-list cache entries 16384"
#   - "no logging ip access-list cache interval 200"
#   - "no logging ip access-list cache threshold 5000"
#   - "no logging origin-id hostname"
#   - "no logging severity auth 2"
#   - "no logging severity ospfv3 1"
#   - "no logging severity ftp 6"
#   - "no logging server 203.0.113.100 1 use-vrf management"
#   - "no logging server 203.0.113.101 3 facility local6 use-vrf default"
#
# after: {}

# Using rendered

- name: Render platform specific configuration lines with state rendered (without connecting to the device)
  cisco.nxos.nxos_logging_global:
    config:
      console:
        severity: error
      monitor:
        severity: warning
      ip:
        access_list:
          cache:
            entries: 16384
            interval: 200
            threshold: 5000
      facilities:
        - facility: auth
          severity: critical
        - facility: ospfv3
          severity: alert
        - facility: ftp
          severity: informational
      hosts:
        - host: 203.0.113.100
          severity: alert
          use_vrf: management
        - host: 203.0.113.101
          severity: error
          facility: local6
          use_vrf: default
      origin_id:
        hostname: true

# Task Output (redacted)
# -----------------------
#  rendered:
#    - "logging console 3"
#    - "logging monitor 4"
#    - "logging ip access-list cache entries 16384"
#    - "logging ip access-list cache interval 200"
#    - "logging ip access-list cache threshold 5000"
#    - "logging severity auth 2"
#    - "logging severity ospfv3 1"
#    - "logging severity ftp 6"
#    - "logging server 203.0.113.100 1 use-vrf management"
#    - "logging server 203.0.113.101 3 facility local6 use-vrf default"
#    - "logging origin-id hostname"

# Using parsed

# parsed.cfg
# ------------
# logging console 3
# logging monitor 4
# logging ip access-list cache entries 16384
# logging ip access-list cache interval 200
# logging ip access-list cache threshold 5000
# logging severity auth 2
# logging severity ospfv3 1
# logging severity ftp 6
# logging origin-id hostname
# logging server 203.0.113.100 1 use-vrf management
# logging server 203.0.113.101 3 use-vrf default facility local6

- name: Parse externally provided logging configuration
  cisco.nxos.nxos_logging_global:
    running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}"
    state: parsed

# Task output (redacted)
# -----------------------
# parsed:
#   console:
#      severity: error
#    facilities:
#      - facility: auth
#        severity: critical
#      - facility: ftp
#        severity: informational
#      - facility: ospfv3
#        severity: alert
#    ip:
#      access_list:
#        cache:
#          entries: 16384
#          interval: 200
#          threshold: 5000
#    monitor:
#      severity: warning
#    origin_id:
#      hostname: true
#    hosts:
#      - severity: alert
#        host: 203.0.113.100
#        use_vrf: management
#      - facility: local6
#        severity: error
#        host: 203.0.113.101
#        use_vrf: default

返回值

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

描述

after

字典

模块执行后的结果配置。

返回值: 当更改时

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

before

字典

模块执行之前的配置。

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

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

commands

列表 / 元素=字符串

推送到远程设备的一组命令。

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

示例: ["logging console 3", "logging monitor 4", "logging ip access-list cache entries 16384", "logging ip access-list cache interval 200", "logging ip access-list cache threshold 5000"]

已收集

列表 / 元素=字符串

从远程设备收集的网络资源的事实,以结构化数据的形式呈现。

返回: 当状态为 已收集

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

已解析

列表 / 元素=字符串

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

返回: 当状态为 已解析

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

已渲染

列表 / 元素=字符串

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

返回: 当状态为 已渲染

示例: ["logging ip access-list cache entries 4096", "no logging ip access-list cache interval 200", "no logging ip access-list cache threshold 5000", "no logging origin-id hostname", "logging origin-id ip 192.0.2.100", "logging server 198.51.100.101 1 port 6538 use-vrf management"]

作者

  • Nilashish Chakraborty (@NilashishC)