From 530fd1365a4b9bd78bd5b5ed123afb53979fefad Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Mon, 11 Jul 2016 02:35:51 -0400 Subject: [PATCH] Allow os_server to delete FIP (#3509) The os_server module could automatically generate a floating IP for the user with auto_ip=true, but we didn't allow for this FIP to be automatically deleted when deleting the instance, which is a bug. Add a new option called delete_fip that enables this. --- lib/ansible/modules/cloud/openstack/os_server.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_server.py b/lib/ansible/modules/cloud/openstack/os_server.py index 6906c185d0e..885cca5093a 100644 --- a/lib/ansible/modules/cloud/openstack/os_server.py +++ b/lib/ansible/modules/cloud/openstack/os_server.py @@ -180,7 +180,15 @@ options: - Should the resource be present or absent. choices: [present, absent] default: present -requirements: ["shade"] + delete_fip: + description: + - When I(state) is absent and this option is true, any floating IP + associated with the instance will be deleted along with the instance. + required: false + default: false +requirements: + - "python >= 2.6" + - "shade" ''' EXAMPLES = ''' @@ -411,7 +419,8 @@ def _delete_server(module, cloud): try: cloud.delete_server( module.params['name'], wait=module.params['wait'], - timeout=module.params['timeout']) + timeout=module.params['timeout'], + delete_ips=module.params['delete_fip']) except Exception as e: module.fail_json(msg="Error in deleting vm: %s" % e.message) module.exit_json(changed=True, result='deleted') @@ -567,6 +576,7 @@ def main(): volumes = dict(default=[], type='list'), scheduler_hints = dict(default=None, type='dict'), state = dict(default='present', choices=['absent', 'present']), + delete_fip = dict(default=False, type='bool'), ) module_kwargs = openstack_module_kwargs( mutually_exclusive=[