community.general.mattermost (8.5.0) — module

Send Mattermost notifications

Authors: Benjamin Jolivot (@bjolivot)

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

Sends notifications to U(http://your.mattermost.url) via the Incoming WebHook integration.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Send notification message via Mattermost
  community.general.mattermost:
    url: http://mattermost.example.com
    api_key: my_api_key
    text: '{{ inventory_hostname }} completed'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Send notification message via Mattermost all options
  community.general.mattermost:
    url: http://mattermost.example.com
    api_key: my_api_key
    text: '{{ inventory_hostname }} completed'
    channel: notifications
    username: 'Ansible on {{ inventory_hostname }}'
    icon_url: http://www.example.com/some-image-file.png
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Send attachments message via Mattermost
  community.general.mattermost:
    url: http://mattermost.example.com
    api_key: my_api_key
    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

Inputs

    
url:
    description:
    - Mattermost url (i.e. http://mattermost.yourcompany.com).
    required: true
    type: str

text:
    description:
    - Text to send. Note that the module does not handle escaping characters.
    - Required when O(attachments) is not set.
    type: str

api_key:
    description:
    - Mattermost webhook api key. Log into your mattermost site, go to Menu -> Integration
      -> Incoming Webhook -> Add Incoming Webhook. This will give you full URL. O(api_key)
      is the last part. http://mattermost.example.com/hooks/C(API_KEY)
    required: true
    type: str

channel:
    description:
    - Channel to send the message to. If absent, the message goes to the channel selected
      for the O(api_key).
    type: str

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

username:
    default: Ansible
    description:
    - This is the sender of the message (Username Override need to be enabled by mattermost
      admin, see mattermost doc.
    type: str

attachments:
    description:
    - Define a list of attachments.
    - For more information, see U(https://developers.mattermost.com/integrate/admin-guide/admin-message-attachments/).
    - Required when O(text) is not set.
    elements: dict
    type: list
    version_added: 4.3.0
    version_added_collection: community.general

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

payload:
  description: Mattermost payload
  returned: success
  type: str
webhook_url:
  description: URL the webhook is sent to
  returned: success
  type: str