@ -5,12 +5,14 @@
gce:
gce:
register : result
register : result
ignore_errors : true
ignore_errors : true
tags:
- param-check
- name : assert failure when called with no parameters
- name : assert failure when called with no parameters
assert:
assert:
that:
that:
- 'result.failed'
- 'result.failed'
- 'result.msg == "M issing GCE connection parameters in libcloud secrets file. "'
- 'result.msg == "M ust specify a \"name\" or \"instance_names\" "'
# ============================================================
# ============================================================
- name : test missing name
- name : test missing name
@ -20,8 +22,10 @@
project_id : "{{ project_id }}"
project_id : "{{ project_id }}"
register : result
register : result
ignore_errors : true
ignore_errors : true
tags:
- param-check
- name : assert failure when called with no parameters
- name : assert failure when missing name
assert:
assert:
that:
that:
- 'result.failed'
- 'result.failed'
@ -95,6 +99,43 @@
- 'result.name == "{{ instance_name }}"'
- 'result.name == "{{ instance_name }}"'
- 'result.state == "absent"'
- 'result.state == "absent"'
# ============================================================
- name : test num_instances state=present (expected changed=true)
gce:
base_name : "{{ instance_name }}"
num_instances : 2
service_account_email : "{{ service_account_email }}"
pem_file : "{{ pem_file }}"
project_id : "{{ project_id }}"
state : present
register : result
- name : assert state=present (expected changed=true)
assert:
that:
- 'result.changed'
- 'result.name == "{{ instance_name }}"'
- 'result.state == "present"'
- 'result.instance_data|length == 2'
# ============================================================
- name : test num_instances state=absent (expected changed=true)
gce:
base_name : "{{ instance_name }}"
num_instances : 2
service_account_email : "{{ service_account_email }}"
pem_file : "{{ pem_file }}"
project_id : "{{ project_id }}"
state : absent
register : result
- name : assert num_instances state=absent (expected changed=true)
assert:
that:
- 'result.changed'
- 'result.state == "absent"'
- 'result.instance_names == ["{{ instance_name }}-000", "{{ instance_name }}-001"]'
# ============================================================
# ============================================================
- name : test disks given (expected changed=true)
- name : test disks given (expected changed=true)
gce:
gce: