Skip to content

Commit

Permalink
Send cards instead of usual messages for Slack
Browse files Browse the repository at this point in the history
  • Loading branch information
br0ziliy committed Jul 21, 2017
1 parent 18e9624 commit a1ffb2c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,22 @@ def task_poller(self):
self.log.debug("Task list: {}".format(self['tasks']))
tasklist = self['tasks']
for uuid in list(tasklist):
author = tasklist[uuid]
author = self.build_identifier(tasklist[uuid])
(result, status) = tasks.get_task_info(uuid)
self.log.debug("Processing task: {}; status: {}, "
"result:\n{}".format(uuid, status, result))
if status in ['finished', 'failed'] and result:
self.send_templated(self.build_identifier(author),
'task_info', {'uuid': uuid, 'status': status, 'task_info': result})
if self._bot.mode == 'slack':
card_color = 'green'
if status != 'finished': card_color = 'red'
self.send_card(to=author,
title="Task " + uuid + " finished",
body=result,
color=card_color)
else:
self.send_templated(author,
'task_info',
{'uuid': uuid, 'status': status, 'task_info': result})
del tasklist[uuid]
self['tasks'] = tasklist
elif status == 'started':
Expand Down

0 comments on commit a1ffb2c

Please sign in to comment.