Bug fixes for gcp_compute_health_check (#42811)

This commit is contained in:
Alex Stephen 2018-08-13 09:07:24 -07:00
commit 4e05af1686
2 changed files with 38 additions and 37 deletions

View file

@ -27,8 +27,6 @@
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
state: absent
#----------------------------------------------------------
- name: create a health check
@ -45,8 +43,6 @@
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
state: present
register: result
- name: assert changed is true
@ -55,13 +51,19 @@
- result.changed == true
- "result.kind == 'compute#healthCheck'"
- name: verify that health_check was created
shell: |
gcloud compute health-checks describe --project="{{gcp_project}}" "{{ resource_name }}"
gcp_compute_health_check_facts:
filters:
- name = {{ resource_name }}
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
register: results
- name: verify that command succeeded
assert:
that:
- results.rc == 0
- results['items'] | length == 1
# ----------------------------------------------------------------------------
- name: create a health check that already exists
gcp_compute_health_check:
@ -77,8 +79,6 @@
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
state: present
register: result
- name: assert changed is false
@ -101,8 +101,6 @@
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
state: absent
register: result
- name: assert changed is true
@ -111,15 +109,19 @@
- result.changed == true
- result.has_key('kind') == False
- name: verify that health_check was deleted
shell: |
gcloud compute health-checks describe --project="{{gcp_project}}" "{{ resource_name }}"
gcp_compute_health_check_facts:
filters:
- name = {{ resource_name }}
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
register: results
failed_when: results.rc == 0
- name: verify that command succeeded
assert:
that:
- results.rc == 1
- "\"'projects/{{ gcp_project }}/global/healthChecks/{{ resource_name }}' was not found\" in results.stderr"
- results['items'] | length == 0
# ----------------------------------------------------------------------------
- name: delete a health check that does not exist
gcp_compute_health_check:
@ -135,8 +137,6 @@
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/compute
state: absent
register: result
- name: assert changed is false