cs_vpc: implement state=started (#40319)

pull/40364/head
René Moser 7 years ago committed by GitHub
parent 6ac2045db8
commit de8b6b55f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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(),

@ -55,6 +55,7 @@
vpc_offering: Redundant VPC offering vpc_offering: Redundant VPC offering
network_domain: test.example.com network_domain: test.example.com
zone: "{{ cs_common_zone_adv }}" zone: "{{ cs_common_zone_adv }}"
state: started
register: vpc register: vpc
check_mode: true check_mode: true
- name: verify test create vpc with custom offering in check mode - name: verify test create vpc with custom offering in check mode
@ -71,6 +72,7 @@
vpc_offering: Redundant VPC offering vpc_offering: Redundant VPC offering
network_domain: test.example.com network_domain: test.example.com
zone: "{{ cs_common_zone_adv }}" zone: "{{ cs_common_zone_adv }}"
state: started
register: vpc register: vpc
- name: verify test create vpc with custom offering - name: verify test create vpc with custom offering
assert: assert:
@ -90,6 +92,7 @@
vpc_offering: Redundant VPC offering vpc_offering: Redundant VPC offering
network_domain: test.example.com network_domain: test.example.com
zone: "{{ cs_common_zone_adv }}" zone: "{{ cs_common_zone_adv }}"
state: started
register: vpc register: vpc
- name: verify test create vpc with custom offering idempotence - name: verify test create vpc with custom offering idempotence
assert: assert:
@ -101,7 +104,6 @@
- vpc.cidr == "10.10.1.0/16" - vpc.cidr == "10.10.1.0/16"
- vpc.network_domain == "test.example.com" - vpc.network_domain == "test.example.com"
- name: test create vpc with default offering in check mode - name: test create vpc with default offering in check mode
cs_vpc: cs_vpc:
name: "{{ cs_resource_prefix }}_vpc" name: "{{ cs_resource_prefix }}_vpc"

@ -258,7 +258,6 @@ lib/ansible/modules/cloud/cloudstack/cs_vmsnapshot.py E325
lib/ansible/modules/cloud/cloudstack/cs_volume.py E322 lib/ansible/modules/cloud/cloudstack/cs_volume.py E322
lib/ansible/modules/cloud/cloudstack/cs_volume.py E324 lib/ansible/modules/cloud/cloudstack/cs_volume.py E324
lib/ansible/modules/cloud/cloudstack/cs_volume.py E325 lib/ansible/modules/cloud/cloudstack/cs_volume.py E325
lib/ansible/modules/cloud/cloudstack/cs_vpc.py E325
lib/ansible/modules/cloud/cloudstack/cs_vpc_offering.py E325 lib/ansible/modules/cloud/cloudstack/cs_vpc_offering.py E325
lib/ansible/modules/cloud/cloudstack/cs_vpn_connection.py E322 lib/ansible/modules/cloud/cloudstack/cs_vpn_connection.py E322
lib/ansible/modules/cloud/cloudstack/cs_vpn_customer_gateway.py E325 lib/ansible/modules/cloud/cloudstack/cs_vpn_customer_gateway.py E325

Loading…
Cancel
Save