Ejemplo n.º 1
0
def absent(dest, username, check_mode):
    """ Ensures user is absent

    Returns (msg, changed) """
    if LooseVersion(passlib.__version__) >= LooseVersion('1.6'):
        ht = HtpasswdFile(dest, new=False)
    else:
        ht = HtpasswdFile(dest)

    if username not in ht.users():
        return ("%s not present" % username, False)
    else:
        if not check_mode:
            ht.delete(username)
            ht.save()
        return ("Remove %s" % username, True)
Ejemplo n.º 2
0
def absent(dest, username, check_mode):
    """ Ensures user is absent

    Returns (msg, changed) """
    if StrictVersion(passlib.__version__) >= StrictVersion('1.6'):
        ht = HtpasswdFile(dest, new=False)
    else:
        ht = HtpasswdFile(dest)

    if username not in ht.users():
        return ("%s not present" % username, False)
    else:
        if not check_mode:
            ht.delete(username)
            ht.save()
        return ("Remove %s" % username, True)
Ejemplo n.º 3
0
def absent(dest, username, check_mode):
    """ Ensures user is absent

    Returns (msg, changed) """
    if not os.path.exists(dest):
        raise ValueError("%s does not exists" % dest)

    if StrictVersion(passlib.__version__) >= StrictVersion('1.6'):
        ht = HtpasswdFile(dest, new=False)
    else:
        ht = HtpasswdFile(dest)

    if username not in ht.users():
        return ("%s not present" % username, False)
    else:
        if not check_mode:
            ht.delete(username)
            ht.save()
        return ("Remove %s" % username, True)
Ejemplo n.º 4
0
def rm_user(username):
  htcontent = HtpasswdFile(app.config['HTPASSWD_FILE'])
  htcontent.delete(username)
  htcontent.save()