diff --git a/changelogs/fragments/openstack-fixes-for-2.7.5.yaml b/changelogs/fragments/openstack-fixes-for-2.7.5.yaml new file mode 100644 index 0000000000..0614bcc758 --- /dev/null +++ b/changelogs/fragments/openstack-fixes-for-2.7.5.yaml @@ -0,0 +1,8 @@ +--- +bugfixes: + - openstack - fix parameter handling when cloud provided as dict + https://github.com/ansible/ansible/issues/42858 + - os_user - Include domain parameter in user lookup + https://github.com/ansible/ansible/issues/42901 + - os_user - Include domain parameter in user deletion + https://github.com/ansible/ansible/issues/42901 diff --git a/lib/ansible/module_utils/openstack.py b/lib/ansible/module_utils/openstack.py index 75fbfbfeff..84de169eb6 100644 --- a/lib/ansible/module_utils/openstack.py +++ b/lib/ansible/module_utils/openstack.py @@ -134,11 +134,12 @@ def openstack_cloud_from_module(module, min_version='0.12.0'): " excluded.") for param in ( 'auth', 'region_name', 'verify', - 'cacert', 'key', 'api_timeout', 'interface'): + 'cacert', 'key', 'api_timeout', 'auth_type'): if module.params[param] is not None: module.fail_json(msg=fail_message.format(param=param)) - if module.params['auth_type'] != 'password': - module.fail_json(msg=fail_message.format(param='auth_type')) + # For 'interface' parameter, fail if we receive a non-default value + if module.params['interface'] != 'public': + module.fail_json(msg=fail_message.format(param='interface')) return sdk, sdk.connect(**cloud_config) else: return sdk, sdk.connect( diff --git a/lib/ansible/modules/cloud/openstack/os_user.py b/lib/ansible/modules/cloud/openstack/os_user.py index 236f192f9c..bc0cf27a0b 100644 --- a/lib/ansible/modules/cloud/openstack/os_user.py +++ b/lib/ansible/modules/cloud/openstack/os_user.py @@ -201,11 +201,12 @@ def main(): sdk, cloud = openstack_cloud_from_module(module) try: - user = cloud.get_user(name) - domain_id = None if domain: domain_id = _get_domain_id(cloud, domain) + user = cloud.get_user(name, domain_id=domain_id) + else: + user = cloud.get_user(name) if state == 'present': if update_password in ('always', 'on_create'): @@ -271,7 +272,10 @@ def main(): if user is None: changed = False else: - cloud.delete_user(user['id']) + if domain: + cloud.delete_user(user['id'], domain_id=domain_id) + else: + cloud.delete_user(user['id']) changed = True module.exit_json(changed=changed)