2015-05-19 10:11:55 +02:00
|
|
|
---
|
2017-05-09 05:32:11 +02:00
|
|
|
- name: network setup
|
|
|
|
cs_network:
|
|
|
|
name: ansible test
|
|
|
|
network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService
|
|
|
|
network_domain: example.com
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: net
|
|
|
|
- name: verify network setup
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- net is successful
|
2017-05-09 05:32:11 +02:00
|
|
|
|
|
|
|
- name: instance setup
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_portforward_vm }}"
|
|
|
|
template: "{{ cs_common_template }}"
|
|
|
|
service_offering: "{{ cs_common_service_offering }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network: "ansible test"
|
|
|
|
register: instance
|
|
|
|
- name: verify instance setup
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2017-05-09 05:32:11 +02:00
|
|
|
|
|
|
|
- name: public ip address setup
|
|
|
|
cs_ip_address:
|
|
|
|
network: ansible test
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: ip_address
|
|
|
|
- name: verify public ip address setup
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- ip_address is successful
|
2017-05-09 05:32:11 +02:00
|
|
|
|
|
|
|
- name: set ip address as fact
|
|
|
|
set_fact:
|
|
|
|
cs_portforward_public_ip: "{{ ip_address.ip_address }}"
|
|
|
|
|
|
|
|
- name: clear existing port forwarding
|
2015-05-19 10:11:55 +02:00
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8080
|
|
|
|
state: absent
|
2017-05-09 05:32:11 +02:00
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
2015-05-19 10:11:55 +02:00
|
|
|
register: pf
|
2017-05-09 05:32:11 +02:00
|
|
|
- name: verify clear existing port forwarding
|
2015-05-19 10:11:55 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
2015-05-19 10:11:55 +02:00
|
|
|
|
|
|
|
- name: test fail if missing params
|
|
|
|
action: cs_portforward
|
|
|
|
register: pf
|
|
|
|
ignore_errors: true
|
|
|
|
- name: verify results of fail if missing params
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is failed
|
2017-05-09 13:37:08 +02:00
|
|
|
- 'pf.msg.startswith("missing required arguments: ")'
|
2015-05-19 10:11:55 +02:00
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test present port forwarding in check mode
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
vm: "{{ cs_portforward_vm }}"
|
|
|
|
private_port: 8080
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: pf
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results of present port forwarding in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
|
2015-05-19 10:11:55 +02:00
|
|
|
- name: test present port forwarding
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
vm: "{{ cs_portforward_vm }}"
|
|
|
|
private_port: 8080
|
2017-05-09 05:32:11 +02:00
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
2015-05-19 10:11:55 +02:00
|
|
|
register: pf
|
|
|
|
- name: verify results of present port forwarding
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is changed
|
2015-05-19 10:11:55 +02:00
|
|
|
- pf.vm_name == "{{ cs_portforward_vm }}"
|
|
|
|
- pf.ip_address == "{{ cs_portforward_public_ip }}"
|
|
|
|
- pf.public_port == 80
|
|
|
|
- pf.public_end_port == 80
|
|
|
|
- pf.private_port == 8080
|
|
|
|
- pf.private_end_port == 8080
|
|
|
|
|
|
|
|
- name: test present port forwarding idempotence
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
vm: "{{ cs_portforward_vm }}"
|
|
|
|
private_port: 8080
|
2017-05-09 05:32:11 +02:00
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
2015-05-19 10:11:55 +02:00
|
|
|
register: pf
|
|
|
|
- name: verify results of present port forwarding idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is not changed
|
2015-05-19 10:11:55 +02:00
|
|
|
- pf.vm_name == "{{ cs_portforward_vm }}"
|
|
|
|
- pf.ip_address == "{{ cs_portforward_public_ip }}"
|
|
|
|
- pf.public_port == 80
|
|
|
|
- pf.public_end_port == 80
|
|
|
|
- pf.private_port == 8080
|
|
|
|
- pf.private_end_port == 8080
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test change port forwarding in check mode
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
vm: "{{ cs_portforward_vm }}"
|
|
|
|
private_port: 8888
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: pf
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results of change port forwarding in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- pf.vm_name == "{{ cs_portforward_vm }}"
|
|
|
|
- pf.ip_address == "{{ cs_portforward_public_ip }}"
|
|
|
|
- pf.public_port == 80
|
|
|
|
- pf.public_end_port == 80
|
|
|
|
- pf.private_port == 8080
|
|
|
|
- pf.private_end_port == 8080
|
|
|
|
|
2015-05-19 10:11:55 +02:00
|
|
|
- name: test change port forwarding
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
vm: "{{ cs_portforward_vm }}"
|
|
|
|
private_port: 8888
|
2017-05-09 05:32:11 +02:00
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
2015-05-19 10:11:55 +02:00
|
|
|
register: pf
|
|
|
|
- name: verify results of change port forwarding
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is changed
|
2015-05-19 10:11:55 +02:00
|
|
|
- pf.vm_name == "{{ cs_portforward_vm }}"
|
|
|
|
- pf.ip_address == "{{ cs_portforward_public_ip }}"
|
|
|
|
- pf.public_port == 80
|
|
|
|
- pf.public_end_port == 80
|
|
|
|
- pf.private_port == 8888
|
|
|
|
- pf.private_end_port == 8888
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test change port forwarding idempotence
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
vm: "{{ cs_portforward_vm }}"
|
|
|
|
private_port: 8888
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: pf
|
|
|
|
- name: verify results of change port forwarding idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is not changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- pf.vm_name == "{{ cs_portforward_vm }}"
|
|
|
|
- pf.ip_address == "{{ cs_portforward_public_ip }}"
|
|
|
|
- pf.public_port == 80
|
|
|
|
- pf.public_end_port == 80
|
|
|
|
- pf.private_port == 8888
|
|
|
|
- pf.private_end_port == 8888
|
|
|
|
|
|
|
|
- name: test absent port forwarding in check mode
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8888
|
|
|
|
state: absent
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: pf
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results of absent port forwarding in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- pf.vm_name == "{{ cs_portforward_vm }}"
|
|
|
|
- pf.ip_address == "{{ cs_portforward_public_ip }}"
|
|
|
|
- pf.public_port == 80
|
|
|
|
- pf.public_end_port == 80
|
|
|
|
- pf.private_port == 8888
|
|
|
|
- pf.private_end_port == 8888
|
|
|
|
|
2015-05-19 10:11:55 +02:00
|
|
|
- name: test absent port forwarding
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8888
|
|
|
|
state: absent
|
2017-05-09 05:32:11 +02:00
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
2015-05-19 10:11:55 +02:00
|
|
|
register: pf
|
|
|
|
- name: verify results of absent port forwarding
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is changed
|
2015-05-19 10:11:55 +02:00
|
|
|
- pf.vm_name == "{{ cs_portforward_vm }}"
|
|
|
|
- pf.ip_address == "{{ cs_portforward_public_ip }}"
|
|
|
|
- pf.public_port == 80
|
|
|
|
- pf.public_end_port == 80
|
|
|
|
- pf.private_port == 8888
|
|
|
|
- pf.private_end_port == 8888
|
|
|
|
|
|
|
|
- name: test absent port forwarding idempotence
|
|
|
|
cs_portforward:
|
|
|
|
ip_address: "{{ cs_portforward_public_ip }}"
|
|
|
|
public_port: 80
|
|
|
|
private_port: 8888
|
|
|
|
state: absent
|
2017-05-09 05:32:11 +02:00
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
2015-05-19 10:11:55 +02:00
|
|
|
register: pf
|
|
|
|
- name: verify results of absent port forwarding idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- pf is successful
|
|
|
|
- pf is not changed
|
2017-05-09 05:32:11 +02:00
|
|
|
|
|
|
|
- name: instance cleanup
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_portforward_vm }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: expunged
|
|
|
|
register: instance
|
|
|
|
- name: verify instance cleanup
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2017-05-09 05:32:11 +02:00
|
|
|
|
|
|
|
- name: network cleanup
|
|
|
|
cs_network:
|
|
|
|
name: ansible test
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: net
|
|
|
|
- name: verify network cleanup
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- net is successful
|