2017-07-07 13:47:44 +02:00
|
|
|
---
|
|
|
|
- name: setup network
|
|
|
|
cs_network:
|
|
|
|
name: "net_nic"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network_offering: DefaultSharedNetworkOffering
|
|
|
|
network_domain: example.com
|
|
|
|
vlan: 1234
|
|
|
|
start_ip: 10.100.123.11
|
|
|
|
end_ip: 10.100.123.250
|
|
|
|
gateway: 10.100.123.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-07 13:47:44 +02:00
|
|
|
- net.name == "net_nic"
|
|
|
|
|
|
|
|
- name: setup instance
|
|
|
|
cs_instance:
|
|
|
|
name: "instance-nic-vm"
|
|
|
|
template: "{{ cs_common_template }}"
|
|
|
|
service_offering: "{{ cs_common_service_offering }}"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network: "net_nic"
|
|
|
|
state: stopped
|
|
|
|
register: instance
|
|
|
|
- name: verify setup instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2017-07-07 13:47:44 +02:00
|
|
|
- instance.name == "instance-nic-vm"
|
|
|
|
- instance.state == "Stopped"
|
|
|
|
|
|
|
|
- name: setup network 2
|
|
|
|
cs_network:
|
|
|
|
name: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
network_offering: DefaultSharedNetworkOffering
|
|
|
|
network_domain: example.com
|
|
|
|
vlan: 1235
|
|
|
|
start_ip: 10.100.124.11
|
|
|
|
end_ip: 10.100.124.250
|
|
|
|
gateway: 10.100.124.1
|
|
|
|
netmask: 255.255.255.0
|
|
|
|
register: net
|
|
|
|
- name: verify setup network 2
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- net is successful
|
2017-07-07 13:47:44 +02:00
|
|
|
- net.name == "net_nic2"
|
|
|
|
|
|
|
|
- name: setup absent nic
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: nic
|
|
|
|
- name: verify setup absent nic
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
2017-07-07 13:47:44 +02:00
|
|
|
|
|
|
|
- name: test fail missing params
|
|
|
|
cs_instance_nic:
|
|
|
|
ignore_errors: true
|
|
|
|
register: nic
|
|
|
|
- name: verify test fail missing params
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is failed
|
2017-07-07 13:47:44 +02:00
|
|
|
- "nic.msg.startswith('missing required arguments: ')"
|
|
|
|
|
|
|
|
- name: test create nic in check mode
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
check_mode: yes
|
|
|
|
register: nic
|
|
|
|
- name: verify test create nic in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
|
|
|
|
- name: test create nic
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
ip_address: 10.100.124.42
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: nic
|
|
|
|
- name: verify test create nic
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.42"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test create nic idempotence
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
ip_address: 10.100.124.42
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: nic
|
|
|
|
- name: verify test create nic idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is not changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.42"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test create nic without ip address idempotence
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: nic
|
|
|
|
- name: verify test create nic without ip address idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is not changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.42"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test update nic in check mode
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
ip_address: 10.100.124.23
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
check_mode: yes
|
|
|
|
register: nic
|
|
|
|
- name: verify test update nic in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.42"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test update nic
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
ip_address: 10.100.124.23
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: nic
|
|
|
|
- name: verify test update nic
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.23"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test update nic idempotence
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
ip_address: 10.100.124.23
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: nic
|
|
|
|
- name: verify test update nic idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is not changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.23"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test update nic without ip address idempotence
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
register: nic
|
|
|
|
- name: verify test update nic without ip address idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is not changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.23"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test remove nic in check mode
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: nic
|
|
|
|
- name: verify test remove nic in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.23"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test remove nic
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: nic
|
|
|
|
- name: verify test remove nic
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is changed
|
2017-07-07 13:47:44 +02:00
|
|
|
- nic.ip_address == "10.100.124.23"
|
|
|
|
- nic.netmask == "255.255.255.0"
|
|
|
|
- nic.network == "net_nic2"
|
|
|
|
- nic.vm == "instance-nic-vm"
|
|
|
|
- nic.zone == "{{ cs_common_zone_adv }}"
|
|
|
|
- nic.mac_address is defined
|
|
|
|
|
|
|
|
- name: test remove nic idempotence
|
|
|
|
cs_instance_nic:
|
|
|
|
vm: "instance-nic-vm"
|
|
|
|
network: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: nic
|
|
|
|
- name: verify test remove nic idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- nic is successful
|
|
|
|
- nic is not changed
|
2017-07-07 13:47:44 +02:00
|
|
|
|
|
|
|
- name: cleanup instance
|
|
|
|
cs_instance:
|
|
|
|
name: "instance-nic-vm"
|
|
|
|
state: expunged
|
|
|
|
register: instance
|
|
|
|
- name: verify cleanup instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2017-07-07 13:47:44 +02:00
|
|
|
|
|
|
|
- name: cleanup network
|
|
|
|
cs_network:
|
|
|
|
name: "net_nic"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: net
|
|
|
|
- name: verify cleanup network
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- net is successful
|
2017-07-07 13:47:44 +02:00
|
|
|
|
|
|
|
- name: cleanup network 2
|
|
|
|
cs_network:
|
|
|
|
name: "net_nic2"
|
|
|
|
zone: "{{ cs_common_zone_adv }}"
|
|
|
|
state: absent
|
|
|
|
register: net
|
|
|
|
- name: verify cleanup network 2
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- net is successful
|