Handle the changed value
This commit is contained in:
parent
2c511a9470
commit
eb3f28effc
1 changed files with 7 additions and 4 deletions
|
@ -256,12 +256,15 @@ def ensure_role_exists(keystone, role_name):
|
||||||
# Get the role if it exists
|
# Get the role if it exists
|
||||||
try:
|
try:
|
||||||
role = get_role(keystone, role_name)
|
role = get_role(keystone, role_name)
|
||||||
|
# Role does exist, we're done
|
||||||
|
return (False, role.id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Role doesn't exist yet
|
# Role doesn't exist yet
|
||||||
|
pass
|
||||||
|
|
||||||
role = keystone.roles.create(role_name)
|
role = keystone.roles.create(role_name)
|
||||||
return (True, role.id)
|
return (True, role.id)
|
||||||
|
|
||||||
|
|
||||||
def ensure_user_role_exists(keystone, user_name, tenant_name, role_name,
|
def ensure_user_role_exists(keystone, user_name, tenant_name, role_name,
|
||||||
check_mode):
|
check_mode):
|
||||||
""" Check if role exists
|
""" Check if role exists
|
||||||
|
@ -397,9 +400,9 @@ def dispatch(keystone, user=None, password=None, tenant=None,
|
||||||
changed = False
|
changed = False
|
||||||
id = None
|
id = None
|
||||||
if not tenant and not user and role and state == "present":
|
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":
|
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":
|
elif tenant and not user and not role and state == "present":
|
||||||
changed, id = ensure_tenant_exists(keystone, tenant,
|
changed, id = ensure_tenant_exists(keystone, tenant,
|
||||||
tenant_description, check_mode)
|
tenant_description, check_mode)
|
||||||
|
|
Loading…
Reference in a new issue