slack – Send Slack notifications
slack – Send Slack notifications
New in version 1.6.
Synopsis
- The
slack
module sends notifications to http://slack.com via the Incoming WebHook integration
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
attachments - |
Define a list of attachments. This list mirrors the Slack JSON API. For more information, see also in the (https://api.slack.com/docs/attachments). | |
channel - |
Channel to send the message to. If absent, the message goes to the channel selected for the token. | |
color - added in 2.0 |
|
Allow text to use default colors - use the default of 'normal' to not send a custom color bar at the start of the message |
domain - |
Slack (sub)domain for your environment without protocol. (i.e. | |
icon_emoji - |
Emoji for the message sender. See Slack documentation for options. (if icon_emoji is set, icon_url will not be used) | |
icon_url - |
Url for the message sender's icon (default | |
link_names - |
|
Automatically create links for channels and usernames in msg. |
msg - |
Message to send. Note that the module does not handle escaping characters. Plain-text angle brackets and ampersands should be converted to HTML entities (e.g. & to &) before sending. See Slack's documentation (https://api.slack.com/docs/message-formatting) for more. | |
parse - |
|
Setting for the message parser at Slack |
token - / required |
Slack integration token. This authenticates you to the slack service. Prior to 1.8, a token looked like | |
username - |
Default: "Ansible" |
This is the sender of the message. |
validate_certs boolean |
|
If |
Examples
- name: Send notification message via Slack
slack:
token: thetoken/generatedby/slack
msg: '{{ inventory_hostname }} completed'
delegate_to: localhost
- name: Send notification message via Slack all options
slack:
token: thetoken/generatedby/slack
msg: '{{ inventory_hostname }} completed'
channel: '#ansible'
username: 'Ansible on {{ inventory_hostname }}'
icon_url: http://www.example.com/some-image-file.png
link_names: 0
parse: 'none'
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 Slack
slack:
token: thetoken/generatedby/slack
msg: '{{ inventory_hostname }} is alive!'
color: good
username: ''
icon_url: ''
- name: Use the attachments API
slack:
token: thetoken/generatedby/slack
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
- name: Send a message with a link using Slack markup
slack:
token: thetoken/generatedby/slack
msg: We sent this message using <https://www.ansible.com|Ansible>!
- name: Send a message with angle brackets and ampersands
slack:
token: thetoken/generatedby/slack
msg: This message has <brackets> & ampersands in plain text.
Status
- This module is guaranteed to have no backward incompatible interface changes going forward. [stableinterface]
- This module is maintained by the Ansible Community. [community]
Authors
- Ramon de la Fuente (@ramondelafuente)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/slack_module.html