|
|
|
@ -4,6 +4,9 @@
|
|
|
|
|
# Copyright (c) 2016, René Moser <mail@renemoser.net>
|
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
|
'status': ['stableinterface'],
|
|
|
|
|
'supported_by': 'community'}
|
|
|
|
@ -30,7 +33,7 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- "CIDR of the VPC, e.g. 10.1.0.0/16"
|
|
|
|
|
- "All VPC guest networks' CIDRs must be within this CIDR."
|
|
|
|
|
- "Required on C(state=present)."
|
|
|
|
|
- "Required on I(state=present)."
|
|
|
|
|
network_domain:
|
|
|
|
|
description:
|
|
|
|
|
- "Network domain for the VPC."
|
|
|
|
@ -42,15 +45,18 @@ options:
|
|
|
|
|
- "If not set, default VPC offering is used."
|
|
|
|
|
clean_up:
|
|
|
|
|
description:
|
|
|
|
|
- "Whether to redeploy a VPC router or not when C(state=restarted)"
|
|
|
|
|
- "Whether to redeploy a VPC router or not when I(state=restarted)"
|
|
|
|
|
version_added: "2.5"
|
|
|
|
|
type: bool
|
|
|
|
|
state:
|
|
|
|
|
description:
|
|
|
|
|
- "State of the VPC."
|
|
|
|
|
- "The state C(started) is only considered while creating the VPC, added in version 2.6."
|
|
|
|
|
default: present
|
|
|
|
|
choices:
|
|
|
|
|
- present
|
|
|
|
|
- absent
|
|
|
|
|
- started
|
|
|
|
|
- restarted
|
|
|
|
|
domain:
|
|
|
|
|
description:
|
|
|
|
@ -68,23 +74,32 @@ options:
|
|
|
|
|
tags:
|
|
|
|
|
description:
|
|
|
|
|
- "List of tags. Tags are a list of dictionaries having keys C(key) and C(value)."
|
|
|
|
|
- "For deleting all tags, set an empty list e.g. C(tags: [])."
|
|
|
|
|
- "For deleting all tags, set an empty list e.g. I(tags: [])."
|
|
|
|
|
aliases:
|
|
|
|
|
- tag
|
|
|
|
|
poll_async:
|
|
|
|
|
description:
|
|
|
|
|
- "Poll async jobs until job has finished."
|
|
|
|
|
default: true
|
|
|
|
|
default: yes
|
|
|
|
|
type: bool
|
|
|
|
|
extends_documentation_fragment: cloudstack
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
|
- name: Ensure a VPC is present
|
|
|
|
|
- name: Ensure a VPC is present but not started after creating
|
|
|
|
|
local_action:
|
|
|
|
|
module: cs_vpc
|
|
|
|
|
name: my_vpc
|
|
|
|
|
display_text: My example VPC
|
|
|
|
|
cidr: 10.10.0.0/16
|
|
|
|
|
|
|
|
|
|
- name: Ensure a VPC is present and started after creating
|
|
|
|
|
local_action:
|
|
|
|
|
module: cs_vpc
|
|
|
|
|
name: my_vpc
|
|
|
|
|
display_text: My example VPC
|
|
|
|
|
cidr: 10.10.0.0/16
|
|
|
|
|
state: started
|
|
|
|
|
|
|
|
|
|
- name: Ensure a VPC is absent
|
|
|
|
|
local_action:
|
|
|
|
@ -96,7 +111,7 @@ EXAMPLES = '''
|
|
|
|
|
local_action:
|
|
|
|
|
module: cs_vpc
|
|
|
|
|
name: my_vpc
|
|
|
|
|
clean_up: true
|
|
|
|
|
clean_up: yes
|
|
|
|
|
state: restarted
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
@ -274,6 +289,7 @@ class AnsibleCloudStackVpc(AnsibleCloudStack):
|
|
|
|
|
'domainid': self.get_domain(key='id'),
|
|
|
|
|
'projectid': self.get_project(key='id'),
|
|
|
|
|
'zoneid': self.get_zone(key='id'),
|
|
|
|
|
'start': self.module.params.get('state') == 'started'
|
|
|
|
|
}
|
|
|
|
|
self.result['diff']['after'] = args
|
|
|
|
|
if not self.module.check_mode:
|
|
|
|
@ -322,7 +338,7 @@ def main():
|
|
|
|
|
vpc_offering=dict(),
|
|
|
|
|
network_domain=dict(),
|
|
|
|
|
clean_up=dict(type='bool'),
|
|
|
|
|
state=dict(choices=['present', 'absent', 'restarted'], default='present'),
|
|
|
|
|
state=dict(choices=['present', 'absent', 'started', 'restarted'], default='present'),
|
|
|
|
|
domain=dict(),
|
|
|
|
|
account=dict(),
|
|
|
|
|
project=dict(),
|
|
|
|
|