cs_vpc: add new argument clean_up (#33278)

* cs_vpc: add new argument clean_up

* docs cleanup
* extend tests and increase coverage

* change default for clean_up to None

* extend tests
This commit is contained in:
René Moser 2017-11-26 11:28:32 +01:00 committed by GitHub
commit 1a546711e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 175 additions and 76 deletions

View file

@ -33,7 +33,70 @@
- vpc|failed
- 'vpc.msg == "state is present but all of the following are missing: cidr"'
- name: test create vpc in check mode
- name: test fail missing vpc offering not found
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
vpc_offering: does_not_exist
zone: "{{ cs_common_zone_adv }}"
cidr: 10.10.1.0/16
ignore_errors: true
register: vpc
- name: verify test fail missing cidr for vpc
assert:
that:
- vpc|failed
- 'vpc.msg == "VPC offering not found: does_not_exist"'
- name: test create vpc with custom offering in check mode
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc_custom"
display_text: "{{ cs_resource_prefix }}_display_text_custom"
cidr: 10.10.1.0/16
vpc_offering: Redundant VPC offering
zone: "{{ cs_common_zone_adv }}"
register: vpc
check_mode: true
- name: verify test create vpc with custom offering in check mode
assert:
that:
- vpc|success
- vpc|changed
- name: test create vpc with custom offering
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc_custom"
display_text: "{{ cs_resource_prefix }}_display_text_custom"
cidr: 10.10.1.0/16
vpc_offering: Redundant VPC offering
zone: "{{ cs_common_zone_adv }}"
register: vpc
- name: verify test create vpc with custom offering
assert:
that:
- vpc|success
- vpc|changed
- vpc.name == "{{ cs_resource_prefix }}_vpc_custom"
- vpc.display_text == "{{ cs_resource_prefix }}_display_text_custom"
- vpc.cidr == "10.10.1.0/16"
- name: test create vpc with custom offering idempotence
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc_custom"
display_text: "{{ cs_resource_prefix }}_display_text_custom"
cidr: 10.10.1.0/16
vpc_offering: Redundant VPC offering
zone: "{{ cs_common_zone_adv }}"
register: vpc
- name: verify test create vpc with custom offering idempotence
assert:
that:
- vpc|success
- not vpc|changed
- vpc.name == "{{ cs_resource_prefix }}_vpc_custom"
- vpc.display_text == "{{ cs_resource_prefix }}_display_text_custom"
- vpc.cidr == "10.10.1.0/16"
- name: test create vpc with default offering in check mode
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text"
@ -41,20 +104,20 @@
zone: "{{ cs_common_zone_adv }}"
register: vpc
check_mode: true
- name: verify test create vpc in check mode
- name: verify test create vpc with default offering in check mode
assert:
that:
- vpc|success
- vpc|changed
- name: test create vpc
- name: test create vpc with default offering
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text"
cidr: 10.10.0.0/16
zone: "{{ cs_common_zone_adv }}"
register: vpc
- name: verify test create vpc
- name: verify test create vpc with default offering
assert:
that:
- vpc|success
@ -63,14 +126,14 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text"
- vpc.cidr == "10.10.0.0/16"
- name: test create vpc idempotence
- name: test create vpc with default offering idempotence
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text"
cidr: 10.10.0.0/16
zone: "{{ cs_common_zone_adv }}"
register: vpc
- name: verify test create vpc idempotence
- name: verify test create vpc with default offering idempotence
assert:
that:
- vpc|success
@ -79,7 +142,7 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text"
- vpc.cidr == "10.10.0.0/16"
- name: test create vpc idempotence2
- name: test create vpc with default offering idempotence2
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
cidr: 10.10.0.0/16
@ -94,7 +157,7 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text"
- vpc.cidr == "10.10.0.0/16"
- name: test update vpc in check mode
- name: test update vpc with default offering in check mode
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text2"
@ -102,7 +165,7 @@
zone: "{{ cs_common_zone_adv }}"
register: vpc
check_mode: true
- name: verify test update vpc in check mode
- name: verify test update vpc with default offering in check mode
assert:
that:
- vpc|success
@ -111,14 +174,14 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text"
- vpc.cidr == "10.10.0.0/16"
- name: test update vpc
- name: test update vpc with default offering
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text2"
cidr: 10.10.0.0/16
zone: "{{ cs_common_zone_adv }}"
register: vpc
- name: verify test update vpc
- name: verify test update vpc with default offering
assert:
that:
- vpc|success
@ -127,7 +190,7 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text2"
- vpc.cidr == "10.10.0.0/16"
- name: test update vpc idempotence
- name: test update vpc with default offering idempotence
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text2"
@ -143,6 +206,60 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text2"
- vpc.cidr == "10.10.0.0/16"
- name: test restart vpc with default offering with clean up in check mode
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text2"
cidr: 10.10.0.0/16
zone: "{{ cs_common_zone_adv }}"
clean_up: true
state: restarted
register: vpc
check_mode: true
- name: verify test restart vpc with default offering with clean up in check mode
assert:
that:
- vpc|success
- vpc|changed
- vpc.name == "{{ cs_resource_prefix }}_vpc"
- vpc.display_text == "{{ cs_resource_prefix }}_display_text2"
- vpc.cidr == "10.10.0.0/16"
- name: test restart vpc with default offering with clean up
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text2"
cidr: 10.10.0.0/16
zone: "{{ cs_common_zone_adv }}"
clean_up: true
state: restarted
register: vpc
- name: verify test restart vpc with default offering with clean up
assert:
that:
- vpc|success
- vpc|changed
- vpc.name == "{{ cs_resource_prefix }}_vpc"
- vpc.display_text == "{{ cs_resource_prefix }}_display_text2"
- vpc.cidr == "10.10.0.0/16"
- name: test restart vpc with default offering without clean up
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
display_text: "{{ cs_resource_prefix }}_display_text2"
cidr: 10.10.0.0/16
zone: "{{ cs_common_zone_adv }}"
state: restarted
register: vpc
- name: verify test restart vpc with default offering without clean up
assert:
that:
- vpc|success
- vpc|changed
- vpc.name == "{{ cs_resource_prefix }}_vpc"
- vpc.display_text == "{{ cs_resource_prefix }}_display_text2"
- vpc.cidr == "10.10.0.0/16"
- name: test create network in vpc in check mode
cs_network:
name: "{{ cs_resource_prefix }}_net_vpc"
@ -533,14 +650,14 @@
- vpc_net|success
- not vpc_net|changed
- name: test remove vpc in check mode
- name: test remove vpc with default offering in check mode
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
state: absent
zone: "{{ cs_common_zone_adv }}"
register: vpc
check_mode: true
- name: verify test remove vpc in check mode
- name: verify test remove vpc with default offering in check mode
assert:
that:
- vpc|success
@ -549,13 +666,13 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text2"
- vpc.cidr == "10.10.0.0/16"
- name: test remove vpc
- name: test remove vpc with default offering
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
state: absent
zone: "{{ cs_common_zone_adv }}"
register: vpc
- name: verify test remove vpc
- name: verify test remove vpc with default offering
assert:
that:
- vpc|success
@ -564,7 +681,7 @@
- vpc.display_text == "{{ cs_resource_prefix }}_display_text2"
- vpc.cidr == "10.10.0.0/16"
- name: test remove vpc idempotence
- name: test remove vpc with default offering idempotence
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc"
state: absent
@ -574,3 +691,17 @@
that:
- vpc|success
- not vpc|changed
- name: test remove vpc with custom offering
cs_vpc:
name: "{{ cs_resource_prefix }}_vpc_custom"
state: absent
zone: "{{ cs_common_zone_adv }}"
register: vpc
- name: verify test remove vpc with custom offering
assert:
that:
- vpc|success
- vpc|changed
- vpc.name == "{{ cs_resource_prefix }}_vpc_custom"
- vpc.cidr == "10.10.1.0/16"