Is content-type "JSON" supported by Slack Module in Ansible 2.7.10 ?

Hello,

I’m attempting to send a message to Slack channel using Ansible’s Slack module as follows:

local_action: module: slack channel: ... token: ... msg: [{"type":"section","text":{"type":"mrkdwn","text":"App deployment started for commit <https://github.com | 1ehe2e38> to production"}}]

The JSON payload makes it to the channel but is rendered as plain text:

[{'type': 'section', 'text': {'type': 'mrkdwn', 'text': 'App deployment started for commit 1ehe2e38 to production'}}]

The goal is to have it rendered as follows

App deployment started for commit [1ehe2e38](http://someurl/) to production

where the commit is a hyperlink to GitHub.

I’m able to send this JSON and have it be properly formatter using Slack’s Block Kit builder as seen here.

Question: Is content-type “JSON” supported by Slack Module in Ansible 2.7.10 ? If it is, what am I doing incorrectly ?

Hi Jourdan,

This type of question is better suited for the forum: https://groups.google.com/forum/#!forum/ansible-project This distribution list is for Ansible Dev.

In your example you want to pass the message, not the payload, slack module takes care of that for you already. See this example and a screenshot of the results: https://gist.github.com/tonyskapunk/731da1c2be33ebda307153cdcda982f6

The Ansible documentation for the slack module (https://docs.ansible.com/ansible/latest/modules/slack_module.html) points to the Slack documentation which includes how to link messages: https://api.slack.com/docs/message-formatting#linking_to_urls

Hope that helps.

That did it! Thank you.

Feel free to delete/move this message since it’s not in the right placed.