From e422f1889857dd0a094acf82b7340fbecb7f9023 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 3 Apr 2019 20:39:10 +0200 Subject: [PATCH] acme_certficate: allow to write files to CWD (#54754) * Allow to write files to CWD. * Add changelog. --- changelogs/fragments/54754-acme_certificate-cwd.yml | 2 ++ lib/ansible/module_utils/acme.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/54754-acme_certificate-cwd.yml diff --git a/changelogs/fragments/54754-acme_certificate-cwd.yml b/changelogs/fragments/54754-acme_certificate-cwd.yml new file mode 100644 index 00000000000..dc8226426f6 --- /dev/null +++ b/changelogs/fragments/54754-acme_certificate-cwd.yml @@ -0,0 +1,2 @@ +bugfixes: +- "acme_certificate - writing result failed when no path was specified (i.e. destination in current working directory)." diff --git a/lib/ansible/module_utils/acme.py b/lib/ansible/module_utils/acme.py index 54f9aa6a0db..4576e86e61e 100644 --- a/lib/ansible/module_utils/acme.py +++ b/lib/ansible/module_utils/acme.py @@ -119,9 +119,10 @@ def write_file(module, dest, content): raise ModuleFailException("Destination %s not readable" % (dest)) checksum_dest = module.sha1(dest) else: - if not os.access(os.path.dirname(dest), os.W_OK): + dirname = os.path.dirname(dest) or '.' + if not os.access(dirname, os.W_OK): os.remove(tmpsrc) - raise ModuleFailException("Destination dir %s not writable" % (os.path.dirname(dest))) + raise ModuleFailException("Destination dir %s not writable" % (dirname)) if checksum_src != checksum_dest: try: shutil.copyfile(tmpsrc, dest)