diff options
author | Nithy Renganathan <maheshsa@us.ibm.com> | 2015-08-20 14:24:05 +0000 |
---|---|---|
committer | Nithy Renganathan <maheshsa@us.ibm.com> | 2015-08-20 14:24:05 +0000 |
commit | 4171d167f481928b6d14c66749fe9be5a0595543 (patch) | |
tree | 54512f2b06130153950d93e63c39c0abcf92376d | |
parent | f459b3773cba0579d4a2ab5440e366c1cdd5b76a (diff) | |
download | ansible-modules-core-4171d167f481928b6d14c66749fe9be5a0595543.tar.gz |
Handle the changed value
-rw-r--r-- | cloud/openstack/keystone_user.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cloud/openstack/keystone_user.py b/cloud/openstack/keystone_user.py index 2596eab9..babcc3cc 100644 --- a/cloud/openstack/keystone_user.py +++ b/cloud/openstack/keystone_user.py @@ -256,11 +256,14 @@ def ensure_role_exists(keystone, role_name): # Get the role if it exists try: role = get_role(keystone, role_name) + # Role does exist, we're done + return (False, role.id) except KeyError: # Role doesn't exist yet - role = keystone.roles.create(role_name) - return (True, role.id) + pass + role = keystone.roles.create(role_name) + return (True, role.id) def ensure_user_role_exists(keystone, user_name, tenant_name, role_name, check_mode): @@ -397,9 +400,9 @@ def dispatch(keystone, user=None, password=None, tenant=None, changed = False id = None if not tenant and not user and role and state == "present": - ensure_role_exists(keystone, role) + changed, id = ensure_role_exists(keystone, role) elif not tenant and not user and role and state == "absent": - ensure_role_absent(keystone, role) + changed = ensure_role_absent(keystone, role) elif tenant and not user and not role and state == "present": changed, id = ensure_tenant_exists(keystone, tenant, tenant_description, check_mode) |