diff --git a/lib/ansible/modules/cloud/cloudstack/cs_vpc.py b/lib/ansible/modules/cloud/cloudstack/cs_vpc.py index 5b943ace710..691c47bbc50 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_vpc.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_vpc.py @@ -4,6 +4,9 @@ # Copyright (c) 2016, René Moser # 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,24 +74,33 @@ 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: module: cs_vpc @@ -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(), diff --git a/test/integration/targets/cs_vpc/tasks/main.yml b/test/integration/targets/cs_vpc/tasks/main.yml index bcf7d6e879e..aafc8607812 100644 --- a/test/integration/targets/cs_vpc/tasks/main.yml +++ b/test/integration/targets/cs_vpc/tasks/main.yml @@ -55,6 +55,7 @@ vpc_offering: Redundant VPC offering network_domain: test.example.com zone: "{{ cs_common_zone_adv }}" + state: started register: vpc check_mode: true - name: verify test create vpc with custom offering in check mode @@ -71,6 +72,7 @@ vpc_offering: Redundant VPC offering network_domain: test.example.com zone: "{{ cs_common_zone_adv }}" + state: started register: vpc - name: verify test create vpc with custom offering assert: @@ -90,6 +92,7 @@ vpc_offering: Redundant VPC offering network_domain: test.example.com zone: "{{ cs_common_zone_adv }}" + state: started register: vpc - name: verify test create vpc with custom offering idempotence assert: @@ -101,7 +104,6 @@ - vpc.cidr == "10.10.1.0/16" - vpc.network_domain == "test.example.com" - - name: test create vpc with default offering in check mode cs_vpc: name: "{{ cs_resource_prefix }}_vpc" diff --git a/test/sanity/validate-modules/ignore.txt b/test/sanity/validate-modules/ignore.txt index 1b671eec067..94b2714de6b 100644 --- a/test/sanity/validate-modules/ignore.txt +++ b/test/sanity/validate-modules/ignore.txt @@ -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 E324 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_vpn_connection.py E322 lib/ansible/modules/cloud/cloudstack/cs_vpn_customer_gateway.py E325