|
|
|
@ -15,18 +15,16 @@
|
|
|
|
|
# Pre-test setup
|
|
|
|
|
- name: create a instance group
|
|
|
|
|
gcp_compute_instance_group:
|
|
|
|
|
name: 'instancegroup-targethttpsproxy'
|
|
|
|
|
zone: 'us-central1-a'
|
|
|
|
|
name: "instancegroup-targethttpsproxy"
|
|
|
|
|
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-targethttpsproxy'
|
|
|
|
|
name: "httphealthcheck-targethttpsproxy"
|
|
|
|
|
healthy_threshold: 10
|
|
|
|
|
port: 8080
|
|
|
|
|
timeout_sec: 2
|
|
|
|
@ -34,41 +32,34 @@
|
|
|
|
|
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-targethttpsproxy'
|
|
|
|
|
name: "backendservice-targethttpsproxy"
|
|
|
|
|
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-targethttpsproxy'
|
|
|
|
|
name: "urlmap-targethttpsproxy"
|
|
|
|
|
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: create a ssl certificate
|
|
|
|
|
gcp_compute_ssl_certificate:
|
|
|
|
|
name: 'sslcert-targethttpsproxy'
|
|
|
|
|
description: |
|
|
|
|
|
"A certificate for testing. Do not use this certificate in production"
|
|
|
|
|
name: "sslcert-targethttpsproxy"
|
|
|
|
|
description: A certificate for testing. Do not use this certificate in production
|
|
|
|
|
certificate: |
|
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
|
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
|
|
|
@ -96,34 +87,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: sslcert
|
|
|
|
|
- name: delete a target https proxy
|
|
|
|
|
gcp_compute_target_https_proxy:
|
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
|
ssl_certificates:
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
url_map: "{{ urlmap }}"
|
|
|
|
|
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 https proxy
|
|
|
|
|
gcp_compute_target_https_proxy:
|
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
|
ssl_certificates:
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
url_map: "{{ urlmap }}"
|
|
|
|
|
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
|
|
|
|
@ -132,25 +117,29 @@
|
|
|
|
|
- result.changed == true
|
|
|
|
|
- "result.kind == 'compute#targetHttpsProxy'"
|
|
|
|
|
- name: verify that target_https_proxy was created
|
|
|
|
|
shell: |
|
|
|
|
|
gcloud compute target-https-proxies describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
|
|
|
|
gcp_compute_target_https_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 https proxy that already exists
|
|
|
|
|
gcp_compute_target_https_proxy:
|
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
|
ssl_certificates:
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
url_map: "{{ urlmap }}"
|
|
|
|
|
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
|
|
|
|
@ -163,13 +152,11 @@
|
|
|
|
|
gcp_compute_target_https_proxy:
|
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
|
ssl_certificates:
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
url_map: "{{ urlmap }}"
|
|
|
|
|
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
|
|
|
|
@ -178,27 +165,29 @@
|
|
|
|
|
- result.changed == true
|
|
|
|
|
- result.has_key('kind') == False
|
|
|
|
|
- name: verify that target_https_proxy was deleted
|
|
|
|
|
shell: |
|
|
|
|
|
gcloud compute target-https-proxies describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
|
|
|
|
gcp_compute_target_https_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/targetHttpsProxies/{{ resource_name }}' was not found\" in results.stderr"
|
|
|
|
|
- results['items'] | length == 0
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
- name: delete a target https proxy that does not exist
|
|
|
|
|
gcp_compute_target_https_proxy:
|
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
|
ssl_certificates:
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
|
url_map: "{{ urlmap }}"
|
|
|
|
|
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
|
|
|
|
@ -210,9 +199,8 @@
|
|
|
|
|
# Post-test teardown
|
|
|
|
|
- name: delete a ssl certificate
|
|
|
|
|
gcp_compute_ssl_certificate:
|
|
|
|
|
name: 'sslcert-targethttpsproxy'
|
|
|
|
|
description: |
|
|
|
|
|
"A certificate for testing. Do not use this certificate in production"
|
|
|
|
|
name: "sslcert-targethttpsproxy"
|
|
|
|
|
description: A certificate for testing. Do not use this certificate in production
|
|
|
|
|
certificate: |
|
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
|
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
|
|
|
@ -240,39 +228,33 @@
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
scopes:
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
state: absent
|
|
|
|
|
register: sslcert
|
|
|
|
|
- name: delete a url map
|
|
|
|
|
gcp_compute_url_map:
|
|
|
|
|
name: 'urlmap-targethttpsproxy'
|
|
|
|
|
name: "urlmap-targethttpsproxy"
|
|
|
|
|
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-targethttpsproxy'
|
|
|
|
|
name: "backendservice-targethttpsproxy"
|
|
|
|
|
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-targethttpsproxy'
|
|
|
|
|
name: "httphealthcheck-targethttpsproxy"
|
|
|
|
|
healthy_threshold: 10
|
|
|
|
|
port: 8080
|
|
|
|
|
timeout_sec: 2
|
|
|
|
@ -280,18 +262,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-targethttpsproxy'
|
|
|
|
|
zone: 'us-central1-a'
|
|
|
|
|
name: "instancegroup-targethttpsproxy"
|
|
|
|
|
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
|
|
|
|
|