arista.eos.eos_logging_global 模块 – 管理日志资源模块

注意

此模块是 arista.eos 集合(版本 10.0.1)的一部分。

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

要安装它,请使用: ansible-galaxy collection install arista.eos

要在剧本中使用它,请指定: arista.eos.eos_logging_global

arista.eos 3.0.0 中的新功能

概要

  • 此模块配置和管理 Arista EOS 平台上的日志属性。

参数

参数

注释

config

字典

日志选项的字典

buffered

字典

设置缓冲日志参数。

buffer_size

整数

日志缓冲区大小

severity

字符串

严重级别。

选项

  • "紧急"

  • "警报"

  • "严重"

  • "错误"

  • "警告"

  • "通知"

  • "信息"

  • "调试"

console

字典

设置控制台日志参数。

severity

字符串

严重级别。

选项

  • "紧急"

  • "警报"

  • "严重"

  • "错误"

  • "警告"

  • "通知"

  • "信息"

  • "调试"

event

字符串

全局事件

选项

  • "链路状态"

  • "端口通道"

  • "生成树"

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"

format

字典

设置日志格式参数

hostname

字符串

指定主机名日志格式。

sequence_numbers

布尔值

日志消息的数量。

选项

  • false

  • true

timestamp

字典

设置时间戳日志参数。

high_resolution

布尔值

RFC3339 时间戳。

选项

  • false

  • true

traditional

字典

RFC3164 中指定的传统 syslog 时间戳格式。

state

字符串

启用后,将设置传统时间戳格式。

选项

  • "enabled"

  • "disabled"

timezone

布尔值

在传统格式的时间戳中显示时区

选项

  • false

  • true

year

布尔值

在传统格式的时间戳中显示年份

选项

  • false

  • true

hosts

列表 / 元素=字典

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

add

布尔值

在给定的主机上配置端口。

选项

  • false

  • true

name

字符串

syslog 服务器的主机名或 IP 地址。

port

整数

syslog 服务器的端口。

protocol

字符串

设置 syslog 服务器传输协议

选项

  • "tcp"

  • "udp"

remove

布尔值

从给定主机中删除配置的端口

选项

  • false

  • true

level

字典

配置日志严重性

facility

字符串

设施级别

severity

字符串

严重级别。

选项

  • "紧急"

  • "警报"

  • "严重"

  • "错误"

  • "警告"

  • "通知"

  • "信息"

  • "调试"

monitor

字符串

设置终端监视器严重性

persistent

字典

将日志消息保存到闪存盘。

set

布尔值

将日志消息保存到闪存盘。

选项

  • false

  • true

size

整数

存储在闪存盘上的日志文件的最大大小(以字节为单位)。

policy

字典

配置日志策略。

invert_result

布尔值

反转匹配列表的匹配项。

选项

  • false

  • true

match_list

字符串

配置日志消息过滤。

qos

整数

在 IP 报头中设置 DSCP 值。

relogging_interval

整数

配置关键日志消息的重新记录间隔

repeat_messages

布尔值

重复消息而不是汇总重复次数

选项

  • false

  • true

source_interface

字符串

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

synchronous

字典

设置将主动消息与被动消息同步

level

字符串

配置日志严重性

set

布尔值

设置将主动消息与被动消息同步。

选项

  • false

  • true

trap

字典

发送到 syslog 服务器的消息的严重性。

set

布尔值

发送到 syslog 服务器的消息的严重性。

选项

  • false

  • true

severity

字符串

严重级别。

选项

  • "紧急"

  • "警报"

  • "严重"

  • "错误"

  • "警告"

  • "通知"

  • "信息"

  • "调试"

turn_on

布尔值

打开日志记录。

选项

  • false

  • true

vrfs

列表 / 元素=字典

指定 vrf

hosts

列表 / 元素=字典

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

add

布尔值

在给定的主机上配置端口。

选项

  • false

  • true

name

字符串

syslog 服务器的主机名或 IP 地址。

port

整数

syslog 服务器的端口。

protocol

字符串

设置 syslog 服务器传输协议

选项

  • "tcp"

  • "udp"

remove

布尔值

从给定主机中删除配置的端口

选项

  • false

  • true

name

字符串

vrf 名称。

source_interface

字符串

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

running_config

字符串

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

此选项的值应是从 EOS 设备执行命令 show running-config | section access-list 收到的输出。

对于此模块,状态 replacedoverridden 具有相同的行为。

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

state

字符串

配置应保留的状态。

选项

  • "已删除"

  • "merged" ← (默认)

  • "已覆盖"

  • "已替换"

  • "已收集"

  • "已渲染"

  • "已解析"

注释

注意

  • 已针对 Arista EOS 4.24.6M 进行测试

  • 此模块使用连接 network_cli。请参阅 EOS 平台选项

示例

# Using merged
# Before state

# test(config)#show running-config | section logging
# test(config)#

- name: Merge provided configuration with device configuration
  arista.eos.eos_logging_global:
    config:
      hosts:
        - name: "host01"
          protocol: "tcp"
        - name: "11.11.11.1"
          port: 25
      vrfs:
        - name: "vrf01"
          source_interface: "Ethernet1"
        - name: "vrf02"
          hosts:
            - name: "hostvrf1"
              protocol: "tcp"
            - name: "24.1.1.1"
              port: "33"

# After State:

# test(config)#show running-config | section logging
# logging host 11.11.11.1 25
# logging host host01 514 protocol tcp
# logging vrf vrf02 host 24.1.1.1 33
# logging vrf vrf02 host hostvrf1 514 protocol tcp
# logging vrf vrf01 source-interface Ethernet1
# test(config)#
#
#
# Module Execution:
# "after": {
#         "hosts": [
#             {
#                 "name": "11.11.11.1",
#                 "port": 25
#             },
#             {
#                 "name": "host01",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "vrfs": [
#             {
#                 "name": "vrf01",
#                 "source_interface": "Ethernet1"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "24.1.1.1",
#                         "port": 33
#                     },
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf02"
#             }
#         ]
#     },
#     "before": {},
#     "changed": true,
#     "commands": [
#         "logging host host01 protocol tcp",
#         "logging host 11.11.11.1 25",
#         "logging vrf vrf01 source-interface Ethernet1",
#         "logging vrf vrf02 host hostvrf1 protocol tcp",
#         "logging vrf vrf02 host 24.1.1.1 33"
#     ],
#

# Using replaced:
# Before State:

# test(config)#show running-config | section logging
# logging host 11.11.11.1 25
# logging host host01 514 protocol tcp
# logging vrf vrf02 host 24.1.1.1 33
# logging vrf vrf02 host hostvrf1 514 protocol tcp
# logging format timestamp traditional timezone
# logging vrf vrf01 source-interface Ethernet1
# logging policy match inverse-result match-list                           list01 discard
# logging persistent 4096
# !
# logging level AAA alerts
# test(config)#

- name: Repalce
  arista.eos.eos_logging_global:
    config:
      synchronous:
        set: true
      trap:
        severity: "critical"
      hosts:
        - name: "host02"
          protocol: "tcp"
      vrfs:
        - name: "vrf03"
          source_interface: "Vlan100"
        - name: "vrf04"
          hosts:
            - name: "hostvrf1"
              protocol: "tcp"

    state: replaced

# After State:
# test(config)#show running-config | section logging
# logging synchronous
# logging trap critical
# logging host host02 514 protocol tcp
# logging vrf vrf04 host hostvrf1 514 protocol tcp
# logging vrf vrf03 source-interface Vlan100
# test(config)#
#
# Module Execution:
# "after": {
#         "hosts": [
#             {
#                 "name": "host02",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "synchronous": {
#             "set": true
#         },
#         "trap": {
#            "severity": "critical"
#         },
#         "vrfs": [
#             {
#                 "name": "vrf03",
#                 "source_interface": "Vlan100"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf04"
#             }
#         ]
#     },
#     "before": {
#         "format": {
#             "timestamp": {
#                 "traditional": {
#                     "timezone": true
#                 }
#             }
#         },
#         "hosts": [
#             {
#                 "name": "11.11.11.1",
#                 "port": 25
#             },
#             {
#                 "name": "host01",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "level": {
#             "facility": "AAA",
#             "severity": "alerts"
#         },
#         "persistent": {
#             "size": 4096
#         },
#         "policy": {
#             "invert_result": true,
#             "match_list": "list01"
#         },
#         "vrfs": [
#             {
#                 "name": "vrf01",
#                 "source_interface": "Ethernet1"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "24.1.1.1",
#                         "port": 33
#                     },
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf02"
#             }
#         ]
#     },
#     "changed": true,
#     "commands": [
#         "logging host host02 protocol tcp",
#         "no logging host 11.11.11.1 25",
#         "no logging host host01 514 protocol tcp",
#         "logging vrf vrf03 source-interface Vlan100",
#         "logging vrf vrf04 host hostvrf1 protocol tcp",
#         "no logging vrf vrf01 source-interface Ethernet1",
#         "no logging vrf vrf02 host 24.1.1.1 33",
#         "no logging vrf vrf02 host hostvrf1 514 protocol tcp",
#         "no logging format timestamp traditional timezone",
#         "no logging level AAA alerts",
#         "no logging persistent 4096",
#         "no logging policy match invert-result match-list list01 discard",
#         "logging synchronous",
#         "logging trap critical"
#     ],
#
#


# Using overridden:
# Before State:

# test(config)#show running-config | section logging
# logging host 11.11.11.1 25
# logging host host01 514 protocol tcp
# logging vrf vrf02 host 24.1.1.1 33
# logging vrf vrf02 host hostvrf1 514 protocol tcp
# logging format timestamp traditional timezone
# logging vrf vrf01 source-interface Ethernet1
# logging policy match inverse-result match-list                           list01 discard
# logging persistent 4096
# !
# logging level AAA alerts
# test(config)#

- name: Repalce
  arista.eos.eos_logging_global:
    config:
      synchronous:
        set: true
      trap:
        severity: "critical"
      hosts:
        - name: "host02"
          protocol: "tcp"
      vrfs:
        - name: "vrf03"
          source_interface: "Vlan100"
        - name: "vrf04"
          hosts:
            - name: "hostvrf1"
              protocol: "tcp"

    state: overridden

# After State:
# test(config)#show running-config | section logging
# logging synchronous
# logging trap critical
# logging host host02 514 protocol tcp
# logging vrf vrf04 host hostvrf1 514 protocol tcp
# logging vrf vrf03 source-interface Vlan100
# test(config)#
#
# Module Execution:
# "after": {
#         "hosts": [
#             {
#                 "name": "host02",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "synchronous": {
#             "set": true
#         },
#         "trap": {
#            "severity": "critical"
#         },
#         "vrfs": [
#             {
#                 "name": "vrf03",
#                 "source_interface": "Vlan100"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf04"
#             }
#         ]
#     },
#     "before": {
#         "format": {
#             "timestamp": {
#                 "traditional": {
#                     "timezone": true
#                 }
#             }
#         },
#         "hosts": [
#             {
#                 "name": "11.11.11.1",
#                 "port": 25
#             },
#             {
#                 "name": "host01",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "level": {
#             "facility": "AAA",
#             "severity": "alerts"
#         },
#         "persistent": {
#             "size": 4096
#         },
#         "policy": {
#             "invert_result": true,
#             "match_list": "list01"
#         },
#         "vrfs": [
#             {
#                 "name": "vrf01",
#                 "source_interface": "Ethernet1"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "24.1.1.1",
#                         "port": 33
#                     },
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf02"
#             }
#         ]
#     },
#     "changed": true,
#     "commands": [
#         "logging host host02 protocol tcp",
#         "no logging host 11.11.11.1 25",
#         "no logging host host01 514 protocol tcp",
#         "logging vrf vrf03 source-interface Vlan100",
#         "logging vrf vrf04 host hostvrf1 protocol tcp",
#         "no logging vrf vrf01 source-interface Ethernet1",
#         "no logging vrf vrf02 host 24.1.1.1 33",
#         "no logging vrf vrf02 host hostvrf1 514 protocol tcp",
#         "no logging format timestamp traditional timezone",
#         "no logging level AAA alerts",
#         "no logging persistent 4096",
#         "no logging policy match invert-result match-list list01 discard",
#         "logging synchronous",
#         "logging trap critical"
#     ],
#
#

# Using deleted:

# Before State:
# test(config)#show running-config | section logging
# logging synchronous level critical
# logging host 11.11.11.1 25
# logging host host01 514 protocol tcp
# logging host host02 514 protocol tcp
# logging vrf vrf02 host 24.1.1.1 33
# logging vrf vrf02 host hostvrf1 514 protocol tcp
# logging vrf vrf04 host hostvrf1 514 protocol tcp
# logging vrf vrf01 source-interface Ethernet1
# logging vrf vrf03 source-interface Vlan100
# test(config)#

- name: Delete all logging configs
  arista.eos.eos_logging_global:
    state: deleted
  become: true

# After state:
# test(config)#show running-config | section logging
# test(config)#
#
# "after": {},
#     "before": {
#         "hosts": [
#             {
#                 "name": "11.11.11.1",
#                 "port": 25
#             },
#             {
#                 "name": "host01",
#                 "port": 514,
#                 "protocol": "tcp"
#             },
#             {
#                 "name": "host02",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "synchronous": {
#             "level": "critical"
#         },
#         "vrfs": [
#             {
#                 "name": "vrf01",
#                 "source_interface": "Ethernet1"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "24.1.1.1",
#                         "port": 33
#                     },
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf02"
#             },
#             {
#                 "name": "vrf03",
#                 "source_interface": "Vlan100"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf04"
#             }
#         ]
#     },
#     "changed": true,
#     "commands": [
#         "no logging host 11.11.11.1 25",
#         "no logging host host01 514 protocol tcp",
#         "no logging host host02 514 protocol tcp",
#         "no logging vrf vrf01 source-interface Ethernet1",
#         "no logging vrf vrf02 host 24.1.1.1 33",
#         "no logging vrf vrf02 host hostvrf1 514 protocol tcp",
#         "no logging vrf vrf03 source-interface Vlan100",
#         "no logging vrf vrf04 host hostvrf1 514 protocol tcp",
#         "no logging synchronous level critical"
#     ],

# Using parsed:
# parsed.cfg

# logging host 11.11.11.1 25
# logging host host01 514 protocol tcp
# logging vrf vrf02 host 24.1.1.1 33
# logging vrf vrf02 host hostvrf1 514 protocol tcp
# logging format timestamp traditional timezone
# logging vrf vrf01 source-interface Ethernet1
# logging policy match inverse-result match-list                           list01 discard
# logging persistent 4096
# !
# logging level AAA alerts

- name: parse configs
  arista.eos.eos_logging_global:
    running_config: "{{ lookup('file', './parsed.cfg') }}"
    state: parsed

# Module Execution
# "parsed": {
#         "format": {
#             "timestamp": {
#                 "traditional": {
#                     "timezone": true
#                 }
#             }
#         },
#         "hosts": [
#             {
#                 "name": "11.11.11.1",
#                 "port": 25
#             },
#             {
#                 "name": "host01",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "level": {
#             "facility": "AAA",
#             "severity": "alerts"
#         },
#         "persistent": {
#             "size": 4096
#         },
#         "policy": {
#             "invert_result": true,
#             "match_list": "list01"
#         },
#         "vrfs": [
#             {
#                 "name": "vrf01",
#                 "source_interface": "Ethernet1"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "24.1.1.1",
#                         "port": 33
#                     },
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf02"
#             }
#         ]
#     }
#

# Using gathered:
# Before State:
# test(config)#show running-config | section logging
# logging host 11.11.11.1 25
# logging host host01 514 protocol tcp
# logging vrf vrf02 host 24.1.1.1 33
# logging vrf vrf02 host hostvrf1 514 protocol tcp
# logging format timestamp traditional timezone
# logging vrf vrf01 source-interface Ethernet1
# logging policy match inverse-result match-list                           list01 discard
# logging persistent 4096
# !
# logging level AAA alerts
# test(config)#

- name: gather configs
  arista.eos.eos_logging_global:
    state: gathered

# Module Execution:
# "gathered": {
#         "format": {
#             "timestamp": {
#                 "traditional": {
#                     "timezone": true
#                 }
#             }
#         },
#         "hosts": [
#             {
#                 "name": "11.11.11.1",
#                 "port": 25
#             },
#             {
#                 "name": "host01",
#                 "port": 514,
#                 "protocol": "tcp"
#             }
#         ],
#         "level": {
#             "facility": "AAA",
#             "severity": "alerts"
#         },
#         "persistent": {
#             "size": 4096
#         },
#         "policy": {
#             "invert_result": true,
#             "match_list": "list01"
#         },
#         "vrfs": [
#             {
#                 "name": "vrf01",
#                 "source_interface": "Ethernet1"
#             },
#             {
#                 "hosts": [
#                     {
#                         "name": "24.1.1.1",
#                         "port": 33
#                     },
#                     {
#                         "name": "hostvrf1",
#                         "port": 514,
#                         "protocol": "tcp"
#                     }
#                 ],
#                 "name": "vrf02"
#             }
#         ]
#     },
#

# Using rendered:
- name: Render provided configuration
  arista.eos.eos_logging_global:
    config:
      format:
        timestamp:
          traditional:
            timezone: true
      level:
        facility: "AAA"
        severity: "alerts"
      persistent:
        size: 4096
      policy:
        invert_result: true
        match_list: "list01"
      hosts:
        - name: "host01"
          protocol: "tcp"
        - name: "11.11.11.1"
          port: 25
      vrfs:
        - name: "vrf01"
          source_interface: "Ethernet1"
        - name: "vrf02"
          hosts:
            - name: "hostvrf1"
              protocol: "tcp"
            - name: "24.1.1.1"
              port: "33"
# Module Execution:

# "rendered": [
#         "logging host host01 protocol tcp",
#         "logging host 11.11.11.1 25",
#         "logging vrf vrf01 source-interface Ethernet1",
#         "logging vrf vrf02 host hostvrf1 protocol tcp",
#         "logging vrf vrf02 host 24.1.1.1 33",
#         "logging format timestamp traditional timezone",
#         "logging level AAA alerts",
#         "logging persistent 4096",
#         "logging policy match invert-result match-list list01 discard"
#     ]
#

作者

  • Gomathi Selvi Srinivasan (@GomathiselviS)