|
|
@ -118,23 +118,21 @@ def main():
|
|
|
|
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)
|
|
|
|
module.exit_json(changed=True, result='created',
|
|
|
|
module.exit_json(changed=True, id=secgroup['id'])
|
|
|
|
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)
|
|
|
|
module.exit_json(changed=True, result='updated',
|
|
|
|
module.exit_json(changed=True, id=secgroup['id'])
|
|
|
|
id=secgroup['id'])
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
module.exit_json(changed=False, result='success')
|
|
|
|
module.exit_json(changed=False)
|
|
|
|
|
|
|
|
|
|
|
|
if state == 'absent':
|
|
|
|
if state == 'absent':
|
|
|
|
if not secgroup:
|
|
|
|
if not secgroup:
|
|
|
|
module.exit_json(changed=False, result='success')
|
|
|
|
module.exit_json(changed=False)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
cloud.delete_security_group(secgroup['id'])
|
|
|
|
cloud.delete_security_group(secgroup['id'])
|
|
|
|
module.exit_json(changed=True, result='deleted')
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
|
|
|
|
|
|
|
|
except shade.OpenStackCloudException as e:
|
|
|
|
except shade.OpenStackCloudException as e:
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|
module.fail_json(msg=e.message)
|
|
|
|