def user_exists(name, password=None, htpasswd_file=None, options='',
                force=False, runas=None):
    ret = {'name': name,
           'changes': {},
           'comment': '',
           'result': None}

    grep = __salt__['file.grep']
    grep_ret = grep(htpasswd_file, name)
    if grep_ret['retcode'] != 0 or force:
        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = ('User {0!r} is set to be added to htpasswd '
                              'file').format(name)
            ret['changes'] = {name: True}
            return ret

        useradd_ret = __salt__['webutil.useradd_all'](htpasswd_file, name,
                                                      password, opts=options,
                                                      runas=runas)
        if useradd_ret['retcode'] == 0:
            ret['result'] = True
            ret['comment'] = useradd_ret['stderr']
            ret['changes'] = {name: True}
            return ret
        else:
            ret['result'] = False
            ret['comment'] = useradd_ret['stderr']
            return ret

    if __opts__['test'] and ret['changes']:
        ret['result'] = None
    else:
        ret['result'] = True
    ret['comment'] = 'User already known'
    return ret
Make sure the user is inside the specified htpasswd file
dataset/ETHPy150Open saltstack/salt/salt/states/htpasswd.py/user_exists