summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrançois Deppierraz <francois@ctrlaltdel.ch>2019-07-08 15:26:16 +0200
committeransibot <ansibot@users.noreply.github.com>2019-07-08 15:26:15 +0200
commit737da1853ef2239e27a2fe380c3e83ba5b34de5b (patch)
treef08486c57f54aebc6cf656a8e79bc5f7552f7de4
parentrole: Fix role's hash_params (#55263) (diff)
downloadansible-737da1853ef2239e27a2fe380c3e83ba5b34de5b.tar.xz
ansible-737da1853ef2239e27a2fe380c3e83ba5b34de5b.zip
os_user_role: add support for named domain (#49891)
Fixes #49859.
-rw-r--r--lib/ansible/modules/cloud/openstack/os_user_role.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/ansible/modules/cloud/openstack/os_user_role.py b/lib/ansible/modules/cloud/openstack/os_user_role.py
index ac15d8dce2..936ccb2bbd 100644
--- a/lib/ansible/modules/cloud/openstack/os_user_role.py
+++ b/lib/ansible/modules/cloud/openstack/os_user_role.py
@@ -41,8 +41,8 @@ options:
If you are using keystone version 2, then this value is required.
domain:
description:
- - ID of the domain to scope the role association to. Valid only with
- keystone version 3, and required if I(project) is not specified.
+ - Name or ID of the domain to scope the role association to. Valid only
+ with keystone version 3, and required if I(project) is not specified.
state:
description:
- Should the roles be present or absent on the user.
@@ -137,7 +137,7 @@ def main():
filters['role'] = r['id']
if domain:
- d = cloud.get_domain(domain)
+ d = cloud.get_domain(name_or_id=domain)
if d is None:
module.fail_json(msg="Domain %s is not valid" % domain)
filters['domain'] = d['id']
@@ -155,6 +155,7 @@ def main():
if g is None:
module.fail_json(msg="Group %s is not valid" % group)
filters['group'] = g['id']
+ domain_id = None
if project:
if domain:
p = cloud.get_project(project, domain_id=filters['domain'])
@@ -162,7 +163,7 @@ def main():
# filter. Once we identified the project (using the domain as
# a filter criteria), we need to remove the domain itself from
# the filters list.
- filters.pop('domain')
+ domain_id = filters.pop('domain')
else:
p = cloud.get_project(project)
@@ -179,13 +180,13 @@ def main():
if state == 'present':
if not assignment:
- kwargs = _build_kwargs(user, group, project, domain)
+ kwargs = _build_kwargs(user, group, project, domain_id)
cloud.grant_role(role, **kwargs)
changed = True
elif state == 'absent':
if assignment:
- kwargs = _build_kwargs(user, group, project, domain)
+ kwargs = _build_kwargs(user, group, project, domain_id)
cloud.revoke_role(role, **kwargs)
changed = True