Bug fixes for gcp_compute_https_health_check (#42813)

This commit is contained in:
Alex Stephen 2018-08-13 09:08:42 -07:00
commit 67b93ecd44
2 changed files with 73 additions and 75 deletions

View file

@ -23,8 +23,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 https health check
@ -37,8 +35,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
@ -47,13 +43,19 @@
- result.changed == true
- "result.kind == 'compute#httpsHealthCheck'"
- name: verify that https_health_check was created
shell: |
gcloud compute https-health-checks describe --project="{{gcp_project}}" "{{ resource_name }}"
gcp_compute_https_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 https health check that already exists
gcp_compute_https_health_check:
@ -65,8 +67,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
@ -85,8 +85,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
@ -95,15 +93,19 @@
- result.changed == true
- result.has_key('kind') == False
- name: verify that https_health_check was deleted
shell: |
gcloud compute https-health-checks describe --project="{{gcp_project}}" "{{ resource_name }}"
gcp_compute_https_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/httpsHealthChecks/{{ resource_name }}' was not found\" in results.stderr"
- results['items'] | length == 0
# ----------------------------------------------------------------------------
- name: delete a https health check that does not exist
gcp_compute_https_health_check:
@ -115,8 +117,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