2015-10-17 14:01:02 +02:00
|
|
|
---
|
2019-04-18 23:58:41 +02:00
|
|
|
- name: ensure instance is expunged
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-lb"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: expunged
|
|
|
|
register: instance
|
|
|
|
- name: verify ensure instance is expunged
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- instance is successful
|
|
|
|
|
|
|
|
- name: ensure network is absent
|
|
|
|
cs_network:
|
|
|
|
name: "{{ cs_resource_prefix }}_net_lb"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: lb_net
|
|
|
|
- name: verify ensure network is absent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- lb_net is successful
|
|
|
|
|
2017-05-09 05:32:11 +02:00
|
|
|
- name: test create network for lb
|
|
|
|
cs_network:
|
|
|
|
name: "{{ cs_resource_prefix }}_net_lb"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network_offering: Offering for Isolated networks with Source Nat service enabled
|
|
|
|
register: lb_net
|
|
|
|
- name: verify test create network for lb
|
2015-10-17 14:01:02 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb_net is successful
|
|
|
|
- lb_net is changed
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb_net.name == "{{ cs_resource_prefix }}_net_lb"
|
2015-10-17 14:01:02 +02:00
|
|
|
|
2017-05-09 05:32:11 +02:00
|
|
|
- name: setup instance in lb
|
2015-10-17 14:01:02 +02:00
|
|
|
cs_instance:
|
2017-05-09 05:32:11 +02:00
|
|
|
name: "{{ cs_resource_prefix }}-vm-lb"
|
|
|
|
template: "{{ cs_common_template }}"
|
|
|
|
service_offering: "{{ cs_common_service_offering }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network: "{{ cs_resource_prefix }}_net_lb"
|
2015-10-17 14:01:02 +02:00
|
|
|
register: instance
|
2019-04-18 23:58:41 +02:00
|
|
|
until: instance is success
|
|
|
|
retries: 20
|
|
|
|
delay: 5
|
2017-05-09 05:32:11 +02:00
|
|
|
- name: verify setup instance in lb
|
2015-10-17 14:01:02 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2017-05-09 05:32:11 +02:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-lb"
|
|
|
|
- instance.state == "Running"
|
|
|
|
|
|
|
|
- name: setup get ip address for lb
|
|
|
|
cs_ip_address:
|
|
|
|
network: "{{ cs_resource_prefix }}_net_lb"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: ip_address
|
2019-04-18 23:58:41 +02:00
|
|
|
- name: verify setup get ip address in lb
|
2017-05-09 05:32:11 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- ip_address is successful
|
2017-05-09 05:32:11 +02:00
|
|
|
|
|
|
|
- name: setup lb rule absent
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
|
|
|
state: absent
|
|
|
|
register: lb
|
|
|
|
- name: verify setup lb rule absent
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
2015-10-17 14:01:02 +02:00
|
|
|
|
|
|
|
- name: test rule requires params
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
ignore_errors: true
|
|
|
|
register: lb
|
|
|
|
- name: verify test rule requires params
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is failed
|
2017-05-09 13:37:08 +02:00
|
|
|
- "lb.msg.startswith('missing required arguments: ')"
|
2015-10-17 14:01:02 +02:00
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
|
|
|
|
- name: test create rule in check mode
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
|
|
|
algorithm: roundrobin
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8080
|
|
|
|
register: lb
|
|
|
|
check_mode: true
|
|
|
|
- name: verify test create rule in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
|
2015-10-17 14:01:02 +02:00
|
|
|
- name: test create rule
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
algorithm: roundrobin
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8080
|
|
|
|
register: lb
|
|
|
|
- name: verify test create rule
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "roundrobin"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
|
|
|
|
- name: test create rule idempotence
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
algorithm: roundrobin
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8080
|
|
|
|
register: lb
|
2017-05-09 05:32:11 +02:00
|
|
|
- name: verify test create rule idempotence
|
2015-10-17 14:01:02 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is not changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "roundrobin"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test update rule in check mode
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
|
|
|
algorithm: source
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8080
|
|
|
|
register: lb
|
|
|
|
check_mode: true
|
|
|
|
- name: verify test update rule in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "roundrobin"
|
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
|
2015-10-17 14:01:02 +02:00
|
|
|
- name: test update rule
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
algorithm: source
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8080
|
|
|
|
register: lb
|
|
|
|
- name: verify test update rule
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
|
|
|
|
- name: test update rule idempotence
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
algorithm: source
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8080
|
|
|
|
register: lb
|
|
|
|
- name: verify test update rule idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is not changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
|
|
|
|
- name: test rule member requires params
|
|
|
|
cs_loadbalancer_rule_member:
|
|
|
|
ignore_errors: true
|
|
|
|
register: lb
|
|
|
|
- name: verify test rule requires params
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is failed
|
2017-05-09 13:37:08 +02:00
|
|
|
- "lb.msg.startswith('missing required arguments: ')"
|
2015-10-17 14:01:02 +02:00
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test add members to rule in check mode
|
|
|
|
cs_loadbalancer_rule_member:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-lb"
|
|
|
|
register: lb
|
|
|
|
check_mode: true
|
|
|
|
- name: verify add members to rule in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
- "'{{ cs_resource_prefix }}-vm-lb' not in lb.vms"
|
|
|
|
|
2015-10-17 14:01:02 +02:00
|
|
|
- name: test add members to rule
|
|
|
|
cs_loadbalancer_rule_member:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
vm: "{{ cs_resource_prefix }}-vm-lb"
|
2015-10-17 14:01:02 +02:00
|
|
|
register: lb
|
|
|
|
- name: verify add members to rule
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
2017-05-09 05:32:11 +02:00
|
|
|
- "'{{ cs_resource_prefix }}-vm-lb' in lb.vms"
|
2015-10-17 14:01:02 +02:00
|
|
|
|
|
|
|
- name: test add members to rule idempotence
|
|
|
|
cs_loadbalancer_rule_member:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
vm: "{{ cs_resource_prefix }}-vm-lb"
|
2015-10-17 14:01:02 +02:00
|
|
|
register: lb
|
|
|
|
- name: verify add members to rule idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is not changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
2017-05-09 05:32:11 +02:00
|
|
|
- "'{{ cs_resource_prefix }}-vm-lb' in lb.vms"
|
2015-10-17 14:01:02 +02:00
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test remove members to rule in check mode
|
|
|
|
cs_loadbalancer_rule_member:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-lb"
|
|
|
|
state: absent
|
|
|
|
register: lb
|
|
|
|
check_mode: true
|
|
|
|
- name: verify remove members to rule in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
- "'{{ cs_resource_prefix }}-vm-lb' in lb.vms"
|
|
|
|
|
2015-10-17 14:01:02 +02:00
|
|
|
- name: test remove members to rule
|
|
|
|
cs_loadbalancer_rule_member:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
vm: "{{ cs_resource_prefix }}-vm-lb"
|
2015-10-17 14:01:02 +02:00
|
|
|
state: absent
|
|
|
|
register: lb
|
|
|
|
- name: verify remove members to rule
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
2017-05-09 05:32:11 +02:00
|
|
|
- "'{{ cs_resource_prefix }}-vm-lb' not in lb.vms"
|
2015-10-17 14:01:02 +02:00
|
|
|
|
|
|
|
- name: test remove members to rule idempotence
|
|
|
|
cs_loadbalancer_rule_member:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
vm: "{{ cs_resource_prefix }}-vm-lb"
|
2015-10-17 14:01:02 +02:00
|
|
|
state: absent
|
|
|
|
register: lb
|
|
|
|
- name: verify remove members to rule
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is not changed
|
2015-10-17 14:01:02 +02:00
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test remove rule in check mode
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
|
|
|
state: absent
|
|
|
|
register: lb
|
|
|
|
check_mode: true
|
|
|
|
- name: verify remove rule in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
|
2015-10-17 14:01:02 +02:00
|
|
|
- name: test remove rule
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
state: absent
|
|
|
|
register: lb
|
|
|
|
- name: verify remove rule
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is changed
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.name == "{{ cs_resource_prefix }}_lb"
|
|
|
|
- lb.algorithm == "source"
|
2017-05-09 05:32:11 +02:00
|
|
|
- lb.public_ip == "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
- lb.public_port == 80
|
|
|
|
- lb.private_port == 8080
|
|
|
|
|
|
|
|
- name: test remove rule idempotence
|
|
|
|
cs_loadbalancer_rule:
|
|
|
|
name: "{{ cs_resource_prefix }}_lb"
|
2017-05-09 05:32:11 +02:00
|
|
|
public_ip: "{{ ip_address.ip_address }}"
|
2015-10-17 14:01:02 +02:00
|
|
|
state: absent
|
|
|
|
register: lb
|
|
|
|
- name: verify remove rule idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- lb is successful
|
|
|
|
- lb is not changed
|
2019-04-18 23:58:41 +02:00
|
|
|
|
|
|
|
- name: cleanup ip address
|
|
|
|
cs_ip_address:
|
|
|
|
network: "{{ cs_resource_prefix }}_net_lb"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
ip_address: "{{ ip_address.ip_address }}"
|
|
|
|
state: absent
|
|
|
|
register: ip_address
|
|
|
|
- name: verify cleanup ip address
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- ip_address is successful
|
|
|
|
- instance is changed
|
|
|
|
|
|
|
|
- name: cleanup instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-lb"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: expunged
|
|
|
|
register: instance
|
|
|
|
- name: verify cleanup instance
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
|
|
|
|
|
|
|
- name: cleanup network
|
|
|
|
cs_network:
|
|
|
|
name: "{{ cs_resource_prefix }}_net_lb"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: lb_net
|
|
|
|
- name: verify cleanup network
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- lb_net is successful
|
|
|
|
- lb_net is changed
|