|
|
|
@ -15,18 +15,16 @@
|
|
|
|
|
# Pre-test setup
|
|
|
|
|
- name: create a instance group
|
|
|
|
|
gcp_compute_instance_group:
|
|
|
|
|
name: 'instancegroup-targethttpproxy'
|
|
|
|
|
zone: 'us-central1-a'
|
|
|
|
|
name: "instancegroup-targethttpproxy"
|
|
|
|
|
zone: us-central1-a
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: present
|
|
|
|
|
register: instancegroup
|
|
|
|
|
- name: create a http health check
|
|
|
|
|
gcp_compute_http_health_check:
|
|
|
|
|
name: 'httphealthcheck-targethttpproxy'
|
|
|
|
|
name: "httphealthcheck-targethttpproxy"
|
|
|
|
|
healthy_threshold: 10
|
|
|
|
|
port: 8080
|
|
|
|
|
timeout_sec: 2
|
|
|
|
@ -34,34 +32,28 @@
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: present
|
|
|
|
|
register: healthcheck
|
|
|
|
|
- name: create a backend service
|
|
|
|
|
gcp_compute_backend_service:
|
|
|
|
|
name: 'backendservice-targethttpproxy'
|
|
|
|
|
name: "backendservice-targethttpproxy"
|
|
|
|
|
backends:
|
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
|
health_checks:
|
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
|
enable_cdn: true
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: present
|
|
|
|
|
register: backendservice
|
|
|
|
|
- name: create a url map
|
|
|
|
|
gcp_compute_url_map:
|
|
|
|
|
name: 'urlmap-targethttpproxy'
|
|
|
|
|
name: "urlmap-targethttpproxy"
|
|
|
|
|
default_service: "{{ backendservice }}"
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: present
|
|
|
|
|
register: urlmap
|
|
|
|
|
- name: delete a target http proxy
|
|
|
|
@ -71,8 +63,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 target http proxy
|
|
|
|
@ -82,8 +72,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
|
|
|
|
@ -92,13 +80,19 @@
|
|
|
|
|
- result.changed == true
|
|
|
|
|
- "result.kind == 'compute#targetHttpProxy'"
|
|
|
|
|
- name: verify that target_http_proxy was created
|
|
|
|
|
shell: |
|
|
|
|
|
gcloud compute target-http-proxies describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
|
|
|
|
gcp_compute_target_http_proxy_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 target http proxy that already exists
|
|
|
|
|
gcp_compute_target_http_proxy:
|
|
|
|
@ -107,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: present
|
|
|
|
|
register: result
|
|
|
|
|
- name: assert changed is false
|
|
|
|
@ -124,8 +116,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
|
|
|
|
@ -134,15 +124,19 @@
|
|
|
|
|
- result.changed == true
|
|
|
|
|
- result.has_key('kind') == False
|
|
|
|
|
- name: verify that target_http_proxy was deleted
|
|
|
|
|
shell: |
|
|
|
|
|
gcloud compute target-http-proxies describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
|
|
|
|
gcp_compute_target_http_proxy_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/targetHttpProxies/{{ resource_name }}' was not found\" in results.stderr"
|
|
|
|
|
- results['items'] | length == 0
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
- name: delete a target http proxy that does not exist
|
|
|
|
|
gcp_compute_target_http_proxy:
|
|
|
|
@ -151,8 +145,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
|
|
|
|
@ -164,33 +156,29 @@
|
|
|
|
|
# Post-test teardown
|
|
|
|
|
- name: delete a url map
|
|
|
|
|
gcp_compute_url_map:
|
|
|
|
|
name: 'urlmap-targethttpproxy'
|
|
|
|
|
name: "urlmap-targethttpproxy"
|
|
|
|
|
default_service: "{{ backendservice }}"
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: absent
|
|
|
|
|
register: urlmap
|
|
|
|
|
- name: delete a backend service
|
|
|
|
|
gcp_compute_backend_service:
|
|
|
|
|
name: 'backendservice-targethttpproxy'
|
|
|
|
|
name: "backendservice-targethttpproxy"
|
|
|
|
|
backends:
|
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
|
health_checks:
|
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
|
enable_cdn: true
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: absent
|
|
|
|
|
register: backendservice
|
|
|
|
|
- name: delete a http health check
|
|
|
|
|
gcp_compute_http_health_check:
|
|
|
|
|
name: 'httphealthcheck-targethttpproxy'
|
|
|
|
|
name: "httphealthcheck-targethttpproxy"
|
|
|
|
|
healthy_threshold: 10
|
|
|
|
|
port: 8080
|
|
|
|
|
timeout_sec: 2
|
|
|
|
@ -198,18 +186,14 @@
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: absent
|
|
|
|
|
register: healthcheck
|
|
|
|
|
- name: delete a instance group
|
|
|
|
|
gcp_compute_instance_group:
|
|
|
|
|
name: 'instancegroup-targethttpproxy'
|
|
|
|
|
zone: 'us-central1-a'
|
|
|
|
|
name: "instancegroup-targethttpproxy"
|
|
|
|
|
zone: us-central1-a
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: absent
|
|
|
|
|
register: instancegroup
|
|
|
|
|