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