From 072110c757178a68980863efbc329dfbb3d6f43b Mon Sep 17 00:00:00 2001 From: dagnello Date: Fri, 19 Jun 2015 10:45:12 -0700 Subject: [PATCH] Resolving secgroup.id issue in this module secgroup['id'] was not being returned in all cases where the specified security group exists. --- .../modules/cloud/openstack/os_security_group.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_security_group.py b/lib/ansible/modules/cloud/openstack/os_security_group.py index 0864b83e9e9..0b195bb383e 100644 --- a/lib/ansible/modules/cloud/openstack/os_security_group.py +++ b/lib/ansible/modules/cloud/openstack/os_security_group.py @@ -115,24 +115,24 @@ def main(): if module.check_mode: module.exit_json(changed=_system_state_change(module, secgroup)) - changed = False if state == 'present': if not secgroup: secgroup = cloud.create_security_group(name, description) - changed = True + module.exit_json(changed=True, id=secgroup['id']) else: if _needs_update(module, secgroup): secgroup = cloud.update_security_group( secgroup['id'], description=description) - changed = True - module.exit_json( - changed=changed, id=secgroup.id, secgroup=secgroup) + module.exit_json(changed=True, id=secgroup['id']) + else: + module.exit_json(changed=False, id=secgroup['id']) if state == 'absent': - if secgroup: + if not secgroup: + module.exit_json(changed=False) + else: cloud.delete_security_group(secgroup['id']) - changed=True - module.exit_json(changed=changed) + module.exit_json(changed=True) except shade.OpenStackCloudException as e: module.fail_json(msg=e.message)