def dashboard_absent(name, hosts=None, profile='grafana'):
 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

def dashboard_absent ( name , hosts = None , profile = 'grafana' ) : 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
ensure the named grafana dashboard is deleted .