diff --git a/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py b/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py index a5932b42b3..1aa0ac0045 100644 --- a/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py +++ b/lib/ansible/modules/extras/cloud/cloudstack/cs_ip_address.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # # (c) 2015, Darren Worrall +# (c) 2015, René Moser # # This file is part of Ansible # @@ -27,7 +28,9 @@ description: limitations this is not an idempotent call, so be sure to only conditionally call this when C(state=present) version_added: '2.0' -author: "Darren Worrall @dazworrall" +author: + - "Darren Worrall (@dazworrall)" + - "René Moser (@resmo)" options: ip_address: description: @@ -45,6 +48,12 @@ options: - Network the IP address is related to. required: false default: null + vpc: + description: + - VPC the IP address is related to. + required: false + default: null + version_added: "2.2" account: description: - Account the IP address is related to. @@ -159,7 +168,6 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack): for n in networks['network']: if network in [ n['displaytext'], n['name'], n['id'] ]: return self._get_by_key(key, n) - break self.module.fail_json(msg="Network '%s' not found" % network) @@ -177,6 +185,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack): args['account'] = self.get_account(key='name') args['domainid'] = self.get_domain(key='id') args['projectid'] = self.get_project(key='id') + args['vpcid'] = self.get_vpc(key='id') ip_addresses = self.cs.listPublicIpAddresses(**args) if ip_addresses: @@ -219,7 +228,7 @@ class AnsibleCloudStackIPAddress(AnsibleCloudStack): self.module.fail_json(msg="Failed: '%s'" % res['errortext']) poll_async = self.module.params.get('poll_async') if poll_async: - res = self._poll_job(res, 'ipaddress') + self._poll_job(res, 'ipaddress') return ip_address @@ -228,10 +237,11 @@ def main(): argument_spec.update(dict( ip_address = dict(required=False), state = dict(choices=['present', 'absent'], default='present'), + vpc = dict(default=None), + network = dict(default=None), zone = dict(default=None), domain = dict(default=None), account = dict(default=None), - network = dict(default=None), project = dict(default=None), poll_async = dict(choices=BOOLEANS, default=True), ))