summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2015-12-04 09:18:45 -0800
committerToshio Kuratomi <toshio@fedoraproject.org>2015-12-04 09:20:29 -0800
commit191347676eea08817da3fb237f24cdbf2d16e307 (patch)
tree81f99d0562914f0e9e52ff993c6054c3573ea4b3
parenta1ea2182b77147f5c183a35223cfb9c926ac186b (diff)
downloadansible-modules-core-191347676eea08817da3fb237f24cdbf2d16e307.tar.gz
When the password file does not exist and we're making sure the user isn't in the password file, change error into a warning
Warning catches typos in the filename. Since the playbook is saying "make sure this user doesn't have an entry" it makes more sense to warn than to error. Fixes #2619
-rw-r--r--web_infrastructure/htpasswd.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/web_infrastructure/htpasswd.py b/web_infrastructure/htpasswd.py
index 4253f157..83a64453 100644
--- a/web_infrastructure/htpasswd.py
+++ b/web_infrastructure/htpasswd.py
@@ -97,6 +97,7 @@ else:
apache_hashes = ["apr_md5_crypt", "des_crypt", "ldap_sha1", "plaintext"]
+
def create_missing_directories(dest):
destpath = os.path.dirname(dest)
if not os.path.exists(destpath):
@@ -155,9 +156,6 @@ 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:
@@ -244,6 +242,9 @@ def main():
if state == 'present':
(msg, changed) = present(path, username, password, crypt_scheme, create, check_mode)
elif state == 'absent':
+ if not os.path.exists(path):
+ module.exit_json(msg="%s not present" % username,
+ warnings="%s does not exist" % path, changed=False)
(msg, changed) = absent(path, username, check_mode)
else:
module.fail_json(msg="Invalid state: %s" % state)