def format_failure_message(result):
    """
    Output a formatted version of the failure
    message, if the result contains one.

    :param result: result to inspect
    :return: message
    """
    if 'msg' in result:
        # this is most likely a module failure
        if isinstance(result['msg'], list):
            error_message = '\n'.join(result['msg'])
        else:
            error_message = result['msg']

        return '{}\n'.format(error_message)

    return ''