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