salt.modules.slack_notify
Module for sending messages to Slack
New in version 2015.5.0.
- configuration
-
This module can be used by either passing an api key and version directly or by specifying both in a configuration profile in the salt master/minion config.
For example:
slack: api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15
-
Send message to Slack incoming webhook.
- Parameters
-
message -- The topic of message.
attachment -- The message to send to the Slack WebHook.
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.
identifier -- The identifier of WebHook.
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.
- Returns
-
Boolean if message was sent successfully.
CLI Example:
salt '*' slack.call_hook message='Hello, from SaltStack'
salt.modules.slack_notify.call_hook(message, attachment=None, color='good', short=False, identifier=None, channel=None, username=None, icon_emoji=None)
-
Find a room by name and return it.
- Parameters
-
name -- The room name.
api_key -- The Slack admin api key.
- Returns
-
The room object.
CLI Example:
salt '*' slack.find_room name="random" salt '*' slack.find_room name="random" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
salt.modules.slack_notify.find_room(name, api_key=None)
-
Find a user by name and return it.
- Parameters
-
name -- The user name.
api_key -- The Slack admin api key.
- Returns
-
The user object.
CLI Example:
salt '*' slack.find_user name="ThomasHatch" salt '*' slack.find_user name="ThomasHatch" api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
salt.modules.slack_notify.find_user(name, api_key=None)
-
List all Slack rooms.
- Parameters
-
api_key -- The Slack admin api key.
- Returns
-
The room list.
CLI Example:
salt '*' slack.list_rooms salt '*' slack.list_rooms api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
salt.modules.slack_notify.list_rooms(api_key=None)
-
List all Slack users.
- Parameters
-
api_key -- The Slack admin api key.
- Returns
-
The user list.
CLI Example:
salt '*' slack.list_users salt '*' slack.list_users api_key=peWcBiMOS9HrZG15peWcBiMOS9HrZG15
salt.modules.slack_notify.list_users(api_key=None)
-
Send a message to a Slack channel.
Changed in version 3003: Added attachments and blocks kwargs
- Parameters
-
channel -- The channel name, either will work.
message -- The message to send to the Slack channel.
from_name -- Specify who the message is from.
api_key -- The Slack api key, if not specified in the configuration.
icon -- URL to an image to use as the icon for this message
attachments -- Any attachments to be sent with the message.
blocks -- Any blocks to be sent with the message.
- Returns
-
Boolean if message was sent successfully.
CLI Example:
salt '*' slack.post_message channel="Development Room" message="Build is done" from_name="Build Server"
salt.modules.slack_notify.post_message(channel, message, from_name, api_key=None, icon=None, attachments=None, blocks=None)
© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.slack_notify.html