W3cubDocs

/Ansible

slack - Send Slack notifications

New in version 1.6.

Synopsis

The slack module sends notifications to http://slack.com via the Incoming WebHook integration

Options

parameter required default choices comments
attachments
no None
Define a list of attachments. This list mirrors the Slack JSON API. For more information, see https://api.slack.com/docs/attachments
channel
no None
Channel to send the message to. If absent, the message goes to the channel selected for the token.
color
(added in 2.0)
no normal
  • normal
  • good
  • warning
  • danger
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
no None
Slack (sub)domain for your environment without protocol. (i.e. future500.slack.com) In 1.8 and beyond, this is deprecated and may be ignored. See token documentation for information.
icon_emoji
no None
Emoji for the message sender. See Slack documentation for options. (if icon_emoji is set, icon_url will not be used)
icon_url
no
Url for the message sender's icon (default https://www.ansible.com/favicon.ico)
link_names
no 1
  • 1
  • 0
Automatically create links for channels and usernames in msg.
msg
no None
Message to send.
parse
no None
  • full
  • none
Setting for the message parser at Slack
token
yes
Slack integration token. This authenticates you to the slack service. Prior to 1.8, a token looked like 3Ffe373sfhRE6y42Fg3rvf4GlK. In 1.8 and above, ansible adapts to the new slack API where tokens look like G922VJP24/D921DW937/3Ffe373sfhRE6y42Fg3rvf4GlK. If tokens are in the new format then slack will ignore any value of domain. If the token is in the old format the domain is required. Ansible has no control of when slack will get rid of the old API. When slack does that the old format will stop working.
username
no Ansible
This is the sender of the message.
validate_certs
no yes
  • yes
  • no
If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates.

Examples

- name: Send notification message via Slack
  local_action:
    module: slack
    token: thetoken/generatedby/slack
    msg: "{{ inventory_hostname }} completed"

- name: Send notification message via Slack all options
  local_action:
    module: 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'

- 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 notification message via Slack (deprecated API using domain)
  local_action:
    module: slack
    domain: future500.slack.com
    token: thetokengeneratedbyslack
    msg: "{{ inventory_hostname }} completed"

This is an Extras Module

For more information on what this means please read Extras Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/slack_module.html