community.general.rocketchat 模块 – 向 Rocket Chat 发送通知

注意

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

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

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

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

概要

  • rocketchat 模块通过 Incoming WebHook 集成向 Rocket Chat 发送通知。

参数

参数

注释

attachments

列表 / 元素=字典

定义附件列表。

channel

字符串

发送消息的频道。如果缺失,则消息将发送到创建 webhook 时为 token 指定的频道。

color

字符串

允许文本使用默认颜色 - 使用默认值“normal”不发送消息开头的自定义颜色条

选项

  • "normal" ← (默认)

  • "good"

  • "warning"

  • "danger"

domain

字符串 / 必需

您环境的域名,不含协议。(例如 example.comchat.example.com。)

icon_emoji

字符串

消息发送者的表情符号。可用表情符号的表示形式可以从 Rocket Chat 获取。

例如 :thumbsup:

如果设置了 icon_emoji,则不会使用 icon_url

icon_url

字符串

消息发送者图标的 URL。

默认: "https://docs.ansible.org.cn/favicon.ico"

整数

自动为 msg 中的频道和用户名创建链接。

选项

  • 1 ← (默认)

  • 0

msg

字符串

要发送的消息。

protocol

字符串

在 webhook URL 前指定用于发送通知消息的协议(即 httphttps)。

选项

  • "http"

  • "https" ← (默认)

token

字符串 / 必需

Rocket Chat Incoming Webhook 集成令牌。这为 Rocket Chat 的 Incoming webhook 提供发布消息的身份验证。

username

字符串

这是消息的发送者。

默认: "Ansible"

validate_certs

布尔值

如果为 false,则不会验证 SSL 证书。这仅应在使用自签名证书的个人控制站点上使用。

选项

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持: 不支持

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

diff_mode

支持: 不支持

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

示例

- name: Send notification message via Rocket Chat
  community.general.rocketchat:
    token: thetoken/generatedby/rocketchat
    domain: chat.example.com
    msg: '{{ inventory_hostname }} completed'
  delegate_to: localhost

- name: Send notification message via Rocket Chat all options
  community.general.rocketchat:
    domain: chat.example.com
    token: thetoken/generatedby/rocketchat
    msg: '{{ inventory_hostname }} completed'
    channel: #ansible
    username: 'Ansible on {{ inventory_hostname }}'
    icon_url: http://www.example.com/some-image-file.png
    link_names: 0
  delegate_to: localhost

- name: Insert a color bar in front of the message for visibility purposes and use the default webhook icon and name configured in rocketchat
  community.general.rocketchat:
    token: thetoken/generatedby/rocketchat
    domain: chat.example.com
    msg: '{{ inventory_hostname }} is alive!'
    color: good
    username: ''
    icon_url: ''
  delegate_to: localhost

- name: Use the attachments API
  community.general.rocketchat:
    token: thetoken/generatedby/rocketchat
    domain: chat.example.com
    attachments:
      - text: Display my system load on host A and B
        color: #ff00dd
        title: System load
        fields:
          - title: System A
            value: 'load average: 0,74, 0,66, 0,63'
            short: true
          - title: System B
            value: 'load average: 5,16, 4,64, 2,43'
            short: true
  delegate_to: localhost

返回值

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

描述

changed

布尔值

指示是否进行了任何更改的标志。

返回:成功

示例: false

作者

  • Ramon de la Fuente (@ramondelafuente)