community.general.sensu_client 模块 – 管理 Sensu 客户端配置

注意

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

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

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

要在剧本中使用它,请指定: community.general.sensu_client

概要

参数

参数

注释

address

字符串

帮助识别和访问客户端的地址。这仅供参考,通常是 IP 地址或主机名。

如果未指定,则默认为由 Ruby Socket.ip_address_list(Sensu 提供)确定的非环回 IPv4 地址。

chef

字典

chef 定义范围,用于配置 Sensu Enterprise Chef 集成(仅限 Sensu Enterprise 用户)。

deregister

布尔值

Sensu 客户端进程停止时是否应创建注销事件。

默认为 false

选项

  • false

  • true

deregistration

字典

注销定义范围,用于配置 Sensu 客户端自动注销。

ec2

字典

ec2 定义范围,用于配置 Sensu Enterprise AWS EC2 集成(仅限 Sensu Enterprise 用户)。

keepalive

字典

keepalive 定义范围,用于配置 Sensu 客户端 keepalive 行为(例如 keepalive 阈值等)。

keepalives

布尔值

Sensu 是否应监控此客户端的 keepalive。

选项

  • false

  • true ← (默认)

name

字符串

客户端的唯一名称。名称不能包含特殊字符或空格。

如果未指定,则默认为由 Ruby Socket.gethostname(Sensu 提供)确定的系统主机名。

puppet

字典

puppet 定义范围,用于配置 Sensu Enterprise Puppet 集成(仅限 Sensu Enterprise 用户)。

redact

列表 / 元素=字符串

在记录和发送客户端 keepalive 时要删除的客户端定义属性(值)。

registration

字典

注册定义范围,用于配置 Sensu 注册事件处理程序。

safe_mode

布尔值

是否为客户端启用安全模式。安全模式需要本地检查定义才能接受检查请求并执行检查。

选项

  • false ← (默认)

  • true

servicenow

字典

servicenow 定义范围,用于配置 Sensu Enterprise ServiceNow 集成(仅限 Sensu Enterprise 用户)。

socket

字典

socket 定义范围,用于配置 Sensu 客户端套接字。

state

字符串

客户端是否存在

选项

  • "present" ← (默认)

  • "absent"

subscriptions

列表 / 元素=字符串

客户端订阅数组,分配给系统的角色和/或职责列表(例如 webserver)。

这些订阅决定客户端执行哪些监控检查,因为检查请求被发送到订阅。

订阅数组项必须是字符串。

属性

属性

支持

描述

check_mode

支持:完全支持

可以在 check_mode 中运行,并在不修改目标的情况下返回更改状态预测。

diff_mode

支持:不支持

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

备注

注意

  • 支持检查模式

示例

# Minimum possible configuration
- name: Configure Sensu client
  community.general.sensu_client:
    subscriptions:
      - default

# With customization
- name: Configure Sensu client
  community.general.sensu_client:
    name: "{{ ansible_fqdn }}"
    address: "{{ ansible_default_ipv4['address'] }}"
    subscriptions:
      - default
      - webserver
    redact:
      - password
    socket:
      bind: 127.0.0.1
      port: 3030
    keepalive:
      thresholds:
        warning: 180
        critical: 300
      handlers:
        - email
      custom:
        - broadcast: irc
      occurrences: 3
  register: client
  notify:
    - Restart sensu-client

- name: Secure Sensu client configuration file
  ansible.builtin.file:
    path: "{{ client['file'] }}"
    owner: "sensu"
    group: "sensu"
    mode: "0600"

- name: Delete the Sensu client configuration
  community.general.sensu_client:
    state: "absent"

返回值

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

描述

config

字典

当状态存在时,有效的客户端配置

返回:成功

示例: {"name": "client", "subscriptions": ["default"]}

file

字符串

客户端配置文件的路径

返回:成功

示例: "/etc/sensu/conf.d/client.json"

作者

  • David Moreau Simard (@dmsimard)