Slack Callback Plugin Usage

I’m trying to use the Slack callback plugin (https://docs.ansible.com/ansible/devel/plugins/callback/slack.html) in the hopes that it will send notifications as a playbook is executed and when it completes successfully or otherwise.

Unfortunately the documentation is poor bordering on non-existant. What I have been able to glean is:

  1. Install prettytable python library
  2. Update ansible.cfg with “callback_whitelist = slack”
    From there it all gets a bit murky. I should be able to setup some ini entries - no idea where so I took a wild guess and added this to ansible.cfg

[callback_slack]
webhook_url = https://hooks.slack.com/services///
channel = #preprod

Which gives this error when running a playbook:

ERROR! Unexpected Exception, this is probably a bug: ‘webook_url’
the full traceback was:

Traceback (most recent call last):
File “/usr/bin/ansible-playbook”, line 106, in
exit_code = cli.run()
File “/usr/lib/python2.7/site-packages/ansible/cli/playbook.py”, line 130, in run
results = pbex.run()
File “/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py”, line 90, in run
self._tqm.load_callbacks()
File “/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py”, line 202, in load_callbacks
callback_obj = callback_plugin()
File “/usr/lib/python2.7/site-packages/ansible/plugins/callback/slack.py”, line 93, in init
self.webhook_url = self._plugin_options[‘webook_url’]
KeyError: ‘webook_url’

Apart from getting this to work my other requirement that I’m not sure how to meet is how to I set the channel to match the name of the inventory I’m deploying to? Ideally I’d set the ini setting to something like “{{ inventory_dir|basename }}” but not sure if it would support that. Otherwise I need to set “env:SLACK_CHANNEL” which I don’t know how to do in Ansible.

NOTE: My playbooks are targeting windows hosts.

Versions:
ansible-playbook 2.4.0.0
python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

Thanks
Andrew

That error has been fixed as of 2.4.1. Please try upgrading and test again. 2.4.2 is the current stable release.

After upgrading, I believe everything should work as you have configured it.