From 3a9eadb22f4996691188031df1d0545e6f045103 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 26 Nov 2018 16:17:25 +0100 Subject: [PATCH] Updating argument_spec for type='list' options by elements value. (#48485) --- lib/ansible/modules/crypto/acme/acme_account.py | 5 +++-- lib/ansible/modules/crypto/certificate_complete_chain.py | 4 ++-- lib/ansible/modules/crypto/openssl_certificate.py | 8 ++++---- lib/ansible/modules/crypto/openssl_csr.py | 8 ++++---- lib/ansible/modules/crypto/openssl_pkcs12.py | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/ansible/modules/crypto/acme/acme_account.py b/lib/ansible/modules/crypto/acme/acme_account.py index 1fbe8165012..3d149e98d1c 100644 --- a/lib/ansible/modules/crypto/acme/acme_account.py +++ b/lib/ansible/modules/crypto/acme/acme_account.py @@ -136,7 +136,7 @@ def main(): terms_agreed=dict(required=False, default=False, type='bool'), state=dict(required=True, choices=['absent', 'present', 'changed_key'], type='str'), allow_creation=dict(required=False, default=True, type='bool'), - contact=dict(required=False, type='list', default=[]), + contact=dict(required=False, type='list', elements='str', default=[]), new_account_key_src=dict(type='path'), new_account_key_content=dict(type='str', no_log=True), select_crypto_backend=dict(required=False, choices=['auto', 'openssl', 'cryptography'], default='auto', type='str'), @@ -192,7 +192,8 @@ def main(): module.exit_json(changed=False, account_uri=account.uri) elif state == 'present': allow_creation = module.params.get('allow_creation') - contact = module.params.get('contact') + # Make sure contact is a list of strings (unfortunately, Ansible doesn't do that for us) + contact = [str(v) for v in module.params.get('contact')] terms_agreed = module.params.get('terms_agreed') changed = account.init_account( contact, diff --git a/lib/ansible/modules/crypto/certificate_complete_chain.py b/lib/ansible/modules/crypto/certificate_complete_chain.py index 0d9222d4113..26d98fcb189 100644 --- a/lib/ansible/modules/crypto/certificate_complete_chain.py +++ b/lib/ansible/modules/crypto/certificate_complete_chain.py @@ -281,8 +281,8 @@ def main(): module = AnsibleModule( argument_spec=dict( input_chain=dict(required=True, type='str'), - root_certificates=dict(required=True, type='list'), - intermediate_certificates=dict(required=False, type='list', default=[]), + root_certificates=dict(required=True, type='list', elements='path'), + intermediate_certificates=dict(required=False, type='list', elements='path', default=[]), ), supports_check_mode=True, ) diff --git a/lib/ansible/modules/crypto/openssl_certificate.py b/lib/ansible/modules/crypto/openssl_certificate.py index d2790db7b0b..3084b09441d 100644 --- a/lib/ansible/modules/crypto/openssl_certificate.py +++ b/lib/ansible/modules/crypto/openssl_certificate.py @@ -987,18 +987,18 @@ def main(): # General properties of a certificate privatekey_path=dict(type='path'), privatekey_passphrase=dict(type='str', no_log=True), - signature_algorithms=dict(type='list'), + signature_algorithms=dict(type='list', elements='str'), subject=dict(type='dict'), subject_strict=dict(type='bool', default=False), issuer=dict(type='dict'), issuer_strict=dict(type='bool', default=False), has_expired=dict(type='bool', default=False), version=dict(type='int'), - keyUsage=dict(type='list', aliases=['key_usage']), + keyUsage=dict(type='list', aliases=['key_usage'], elements='str'), keyUsage_strict=dict(type='bool', default=False, aliases=['key_usage_strict']), - extendedKeyUsage=dict(type='list', aliases=['extended_key_usage'], ), + extendedKeyUsage=dict(type='list', aliases=['extended_key_usage'], elements='str'), extendedKeyUsage_strict=dict(type='bool', default=False, aliases=['extended_key_usage_strict']), - subjectAltName=dict(type='list', aliases=['subject_alt_name']), + subjectAltName=dict(type='list', aliases=['subject_alt_name'], elements='str'), subjectAltName_strict=dict(type='bool', default=False, aliases=['subject_alt_name_strict']), notBefore=dict(type='str', aliases=['not_before']), notAfter=dict(type='str', aliases=['not_after']), diff --git a/lib/ansible/modules/crypto/openssl_csr.py b/lib/ansible/modules/crypto/openssl_csr.py index 21b0e7b1fe1..0baf7eb661a 100644 --- a/lib/ansible/modules/crypto/openssl_csr.py +++ b/lib/ansible/modules/crypto/openssl_csr.py @@ -529,13 +529,13 @@ def main(): organizationalUnitName=dict(aliases=['OU', 'organizational_unit_name'], type='str'), commonName=dict(aliases=['CN', 'common_name'], type='str'), emailAddress=dict(aliases=['E', 'email_address'], type='str'), - subjectAltName=dict(aliases=['subject_alt_name'], type='list'), + subjectAltName=dict(aliases=['subject_alt_name'], type='list', elements='str'), subjectAltName_critical=dict(aliases=['subject_alt_name_critical'], default=False, type='bool'), - keyUsage=dict(aliases=['key_usage'], type='list'), + keyUsage=dict(aliases=['key_usage'], type='list', elements='str'), keyUsage_critical=dict(aliases=['key_usage_critical'], default=False, type='bool'), extendedKeyUsage=dict(aliases=['extKeyUsage', 'extended_key_usage'], type='list'), - extendedKeyUsage_critical=dict(aliases=['extKeyUsage_critical', 'extended_key_usage_critical'], default=False, type='bool'), - basicConstraints=dict(aliases=['basic_constraints'], type='list'), + extendedKeyUsage_critical=dict(aliases=['extKeyUsage_critical', 'extended_key_usage_critical'], default=False, type='bool', elements='str'), + basicConstraints=dict(aliases=['basic_constraints'], type='list', elements='str'), basicConstraints_critical=dict(aliases=['basic_constraints_critical'], default=False, type='bool'), ocspMustStaple=dict(aliases=['ocsp_must_staple'], default=False, type='bool'), ocspMustStaple_critical=dict(aliases=['ocsp_must_staple_critical'], default=False, type='bool'), diff --git a/lib/ansible/modules/crypto/openssl_pkcs12.py b/lib/ansible/modules/crypto/openssl_pkcs12.py index 32da212f42c..dc904f59571 100644 --- a/lib/ansible/modules/crypto/openssl_pkcs12.py +++ b/lib/ansible/modules/crypto/openssl_pkcs12.py @@ -278,7 +278,7 @@ def main(): argument_spec = dict( action=dict(type='str', default='export', choices=['parse', 'export']), - ca_certificates=dict(type='list'), + ca_certificates=dict(type='list', elements='path'), certificate_path=dict(type='path'), force=dict(type='bool', default=False), friendly_name=dict(type='str', aliases=['name']),