Bug fixes for gcp_compute_http_health_check (#42812)

This commit is contained in:
Alex Stephen 2018-08-15 10:52:00 -07:00
parent 4ef1909aab
commit a9d401f5bb
2 changed files with 74 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 http 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#httpHealthCheck'"
- name: verify that http_health_check was created
shell: |
gcloud compute http-health-checks describe --project="{{gcp_project}}" "{{ resource_name }}"
gcp_compute_http_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 http health check that already exists
gcp_compute_http_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 http_health_check was deleted
shell: |
gcloud compute http-health-checks describe --project="{{gcp_project}}" "{{ resource_name }}"
gcp_compute_http_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/httpHealthChecks/{{ resource_name }}' was not found\" in results.stderr"
- results['items'] | length == 0
# ----------------------------------------------------------------------------
- name: delete a http health check that does not exist
gcp_compute_http_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