Ensure the named grafana dashboard is deleted.

    name
        Name of the grafana dashboard.

    profile
        A pillar key or dict that contains a list of hosts and an
        elasticsearch index to use.

def dashboard_absent(
        name,
        hosts=None,
        profile='grafana'):
    '''
    Ensure the named grafana dashboard is deleted.

    name
        Name of the grafana dashboard.

    profile
        A pillar key or dict that contains a list of hosts and an
        elasticsearch index to use.
    '''
    ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}

    hosts, index = _parse_profile(profile)
    if not index:
        raise SaltInvocationError('index is a required key in the profile.')

    exists = __salt__['elasticsearch.exists'](
        index=index, id=name, doc_type='dashboard', hosts=hosts
    )

    if exists:
        if __opts__['test']:
            ret['comment'] = 'Dashboard {0} is set to be removed.'.format(
                name
            )
            return ret
        deleted = __salt__['elasticsearch.delete'](
            index=index, doc_type='dashboard', id=name, hosts=hosts
        )
        if deleted:
            ret['result'] = True
            ret['changes']['old'] = name
            ret['changes']['new'] = None
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to delete {0} dashboard.'.format(name)
    else:
        ret['result'] = True
        ret['comment'] = 'Dashboard {0} does not exist.'.format(name)

    return ret