community.general.rocketchat (8.5.0) — module

Send notifications to Rocket Chat

Authors: Ramon de la Fuente (@ramondelafuente)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

The C(rocketchat) module sends notifications to Rocket Chat via the Incoming WebHook integration

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
msg:
    description:
    - Message to be sent.
    type: str

color:
    choices:
    - normal
    - good
    - warning
    - danger
    default: normal
    description:
    - Allow text to use default colors - use the default of 'normal' to not send a custom
      color bar at the start of the message
    type: str

token:
    description:
    - Rocket Chat Incoming Webhook integration token.  This provides authentication to
      Rocket Chat's Incoming webhook for posting messages.
    required: true
    type: str

domain:
    description:
    - The domain for your environment without protocol. (For example V(example.com) or
      V(chat.example.com).)
    required: true
    type: str

channel:
    description:
    - Channel to send the message to. If absent, the message goes to the channel selected
      for the O(token) specified during the creation of webhook.
    type: str

icon_url:
    default: https://docs.ansible.com/favicon.ico
    description:
    - URL for the message sender's icon.
    type: str

protocol:
    choices:
    - http
    - https
    default: https
    description:
    - Specify the protocol used to send notification messages before the webhook URL (that
      is, V(http) or V(https)).
    type: str

username:
    default: Ansible
    description:
    - This is the sender of the message.
    type: str

icon_emoji:
    description:
    - Emoji for the message sender. The representation for the available emojis can be
      got from Rocket Chat.
    - For example V(:thumbsup:).
    - If O(icon_emoji) is set, O(icon_url) will not be used.
    type: str

link_names:
    choices:
    - 1
    - 0
    default: 1
    description:
    - Automatically create links for channels and usernames in O(msg).
    type: int

attachments:
    description:
    - Define a list of attachments.
    elements: dict
    type: list

validate_certs:
    default: true
    description:
    - If V(false), SSL certificates will not be validated. This should only be used on
      personally controlled sites using self-signed certificates.
    type: bool

Outputs

changed:
  description: A flag indicating if any change was made or not.
  returned: success
  sample: false
  type: bool