diff options
author | Felix Fontein <felix@fontein.de> | 2019-01-03 12:34:46 +0100 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-01-07 11:09:28 -0800 |
commit | 4561a5007baa12e5333846a15047bce181805cbb (patch) | |
tree | 63f9b1f33d4519cc35312f228b1972b7af6f1f06 | |
parent | 7ced444af83004ef1ccc02f8ce86e59a8bfaa915 (diff) | |
download | ansible-4561a5007baa12e5333846a15047bce181805cbb.tar.gz |
openssl_*: prevent error when path includes no path (#50322)
* Prevent error when path includes no path.
* Add changelog.
(cherry picked from commit 5c5cd2dc4d0a58a12233397d9682233f7b4c5e9a)
-rw-r--r-- | changelogs/fragments/50322-openssl-path-error.yml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/crypto/openssl_certificate.py | 2 | ||||
-rw-r--r-- | lib/ansible/modules/crypto/openssl_csr.py | 2 | ||||
-rw-r--r-- | lib/ansible/modules/crypto/openssl_dhparam.py | 2 | ||||
-rw-r--r-- | lib/ansible/modules/crypto/openssl_pkcs12.py | 2 | ||||
-rw-r--r-- | lib/ansible/modules/crypto/openssl_privatekey.py | 2 | ||||
-rw-r--r-- | lib/ansible/modules/crypto/openssl_publickey.py | 2 |
7 files changed, 8 insertions, 6 deletions
diff --git a/changelogs/fragments/50322-openssl-path-error.yml b/changelogs/fragments/50322-openssl-path-error.yml new file mode 100644 index 0000000000..4debcb6100 --- /dev/null +++ b/changelogs/fragments/50322-openssl-path-error.yml @@ -0,0 +1,2 @@ +bugfixes: +- "openssl_* - fix error when ``path`` contains a file name without path." diff --git a/lib/ansible/modules/crypto/openssl_certificate.py b/lib/ansible/modules/crypto/openssl_certificate.py index b29afccf6a..32db6e4017 100644 --- a/lib/ansible/modules/crypto/openssl_certificate.py +++ b/lib/ansible/modules/crypto/openssl_certificate.py @@ -1041,7 +1041,7 @@ def main(): if module.params['provider'] != 'assertonly' and module.params['csr_path'] is None: module.fail_json(msg='csr_path is required when provider is not assertonly') - base_dir = os.path.dirname(module.params['path']) + base_dir = os.path.dirname(module.params['path']) or '.' if not os.path.isdir(base_dir): module.fail_json( name=base_dir, diff --git a/lib/ansible/modules/crypto/openssl_csr.py b/lib/ansible/modules/crypto/openssl_csr.py index 0c9d77537a..cba9e06812 100644 --- a/lib/ansible/modules/crypto/openssl_csr.py +++ b/lib/ansible/modules/crypto/openssl_csr.py @@ -563,7 +563,7 @@ def main(): except AttributeError: module.fail_json(msg='You need to have PyOpenSSL>=0.15 to generate CSRs') - base_dir = os.path.dirname(module.params['path']) + base_dir = os.path.dirname(module.params['path']) or '.' if not os.path.isdir(base_dir): module.fail_json(name=base_dir, msg='The directory %s does not exist or the file is not a directory' % base_dir) diff --git a/lib/ansible/modules/crypto/openssl_dhparam.py b/lib/ansible/modules/crypto/openssl_dhparam.py index 849477c1f8..2efc0efb83 100644 --- a/lib/ansible/modules/crypto/openssl_dhparam.py +++ b/lib/ansible/modules/crypto/openssl_dhparam.py @@ -191,7 +191,7 @@ def main(): add_file_common_args=True, ) - base_dir = os.path.dirname(module.params['path']) + base_dir = os.path.dirname(module.params['path']) or '.' if not os.path.isdir(base_dir): module.fail_json( name=base_dir, diff --git a/lib/ansible/modules/crypto/openssl_pkcs12.py b/lib/ansible/modules/crypto/openssl_pkcs12.py index 32da212f42..35023cd291 100644 --- a/lib/ansible/modules/crypto/openssl_pkcs12.py +++ b/lib/ansible/modules/crypto/openssl_pkcs12.py @@ -312,7 +312,7 @@ def main(): if not pyopenssl_found: module.fail_json(msg='The python pyOpenSSL library is required') - base_dir = os.path.dirname(module.params['path']) + base_dir = os.path.dirname(module.params['path']) or '.' if not os.path.isdir(base_dir): module.fail_json( name=base_dir, diff --git a/lib/ansible/modules/crypto/openssl_privatekey.py b/lib/ansible/modules/crypto/openssl_privatekey.py index 2b35f556d2..d9ef9d3947 100644 --- a/lib/ansible/modules/crypto/openssl_privatekey.py +++ b/lib/ansible/modules/crypto/openssl_privatekey.py @@ -271,7 +271,7 @@ def main(): if not pyopenssl_found: module.fail_json(msg='the python pyOpenSSL module is required') - base_dir = os.path.dirname(module.params['path']) + base_dir = os.path.dirname(module.params['path']) or '.' if not os.path.isdir(base_dir): module.fail_json( name=base_dir, diff --git a/lib/ansible/modules/crypto/openssl_publickey.py b/lib/ansible/modules/crypto/openssl_publickey.py index 6ff923ffc9..5a749d6bef 100644 --- a/lib/ansible/modules/crypto/openssl_publickey.py +++ b/lib/ansible/modules/crypto/openssl_publickey.py @@ -269,7 +269,7 @@ def main(): if not pyopenssl_found: module.fail_json(msg='the python pyOpenSSL module is required') - base_dir = os.path.dirname(module.params['path']) + base_dir = os.path.dirname(module.params['path']) or '.' if not os.path.isdir(base_dir): module.fail_json( name=base_dir, |