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:21:40 -0800
commita10f61ce8af3f3a091a4765a22e12988f6beff15 (patch)
tree78f925a1b0b93795d59a851f62275e5563eeba7b
parent0336922672ffabe95262873e835197d8666e390a (diff)
downloadansible-modules-core-a10f61ce8af3f3a091a4765a22e12988f6beff15.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)