Mail Callback

Hello!

I am trying to receive email alerts anytime a playbook fails.

Could anyone guide me as to how I can configure / setup the mail callback feature to work?

I tried un-commenting the following line in ansible.cfg and added the following lines:
`
callback_whitelist = timer, mail (uncommented)

[callback_mail] (added)
to = user@example.com (added)
`

However, I got the following error when I ran the playbook:

[WARNING]: Failure using method (v2_runner_on_failed) in callback plugin (<ansible.plugins.callback.mail.CallbackModule object at
0x25c8e10>): sub() got an unexpected keyword argument ‘flags’

Callback Exception:
File “/usr/lib/python2.6/site-packages/ansible/executor/task_queue_manager.py”, line 374, in send_callback
method(*new_args, **kwargs)
File “/usr/lib/python2.6/site-packages/ansible/plugins/callback/mail.py”, line 220, in v2_runner_on_failed
self.mail_result(result, ‘Failed’)
File “/usr/lib/python2.6/site-packages/ansible/plugins/callback/mail.py”, line 182, in mail_result
body += self.indent(‘%s\n’ % result._task.action)
File “/usr/lib/python2.6/site-packages/ansible/plugins/callback/mail.py”, line 136, in indent
return re.sub(‘^’, ’ ’ * indent, multiline, flags=re.MULTILINE)

Any assistance will be much appreciated !

Regards
JS

The traceback you're getting says "unexpected keyword argument
'flags'". That argument was added in Python 2.7 which is also the
minimal Python version supported by Ansible on the controller side.

M.

But that's being done for 2.7. What Ansible version are you running?

Hi Martin

Thanks for the swift response!

Ah ok, I shall upgrade the Python Version in that case!

I am currently running: ansible 2.5.5

Regards
JS