community.general.matrix 模块 – 发送通知到 Matrix
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您使用的是 ansible 包,您可能已经安装了这个集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要进一步的要求才能使用此模块,有关详细信息,请参阅要求。
要在 playbook 中使用它,请指定:community.general.matrix。
概要
- 此模块将 HTML 格式的通知发送到 Matrix 房间。 
要求
在执行此模块的主机上需要以下要求。
- matrix-client (Python 库) 
参数
| 参数 | 注释 | 
|---|---|
| homeserver 的 URL,CS-API 在这里可访问 | |
| 要发送到 Matrix 的消息的 HTML 格式 | |
| 要发送到 Matrix 的消息的纯文本格式,通常是 Markdown | |
| 用于登录的密码 | |
| 要将通知发送到的房间的 ID | |
| 用于 API 调用的身份验证令牌。如果提供,则不需要 user_id 和密码 | |
| 用户的用户 ID | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完整 | 可以在  | |
| 支持:无 | 当处于差异模式时,将返回已更改的内容(或可能需要在  | 
示例
- name: Send matrix notification with token
  community.general.matrix:
    msg_plain: "**hello world**"
    msg_html: "<b>hello world</b>"
    room_id: "!12345678:server.tld"
    hs_url: "https://matrix.org"
    token: "{{ matrix_auth_token }}"
- name: Send matrix notification with user_id and password
  community.general.matrix:
    msg_plain: "**hello world**"
    msg_html: "<b>hello world</b>"
    room_id: "!12345678:server.tld"
    hs_url: "https://matrix.org"
    user_id: "ansible_notification_bot"
    password: "{{ matrix_auth_password }}"
