Ensure that the named database is present with the specified options

    name
        The name of the database to manage
    owner
        Adds owner using AUTHORIZATION option
    Grants
        Can only be a list of strings

def present(name, owner=None, grants=None, **kwargs):
    '''
    Ensure that the named database is present with the specified options

    name
        The name of the database to manage
    owner
        Adds owner using AUTHORIZATION option
    Grants
        Can only be a list of strings
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}

    if __salt__['mssql.role_exists'](name, **kwargs):
        ret['comment'] = 'Role {0} is already present (Not going to try to set its grants)'.format(name)
        return ret
    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'Role {0} is set to be added'.format(name)
        return ret

    role_created = __salt__['mssql.role_create'](name, owner=owner, grants=grants, **kwargs)
    if role_created is not True:  # Non-empty strings are also evaluated to True, so we cannot use if not role_created:
        ret['result'] = False
        ret['comment'] += 'Role {0} failed to be created: {1}'.format(name, role_created)
        return ret
    ret['comment'] += 'Role {0} has been added'.format(name)
    ret['changes'][name] = 'Present'
    return ret