salt.states.slack#

Send a message to Slack#

This state is useful for sending messages to Slack during state runs.

New in version 2015.5.0.

slack-message:
  slack.post_message:
    - channel: '#general'
    - from_name: SuperAdmin
    - message: 'This state was executed successfully.'
    - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15

The api key can be specified in the master or minion configuration like below:

slack:
  api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15
salt.states.slack.post_message(name, **kwargs)#

Send a message to a Slack channel.

slack-message:
  slack.post_message:
    - channel: '#general'
    - from_name: SuperAdmin
    - message: 'This state was executed successfully.'
    - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15

Changed in version 3006.28: from_name is now optional. Slack deprecated the ability for classic/custom-bot apps to override the bot's display name and icon via chat.postMessage on March 31, 2025 (see https://api.slack.com/changelog/2024-09-legacy-custom-bots-classic-apps-deprecation). Omit from_name and icon and configure the display name and icon in the Slack app settings instead.

The following parameters are required:

api_key parameters:
name

The unique name for this event.

channel

The channel to send the message to. Can either be the ID or the name.

message

The message that is to be sent to the Slack channel.

The following parameters are optional:

api_key

The api key for Slack to use for authentication, if not specified in the configuration options of master or minion.

from_name

Deprecated. Formerly the name shown in the "from" field. Slack rejects this for modern apps; configure the display name in the Slack app settings instead.

icon

Deprecated. Formerly a URL to an image to use as the icon for this message. Slack rejects this for modern apps; configure the icon in the Slack app settings instead.

webhook parameters:
name

The unique name for this event.

message

The message that is to be sent to the Slack channel.

color

The color of border of left side

short

An optional flag indicating whether the value is short enough to be displayed side-by-side with other values.

webhook

The identifier of WebHook (URL or token).

channel

The channel to use instead of the WebHook default.

username

Username to use instead of WebHook default.

icon_emoji

Icon to use instead of WebHook default.