Resolving secgroup.id issue in this module
secgroup['id'] was not being returned in all cases where the specified security group exists.
This commit is contained in:
parent
7a33832606
commit
d7f65af6d9
1 changed files with 10 additions and 8 deletions
|
@ -48,6 +48,8 @@ options:
|
||||||
- Should the resource be present or absent.
|
- Should the resource be present or absent.
|
||||||
choices: [present, absent]
|
choices: [present, absent]
|
||||||
default: present
|
default: present
|
||||||
|
|
||||||
|
requirements: ["shade"]
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -114,24 +116,24 @@ def main():
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
module.exit_json(changed=_system_state_change(module, secgroup))
|
module.exit_json(changed=_system_state_change(module, secgroup))
|
||||||
|
|
||||||
changed = False
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if not secgroup:
|
if not secgroup:
|
||||||
secgroup = cloud.create_security_group(name, description)
|
secgroup = cloud.create_security_group(name, description)
|
||||||
changed = True
|
module.exit_json(changed=True, id=secgroup['id'])
|
||||||
else:
|
else:
|
||||||
if _needs_update(module, secgroup):
|
if _needs_update(module, secgroup):
|
||||||
secgroup = cloud.update_security_group(
|
secgroup = cloud.update_security_group(
|
||||||
secgroup['id'], description=description)
|
secgroup['id'], description=description)
|
||||||
changed = True
|
module.exit_json(changed=True, id=secgroup['id'])
|
||||||
module.exit_json(
|
else:
|
||||||
changed=changed, id=secgroup.id, secgroup=secgroup)
|
module.exit_json(changed=False, id=secgroup['id'])
|
||||||
|
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
if secgroup:
|
if not secgroup:
|
||||||
|
module.exit_json(changed=False)
|
||||||
|
else:
|
||||||
cloud.delete_security_group(secgroup['id'])
|
cloud.delete_security_group(secgroup['id'])
|
||||||
changed=True
|
module.exit_json(changed=True)
|
||||||
module.exit_json(changed=changed)
|
|
||||||
|
|
||||||
except shade.OpenStackCloudException as e:
|
except shade.OpenStackCloudException as e:
|
||||||
module.fail_json(msg=e.message)
|
module.fail_json(msg=e.message)
|
||||||
|
|
Loading…
Reference in a new issue