2015-05-03 14:06:30 +00:00
|
|
|
---
|
2015-12-14 13:23:44 +00:00
|
|
|
- name: setup instance to be absent
|
2018-05-25 09:20:04 +00:00
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
state: expunged
|
2015-12-14 13:23:44 +00:00
|
|
|
register: instance
|
|
|
|
- name: verify instance to be absent
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
2015-12-14 13:23:44 +00:00
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test create instance in check mode
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
|
|
|
affinity_group: "{{ cs_resource_prefix }}-ag"
|
|
|
|
security_group: "{{ cs_resource_prefix }}-sg"
|
|
|
|
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
2018-03-08 16:05:57 +00:00
|
|
|
user_data: |
|
|
|
|
#cloud-config
|
|
|
|
package_upgrade: true
|
|
|
|
packages:
|
|
|
|
- tmux
|
2017-05-26 10:19:47 +00:00
|
|
|
tags: []
|
|
|
|
register: instance
|
|
|
|
check_mode: true
|
|
|
|
- name: verify create instance in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test create instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
affinity_group: "{{ cs_resource_prefix }}-ag"
|
|
|
|
security_group: "{{ cs_resource_prefix }}-sg"
|
|
|
|
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
2018-03-08 16:05:57 +00:00
|
|
|
user_data: |
|
|
|
|
#cloud-config
|
|
|
|
package_upgrade: true
|
|
|
|
packages:
|
|
|
|
- tmux
|
2015-05-03 14:06:30 +00:00
|
|
|
tags: []
|
|
|
|
register: instance
|
|
|
|
- name: verify create instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Running"
|
|
|
|
- instance.ssh_key == "{{ cs_resource_prefix }}-sshkey"
|
|
|
|
- not instance.tags
|
|
|
|
|
|
|
|
- name: test create instance idempotence
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
affinity_group: "{{ cs_resource_prefix }}-ag"
|
|
|
|
security_group: "{{ cs_resource_prefix }}-sg"
|
|
|
|
ssh_key: "{{ cs_resource_prefix }}-sshkey"
|
2018-03-08 16:05:57 +00:00
|
|
|
user_data: |
|
|
|
|
#cloud-config
|
|
|
|
package_upgrade: true
|
|
|
|
packages:
|
|
|
|
- tmux
|
2015-05-03 14:06:30 +00:00
|
|
|
tags: []
|
|
|
|
register: instance
|
|
|
|
- name: verify create instance idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is not changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Running"
|
|
|
|
- instance.ssh_key == "{{ cs_resource_prefix }}-sshkey"
|
|
|
|
- not instance.tags
|
|
|
|
|
2018-05-25 09:20:04 +00:00
|
|
|
- name: gather host facts of running instance
|
|
|
|
cs_instance_facts:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test running instance not updated in check mode
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_2 }}"
|
|
|
|
register: instance
|
|
|
|
check_mode: true
|
|
|
|
- name: verify running instance not updated in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is not changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
|
|
|
- instance.state == "Running"
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test running instance not updated
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
service_offering: "{{ test_cs_instance_offering_2 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
register: instance
|
|
|
|
- name: verify running instance not updated
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is not changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Running"
|
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test stopping instance in check mode
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
state: stopped
|
|
|
|
register: instance
|
|
|
|
check_mode: true
|
|
|
|
- name: verify stopping instance in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
|
|
|
- instance.state == "Running"
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test stopping instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
state: stopped
|
|
|
|
register: instance
|
|
|
|
- name: verify stopping instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Stopped"
|
|
|
|
|
|
|
|
- name: test stopping instance idempotence
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
state: stopped
|
|
|
|
register: instance
|
|
|
|
- name: verify stopping instance idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is not changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Stopped"
|
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test updating stopped instance in check mode
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
display_name: "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_2 }}"
|
|
|
|
register: instance
|
|
|
|
check_mode: true
|
|
|
|
- name: verify updating stopped instance in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
|
|
|
- instance.state == "Stopped"
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test updating stopped instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
display_name: "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
service_offering: "{{ test_cs_instance_offering_2 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
register: instance
|
|
|
|
- name: verify updating stopped instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Stopped"
|
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test updating stopped instance idempotence
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
display_name: "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_2 }}"
|
|
|
|
register: instance
|
|
|
|
- name: verify updating stopped instance idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is not changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
|
|
|
|
- instance.state == "Stopped"
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test starting instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
state: started
|
|
|
|
register: instance
|
|
|
|
- name: verify starting instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Running"
|
|
|
|
|
|
|
|
- name: test starting instance idempotence
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
state: started
|
|
|
|
register: instance
|
|
|
|
- name: verify starting instance idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is not changed
|
2015-12-14 13:23:44 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Running"
|
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test force update running instance in check mode
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
|
|
|
force: true
|
|
|
|
register: instance
|
|
|
|
check_mode: true
|
|
|
|
- name: verify force update running instance in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_2 }}"
|
|
|
|
- instance.state == "Running"
|
|
|
|
|
2015-05-03 14:06:30 +00:00
|
|
|
- name: test force update running instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
force: true
|
|
|
|
register: instance
|
|
|
|
- name: verify force update running instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-12-14 13:23:44 +00:00
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Running"
|
|
|
|
|
|
|
|
- name: test force update running instance idempotence
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
force: true
|
|
|
|
register: instance
|
|
|
|
- name: verify force update running instance idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is not changed
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
2015-12-14 13:23:44 +00:00
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
2015-08-23 20:49:45 +00:00
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
2015-05-03 14:06:30 +00:00
|
|
|
- instance.state == "Running"
|
2015-12-14 13:23:44 +00:00
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test restore instance in check mode
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
state: restored
|
|
|
|
register: instance
|
|
|
|
check_mode: true
|
|
|
|
- name: verify restore instance in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|
|
|
|
|
2015-12-14 13:23:44 +00:00
|
|
|
- name: test restore instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
state: restored
|
|
|
|
register: instance
|
|
|
|
- name: verify restore instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
|
|
|
- instance is changed
|
2015-12-14 13:23:44 +00:00
|
|
|
- instance.name == "{{ cs_resource_prefix }}-vm-{{ instance_number }}"
|
|
|
|
- instance.display_name == "{{ cs_resource_prefix }}-display-{{ instance_number }}"
|
|
|
|
- instance.service_offering == "{{ test_cs_instance_offering_1 }}"
|