Sending Messages to a Discord Channel via Ansible

TL;DR

For those who know what they're doing, code is right here. Strip what you need and change what you know.

Explanation and Setup

I'll keep this one pretty brief, it's not too hard honestly. Sometimes, you just want to be able to send a message to a Discord channel via an Ansible task. No need to write or install your own module!

I have my own personal STIG playbook that I use and run to update repos and subsequent packages. At the end of the playbook, I use these two tasks to let me know when a reboot is required during a maintenance period.

If you haven't yet, you'll need to setup a webhook in a Discord channel. Provided you're a mod or admin of a Discord server, you can do this in literally a minute.

On desktop, hover over the channel you wish to send Discord messages to. Click on the gear icon, then on the following menu, click on 'Integrations'. After that, click on 'New Webhook'. You don't need to set an avatar picture unless you want to. After that, click on 'Copy Webhook URL' and use that in the code above.