mirror of https://github.com/ansible/ansible.git
cs_ip_address: fix vpc and network mutually exclusive (#47846)
* cs_ip_address: fix vpc and network mutually exclusive * add changelog * streamline docspull/47924/head
parent
8e561d1eb4
commit
242bd512d0
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- cs_ip_address - fix vpc use case failed if network param provided. Ensured vpc and network are mutually exclusive.
|
@ -1,212 +1,19 @@
|
||||
---
|
||||
- name: setup ensure the test network is absent
|
||||
cs_network:
|
||||
name: ipaddr_test_network
|
||||
state: absent
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
|
||||
- name: setup create the test network
|
||||
cs_network:
|
||||
name: ipaddr_test_network
|
||||
network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService
|
||||
state: present
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: base_network
|
||||
- name: setup verify create the test network
|
||||
assert:
|
||||
that:
|
||||
- base_network is successful
|
||||
|
||||
- name: setup clean ip_address with tags
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
|
||||
- name: setup associate ip_address for SNAT
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_snat
|
||||
|
||||
- name: test associate ip_address in check mode
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
check_mode: true
|
||||
register: ip_address
|
||||
- name: verify test associate ip_address in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test associate ip_address
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test associate ip_address
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
- ip_address.ip_address is defined
|
||||
|
||||
- name: test associate ip_address with tags in check mode
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
check_mode: true
|
||||
- name: verify test associate ip_address with tags in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is changed
|
||||
|
||||
- name: test associate ip_address with tags
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
- name: verify test associate ip_address with tags
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is changed
|
||||
- ip_address_tag.ip_address is defined
|
||||
- ip_address_tag.tags.0.key == "unique_id"
|
||||
- ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
|
||||
- name: test associate ip_address with tags idempotence
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
- name: verify test associate ip_address with tags idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is not changed
|
||||
- ip_address_tag.ip_address is defined
|
||||
- ip_address_tag.state == "Allocated"
|
||||
- ip_address_tag.tags.0.key == "unique_id"
|
||||
- ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
|
||||
- name: test disassiociate ip_address with missing param ip_address
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
ignore_errors: true
|
||||
register: ip_address_err
|
||||
- name: verify test disassiociate ip_address with missing param ip_address
|
||||
assert:
|
||||
that:
|
||||
- ip_address_err is failed
|
||||
- 'ip_address_err.msg == "state is absent but any of the following are missing: ip_address, tags"'
|
||||
|
||||
- name: test disassociate ip_address in check mode
|
||||
- name: test fail vpc and network mutually exclusive
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address.ip_address }}"
|
||||
network: ipaddr_test_network
|
||||
network: "{{ cs_resource_prefix }}_net_vpc"
|
||||
vpc: "foobar"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
check_mode: true
|
||||
ignore_errors: yes
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address in check mode
|
||||
- name: verify test fail vpc and network mutually exclusive
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
- ip_address is failed
|
||||
- 'ip_address.msg == "parameters are mutually exclusive: vpc, network"'
|
||||
|
||||
- name: test disassociate ip_address
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address.ip_address }}"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
- name: run test for network setup
|
||||
import_tasks: network.yml
|
||||
|
||||
- name: test disassociate ip_address idempotence
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address.ip_address }}"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is not changed
|
||||
|
||||
- name: test disassociate ip_address with tags with check mode
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
check_mode: true
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address with tags in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address with tags
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address with tags
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address with tags idempotence
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address with tags idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is not changed
|
||||
|
||||
- name: clean the test network
|
||||
cs_network:
|
||||
name: ipaddr_test_network
|
||||
state: absent
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
- name: run test for vpc setup
|
||||
import_tasks: vpc.yml
|
||||
|
@ -0,0 +1,212 @@
|
||||
---
|
||||
- name: setup ensure the test network is absent
|
||||
cs_network:
|
||||
name: ipaddr_test_network
|
||||
state: absent
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
|
||||
- name: setup create the test network
|
||||
cs_network:
|
||||
name: ipaddr_test_network
|
||||
network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService
|
||||
state: present
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: base_network
|
||||
- name: setup verify create the test network
|
||||
assert:
|
||||
that:
|
||||
- base_network is successful
|
||||
|
||||
- name: setup clean ip_address with tags
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
|
||||
- name: setup associate ip_address for SNAT
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_snat
|
||||
|
||||
- name: test associate ip_address in check mode
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
check_mode: true
|
||||
register: ip_address
|
||||
- name: verify test associate ip_address in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test associate ip_address
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test associate ip_address
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
- ip_address.ip_address is defined
|
||||
|
||||
- name: test associate ip_address with tags in check mode
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
check_mode: true
|
||||
- name: verify test associate ip_address with tags in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is changed
|
||||
|
||||
- name: test associate ip_address with tags
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
- name: verify test associate ip_address with tags
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is changed
|
||||
- ip_address_tag.ip_address is defined
|
||||
- ip_address_tag.tags.0.key == "unique_id"
|
||||
- ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
|
||||
- name: test associate ip_address with tags idempotence
|
||||
cs_ip_address:
|
||||
network: ipaddr_test_network
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
- name: verify test associate ip_address with tags idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is not changed
|
||||
- ip_address_tag.ip_address is defined
|
||||
- ip_address_tag.state == "Allocated"
|
||||
- ip_address_tag.tags.0.key == "unique_id"
|
||||
- ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
|
||||
- name: test disassiociate ip_address with missing param ip_address
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
ignore_errors: true
|
||||
register: ip_address_err
|
||||
- name: verify test disassiociate ip_address with missing param ip_address
|
||||
assert:
|
||||
that:
|
||||
- ip_address_err is failed
|
||||
- 'ip_address_err.msg == "state is absent but any of the following are missing: ip_address, tags"'
|
||||
|
||||
- name: test disassociate ip_address in check mode
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address.ip_address }}"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
check_mode: true
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address.ip_address }}"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address idempotence
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address.ip_address }}"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is not changed
|
||||
|
||||
- name: test disassociate ip_address with tags with check mode
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
check_mode: true
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address with tags in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address with tags
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address with tags
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address with tags idempotence
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
|
||||
network: ipaddr_test_network
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address with tags idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is not changed
|
||||
|
||||
- name: clean the test network
|
||||
cs_network:
|
||||
name: ipaddr_test_network
|
||||
state: absent
|
||||
zone: "{{ cs_common_zone_adv }}"
|
@ -0,0 +1,121 @@
|
||||
---
|
||||
- name: setup vpc
|
||||
cs_vpc:
|
||||
name: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
cidr: 10.10.111.0/16
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: vpc
|
||||
- name: verify setup vpc
|
||||
assert:
|
||||
that:
|
||||
- vpc is successful
|
||||
|
||||
- name: setup clean ip_address with tags
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
|
||||
- name: test associate ip_address in vpc with tags in check mode
|
||||
cs_ip_address:
|
||||
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
check_mode: yes
|
||||
- name: verify test associate ip_address in vpc with tags in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is changed
|
||||
|
||||
- name: test associate ip_address in vpc with tags
|
||||
cs_ip_address:
|
||||
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
- name: verify test associate ip_address in vpc with tags
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is changed
|
||||
- ip_address_tag.ip_address is defined
|
||||
- ip_address_tag.tags.0.key == "unique_id"
|
||||
- ip_address_tag.tags.0.value == "86cdce4c-dce7-11e8-8394-00262df3bf70"
|
||||
|
||||
- name: test associate ip_address in vpc with tags idempotence
|
||||
cs_ip_address:
|
||||
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
tags:
|
||||
- key: unique_id
|
||||
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address_tag
|
||||
- name: verify test associate ip_address in vpc with tags idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address_tag is successful
|
||||
- ip_address_tag is not changed
|
||||
- ip_address_tag.ip_address is defined
|
||||
- ip_address_tag.state == "Allocated"
|
||||
- ip_address_tag.tags.0.key == "unique_id"
|
||||
- ip_address_tag.tags.0.value == "86cdce4c-dce7-11e8-8394-00262df3bf70"
|
||||
|
||||
- name: test disassociate ip_address in vpc in check mode
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address_tag.ip_address }}"
|
||||
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
check_mode: true
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address in vpc in check mode
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address in vpc
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address_tag.ip_address }}"
|
||||
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address in vpc
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is changed
|
||||
|
||||
- name: test disassociate ip_address in vpc idempotence
|
||||
cs_ip_address:
|
||||
state: absent
|
||||
ip_address: "{{ ip_address_tag.ip_address }}"
|
||||
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
register: ip_address
|
||||
- name: verify test disassociate ip_address in vpc idempotence
|
||||
assert:
|
||||
that:
|
||||
- ip_address is successful
|
||||
- ip_address is not changed
|
||||
|
||||
- name: cleanup vpc
|
||||
cs_vpc:
|
||||
name: "{{ cs_resource_prefix }}_vpc_ip_address"
|
||||
zone: "{{ cs_common_zone_adv }}"
|
||||
state: absent
|
||||
register: vpc
|
||||
- name: verify cleanup vpc
|
||||
assert:
|
||||
that:
|
||||
- vpc is successful
|
Loading…
Reference in New Issue