2017-07-15 10:09:25 +02:00
|
|
|
---
|
|
|
|
- name: setup network
|
|
|
|
cs_network:
|
|
|
|
name: "net_router"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network_offering: DefaultSharedNetworkOffering
|
|
|
|
network_domain: example.com
|
|
|
|
vlan: 1234
|
|
|
|
start_ip: 10.100.12.11
|
|
|
|
end_ip: 10.100.12.250
|
|
|
|
gateway: 10.100.12.1
|
|
|
|
netmask: 255.255.255.0
|
|
|
|
register: net
|
|
|
|
- name: verify setup network
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- net is successful
|
2017-07-15 10:09:25 +02:00
|
|
|
- net.name == "net_router"
|
|
|
|
|
|
|
|
- name: setup instance
|
|
|
|
cs_instance:
|
|
|
|
name: "instance-vm"
|
|
|
|
template: "{{ cs_common_template }}"
|
|
|
|
service_offering: "{{ cs_common_service_offering }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network: "net_router"
|
|
|
|
state: started
|
|
|
|
register: instance
|
|
|
|
- name: verify setup instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2017-07-15 10:09:25 +02:00
|
|
|
- instance.name == "instance-vm"
|
|
|
|
- instance.state == "Running"
|
|
|
|
|
|
|
|
- name: setup instance starts a router
|
|
|
|
cs_instance:
|
|
|
|
name: "instance-vm"
|
|
|
|
template: "{{ cs_common_template }}"
|
|
|
|
service_offering: "{{ cs_common_service_offering }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network: "net_router"
|
|
|
|
state: started
|
|
|
|
register: instance
|
|
|
|
- name: verify setup instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2017-07-15 10:09:25 +02:00
|
|
|
- instance.name == "instance-vm"
|
|
|
|
- instance.state == "Running"
|
|
|
|
|
|
|
|
- name: setup find the routers name
|
2017-10-26 09:21:46 +02:00
|
|
|
shell: cs listRouters listall=true networkid="{{ net.id }}" zone="{{ cs_common_zone_adv }}"
|
2017-07-15 10:09:25 +02:00
|
|
|
args:
|
|
|
|
chdir: "{{ playbook_dir }}"
|
|
|
|
register: router
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: router.stdout
|
|
|
|
|
|
|
|
- set_fact:
|
2017-10-26 09:21:46 +02:00
|
|
|
router_json: "{{ router.stdout | from_json }}"
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
router_name: "{{ router_json.router[0].name }}"
|
2017-07-15 10:09:25 +02:00
|
|
|
|
|
|
|
- name: test router started
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: started
|
|
|
|
register: router
|
|
|
|
- name: verify test router started
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is successful
|
2017-07-15 10:09:25 +02:00
|
|
|
|
|
|
|
- name: test stop router in check mode
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: stopped
|
|
|
|
check_mode: true
|
|
|
|
register: router
|
|
|
|
- name: verify test stop router in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Running"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|
|
|
|
|
|
|
|
- name: test stop router
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: stopped
|
|
|
|
register: router
|
|
|
|
- name: verify test stop router
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Stopped"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|
|
|
|
|
|
|
|
- name: test stop router idempotence
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: stopped
|
|
|
|
register: router
|
|
|
|
- name: verify test stop router idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is not changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Stopped"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|
|
|
|
|
|
|
|
- name: test start router in check mode
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: started
|
|
|
|
register: router
|
|
|
|
check_mode: true
|
|
|
|
- name: verify test start router in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Stopped"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|
|
|
|
|
|
|
|
- name: test start router
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: started
|
|
|
|
register: router
|
|
|
|
- name: verify test start router
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Running"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|
|
|
|
|
|
|
|
- name: test start router idempotence
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: started
|
|
|
|
register: router
|
|
|
|
- name: verify test start router idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is not changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Running"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|
|
|
|
|
|
|
|
- name: test restart router in check mode
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: restarted
|
|
|
|
register: router
|
|
|
|
check_mode: true
|
|
|
|
- name: verify test restart router in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Running"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|
|
|
|
|
|
|
|
- name: test restart router
|
|
|
|
cs_router:
|
|
|
|
name: "{{ router_name }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: restarted
|
|
|
|
register: router
|
|
|
|
- name: verify test restart router
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- router is changed
|
2017-07-15 10:09:25 +02:00
|
|
|
- router.state == "Running"
|
|
|
|
- router.service_offering == "System Offering For Software Router"
|