mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add domain_id parameter to openstack os_group (#20609)
Previously, the os_group module did not have any way to specify under which domain a group should be created. This meant that a group could only be created for the default domain. The keystone API supports the domain_id parameter for group creation[1] as does the shade library[2] so this patch adds the support in the ansible module. [1] http://developer.openstack.org/api-ref/identity/v3/index.html?expanded=create-group-detail#create-group [2] http://docs.openstack.org/infra/shade/usage.html#shade.OperatorCloud.create_group
This commit is contained in:
parent
b8d308d919
commit
352815ecbb
1 changed files with 12 additions and 2 deletions
|
@ -38,6 +38,12 @@ options:
|
||||||
- Group description
|
- Group description
|
||||||
required: false
|
required: false
|
||||||
default: None
|
default: None
|
||||||
|
domain_id:
|
||||||
|
description:
|
||||||
|
- Domain id to create the group in if the cloud supports domains.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
|
version_added: "2.3"
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Should the resource be present or absent.
|
- Should the resource be present or absent.
|
||||||
|
@ -59,6 +65,7 @@ EXAMPLES = '''
|
||||||
state: present
|
state: present
|
||||||
name: demo
|
name: demo
|
||||||
description: "Demo Group"
|
description: "Demo Group"
|
||||||
|
domain_id: demoid
|
||||||
|
|
||||||
# Update the description on existing "demo" group
|
# Update the description on existing "demo" group
|
||||||
- os_group:
|
- os_group:
|
||||||
|
@ -66,6 +73,7 @@ EXAMPLES = '''
|
||||||
state: present
|
state: present
|
||||||
name: demo
|
name: demo
|
||||||
description: "Something else"
|
description: "Something else"
|
||||||
|
domain_id: demoid
|
||||||
|
|
||||||
# Delete group named "demo"
|
# Delete group named "demo"
|
||||||
- os_group:
|
- os_group:
|
||||||
|
@ -119,6 +127,7 @@ def main():
|
||||||
argument_spec = openstack_full_argument_spec(
|
argument_spec = openstack_full_argument_spec(
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
description=dict(required=False, default=None),
|
description=dict(required=False, default=None),
|
||||||
|
domain_id=dict(required=False, default=None),
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present']),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -132,11 +141,12 @@ def main():
|
||||||
|
|
||||||
name = module.params.pop('name')
|
name = module.params.pop('name')
|
||||||
description = module.params.pop('description')
|
description = module.params.pop('description')
|
||||||
|
domain_id = module.params.pop('domain_id')
|
||||||
state = module.params.pop('state')
|
state = module.params.pop('state')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cloud = shade.operator_cloud(**module.params)
|
cloud = shade.operator_cloud(**module.params)
|
||||||
group = cloud.get_group(name)
|
group = cloud.get_group(name, filters={'domain_id': domain_id})
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
module.exit_json(changed=_system_state_change(state, description, group))
|
module.exit_json(changed=_system_state_change(state, description, group))
|
||||||
|
@ -144,7 +154,7 @@ def main():
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if group is None:
|
if group is None:
|
||||||
group = cloud.create_group(
|
group = cloud.create_group(
|
||||||
name=name, description=description)
|
name=name, description=description, domain=domain_id)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
if description is not None and group.description != description:
|
if description is not None and group.description != description:
|
||||||
|
|
Loading…
Reference in a new issue