'Display info about playbook statistics'

def v2_playbook_on_stats(self, stats):

    hosts = sorted(stats.processed.keys())
    t = prettytable.PrettyTable(['Host', 'Ok', 'Changed', 'Unreachable', 'Failures'])
    failures = False
    unreachable = False
    for h in hosts:
        s = stats.summarize(h)
        if (s['failures'] > 0):
            failures = True
        if (s['unreachable'] > 0):
            unreachable = True
        t.add_row(([h] + [s[k] for k in ['ok', 'changed', 'unreachable', 'failures']]))
    attachments = []
    msg_items = [('*Playbook    Complete*    (_%s_)' % self.guid)]
    if (failures or unreachable):
        color = 'danger'
        msg_items.append('\n*Failed!*')
    else:
        color = 'good'
        msg_items.append('\n*Success!*')
    msg_items.append(('```\n%s\n```' % t))
    msg = '\n'.join(msg_items)
    attachments.append({'fallback': msg, 'fields': [{'value': msg}], 'color': color, 'mrkdwn_in': ['text', 'fallback', 'fields']})
    self.send_msg(attachments=attachments)
