community.general.syslogger 模块 – 在 syslog 中记录消息

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

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

要安装它,请使用:ansible-galaxy collection install community.general

要在 playbook 中使用它,请指定:community.general.syslogger

概要

  • 使用 syslog 将日志条目添加到主机。

参数

参数

注释

facility

字符串

设置日志设备。

选择

  • "kern"

  • "user"

  • "mail"

  • "daemon" ← (默认)

  • "auth"

  • "lpr"

  • "news"

  • "uucp"

  • "cron"

  • "syslog"

  • "local0"

  • "local1"

  • "local2"

  • "local3"

  • "local4"

  • "local5"

  • "local6"

  • "local7"

ident

字符串

在 community.general 0.2.0 中添加

指定将日志发送到 syslog 的应用程序的名称。

默认值: "ansible_syslogger"

log_pid

布尔值

在方括号中记录 PID。

选择

  • false ← (默认)

  • true

msg

字符串 / 必需

这是要放入 syslog 的消息。

priority

字符串

设置日志优先级。

选择

  • "emerg"

  • "alert"

  • "crit"

  • "err"

  • "warning"

  • "notice"

  • "info" ← (默认)

  • "debug"

属性

属性

支持

描述

check_mode

支持:

可以在 check_mode 中运行并返回更改状态预测,而无需修改目标。

diff_mode

支持:

在 diff 模式下运行时,将返回有关已更改的内容(或可能需要在 check_mode 中更改的内容)的详细信息。

示例

- name: Simple Usage
  community.general.syslogger:
    msg: "I will end up as daemon.info"

- name: Send a log message with err priority and user facility with log_pid
  community.general.syslogger:
    msg: "Hello from Ansible"
    priority: "err"
    facility: "user"
    log_pid: true

- name: Specify the name of application which is sending log message
  community.general.syslogger:
    ident: "MyApp"
    msg: "I want to believe"
    priority: "alert"

返回值

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

描述

facility

字符串

Syslog 设备

返回:总是

示例: "info"

ident

字符串

在 community.general 0.2.0 中添加

将消息发送到日志的应用程序的名称

返回:总是

示例: "ansible_syslogger"

log_pid

布尔值

日志 PID 状态

返回:总是

示例: true

msg

字符串

发送到 syslog 的消息

返回:总是

示例: "来自 Ansible 的问候"

priority

字符串

优先级级别

返回:总是

示例: "daemon"

作者

  • Tim Rightnour (@garbled1)