From 41de2855ae58baaaa80d6e41e3f24ca90b839868 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 9 Jan 2019 15:10:17 +0100 Subject: [PATCH] Remove elements= from arg_spec when type is not 'list'. (#50484) --- lib/ansible/modules/crypto/openssl_csr.py | 4 ++-- lib/ansible/modules/network/ios/ios_user.py | 2 +- .../modules/remote_management/manageiq/manageiq_group.py | 8 +++++--- .../remote_management/ucs/ucs_disk_group_policy.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/ansible/modules/crypto/openssl_csr.py b/lib/ansible/modules/crypto/openssl_csr.py index d9eea9194c..e67c9dd0b7 100644 --- a/lib/ansible/modules/crypto/openssl_csr.py +++ b/lib/ansible/modules/crypto/openssl_csr.py @@ -544,8 +544,8 @@ def main(): subjectAltName_critical=dict(aliases=['subject_alt_name_critical'], default=False, type='bool'), 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', elements='str'), + extendedKeyUsage=dict(aliases=['extKeyUsage', 'extended_key_usage'], type='list', elements='str'), + extendedKeyUsage_critical=dict(aliases=['extKeyUsage_critical', 'extended_key_usage_critical'], default=False, type='bool'), 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'), diff --git a/lib/ansible/modules/network/ios/ios_user.py b/lib/ansible/modules/network/ios/ios_user.py index ec5756430f..8d675ac8d5 100644 --- a/lib/ansible/modules/network/ios/ios_user.py +++ b/lib/ansible/modules/network/ios/ios_user.py @@ -456,7 +456,7 @@ def main(): name=dict(), configured_password=dict(no_log=True), - hashed_password=dict(no_log=True, elements='dict', options=hashed_password_spec), + hashed_password=dict(no_log=True, type='dict', options=hashed_password_spec), nopassword=dict(type='bool'), update_password=dict(default='always', choices=['on_create', 'always']), password_type=dict(default='secret', choices=['secret', 'password']), diff --git a/lib/ansible/modules/remote_management/manageiq/manageiq_group.py b/lib/ansible/modules/remote_management/manageiq/manageiq_group.py index 28c7d67b30..5547e0ab03 100644 --- a/lib/ansible/modules/remote_management/manageiq/manageiq_group.py +++ b/lib/ansible/modules/remote_management/manageiq/manageiq_group.py @@ -507,13 +507,15 @@ class ManageIQgroup(object): return res @staticmethod - def normalize_user_managed_filters_to_sorted_dict(managed_filters): + def normalize_user_managed_filters_to_sorted_dict(managed_filters, module): if not managed_filters: return None res = {} for cat_key in managed_filters: cat_array = [] + if not isinstance(managed_filters[cat_key], list): + module.fail_json(msg='Entry "{0}" of managed_filters must be a list!'.format(cat_key)) for tags in managed_filters[cat_key]: miq_managed_tag = "/managed/" + cat_key + "/" + tags cat_array.append(miq_managed_tag) @@ -571,7 +573,7 @@ def main(): role=dict(required=False, type='str'), tenant_id=dict(required=False, type='int'), tenant=dict(required=False, type='str'), - managed_filters=dict(required=False, type='dict', elements='list'), + managed_filters=dict(required=False, type='dict'), managed_filters_merge_mode=dict(required=False, choices=['merge', 'replace'], default='replace'), belongsto_filters=dict(required=False, type='list', elements='str'), belongsto_filters_merge_mode=dict(required=False, choices=['merge', 'replace'], default='replace'), @@ -615,7 +617,7 @@ def main(): tenant = manageiq_group.tenant(tenant_id, tenant_name) role = manageiq_group.role(role_id, role_name) - norm_managed_filters = manageiq_group.normalize_user_managed_filters_to_sorted_dict(managed_filters) + norm_managed_filters = manageiq_group.normalize_user_managed_filters_to_sorted_dict(managed_filters, module) # if we have a group, edit it if group: res_args = manageiq_group.edit_group(group, description, role, tenant, diff --git a/lib/ansible/modules/remote_management/ucs/ucs_disk_group_policy.py b/lib/ansible/modules/remote_management/ucs/ucs_disk_group_policy.py index 093eeb94d7..e64adec39a 100644 --- a/lib/ansible/modules/remote_management/ucs/ucs_disk_group_policy.py +++ b/lib/ansible/modules/remote_management/ucs/ucs_disk_group_policy.py @@ -387,7 +387,7 @@ def main(): min_drive_size=dict(type='str', default='unspecified'), manual_disks=dict(type='list', elements='dict', options=manual_disk), state=dict(type='str', default='present', choices=['present', 'absent']), - virtual_drive=dict(type='dict', elements='dict', options=_virtual_drive_argument_spec()), + virtual_drive=dict(type='dict', options=_virtual_drive_argument_spec()), ) module = AnsibleModule( argument_spec,