|
|
@ -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-targetsslproxy'
|
|
|
|
name: "instancegroup-targetsslproxy"
|
|
|
|
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 health check
|
|
|
|
- name: create a health check
|
|
|
|
gcp_compute_health_check:
|
|
|
|
gcp_compute_health_check:
|
|
|
|
name: 'healthcheck-targetsslproxy'
|
|
|
|
name: "healthcheck-targetsslproxy"
|
|
|
|
type: TCP
|
|
|
|
type: TCP
|
|
|
|
tcp_health_check:
|
|
|
|
tcp_health_check:
|
|
|
|
port_name: service-health
|
|
|
|
port_name: service-health
|
|
|
@ -38,30 +36,25 @@
|
|
|
|
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-targetsslproxy'
|
|
|
|
name: "backendservice-targetsslproxy"
|
|
|
|
backends:
|
|
|
|
backends:
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
health_checks:
|
|
|
|
health_checks:
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
protocol: 'SSL'
|
|
|
|
protocol: SSL
|
|
|
|
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 ssl certificate
|
|
|
|
- name: create a ssl certificate
|
|
|
|
gcp_compute_ssl_certificate:
|
|
|
|
gcp_compute_ssl_certificate:
|
|
|
|
name: 'sslcert-targetsslproxy'
|
|
|
|
name: "sslcert-targetsslproxy"
|
|
|
|
description: |
|
|
|
|
description: A certificate for testing. Do not use this certificate in production
|
|
|
|
"A certificate for testing. Do not use this certificate in production"
|
|
|
|
|
|
|
|
certificate: |
|
|
|
|
certificate: |
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
|
|
|
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
|
|
@ -89,34 +82,28 @@
|
|
|
|
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: sslcert
|
|
|
|
register: sslcert
|
|
|
|
- name: delete a target ssl proxy
|
|
|
|
- name: delete a target ssl proxy
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
ssl_certificates:
|
|
|
|
ssl_certificates:
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
service: "{{ backendservice }}"
|
|
|
|
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
|
|
|
|
#----------------------------------------------------------
|
|
|
|
#----------------------------------------------------------
|
|
|
|
- name: create a target ssl proxy
|
|
|
|
- name: create a target ssl proxy
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
ssl_certificates:
|
|
|
|
ssl_certificates:
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
service: "{{ backendservice }}"
|
|
|
|
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: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is true
|
|
|
|
- name: assert changed is true
|
|
|
@ -125,25 +112,29 @@
|
|
|
|
- result.changed == true
|
|
|
|
- result.changed == true
|
|
|
|
- "result.kind == 'compute#targetSslProxy'"
|
|
|
|
- "result.kind == 'compute#targetSslProxy'"
|
|
|
|
- name: verify that target_ssl_proxy was created
|
|
|
|
- name: verify that target_ssl_proxy was created
|
|
|
|
shell: |
|
|
|
|
gcp_compute_target_ssl_proxy_facts:
|
|
|
|
gcloud compute target-ssl-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 ssl proxy that already exists
|
|
|
|
- name: create a target ssl proxy that already exists
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
ssl_certificates:
|
|
|
|
ssl_certificates:
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
service: "{{ backendservice }}"
|
|
|
|
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: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is false
|
|
|
|
- name: assert changed is false
|
|
|
@ -156,13 +147,11 @@
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
ssl_certificates:
|
|
|
|
ssl_certificates:
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
service: "{{ backendservice }}"
|
|
|
|
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: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is true
|
|
|
|
- name: assert changed is true
|
|
|
@ -171,27 +160,29 @@
|
|
|
|
- result.changed == true
|
|
|
|
- result.changed == true
|
|
|
|
- result.has_key('kind') == False
|
|
|
|
- result.has_key('kind') == False
|
|
|
|
- name: verify that target_ssl_proxy was deleted
|
|
|
|
- name: verify that target_ssl_proxy was deleted
|
|
|
|
shell: |
|
|
|
|
gcp_compute_target_ssl_proxy_facts:
|
|
|
|
gcloud compute target-ssl-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/targetSslProxies/{{ resource_name }}' was not found\" in results.stderr"
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
- name: delete a target ssl proxy that does not exist
|
|
|
|
- name: delete a target ssl proxy that does not exist
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
gcp_compute_target_ssl_proxy:
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
name: "{{ resource_name }}"
|
|
|
|
ssl_certificates:
|
|
|
|
ssl_certificates:
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
- "{{ sslcert }}"
|
|
|
|
service: "{{ backendservice }}"
|
|
|
|
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: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is false
|
|
|
|
- name: assert changed is false
|
|
|
@ -203,9 +194,8 @@
|
|
|
|
# Post-test teardown
|
|
|
|
# Post-test teardown
|
|
|
|
- name: delete a ssl certificate
|
|
|
|
- name: delete a ssl certificate
|
|
|
|
gcp_compute_ssl_certificate:
|
|
|
|
gcp_compute_ssl_certificate:
|
|
|
|
name: 'sslcert-targetsslproxy'
|
|
|
|
name: "sslcert-targetsslproxy"
|
|
|
|
description: |
|
|
|
|
description: A certificate for testing. Do not use this certificate in production
|
|
|
|
"A certificate for testing. Do not use this certificate in production"
|
|
|
|
|
|
|
|
certificate: |
|
|
|
|
certificate: |
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
|
|
|
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
|
|
@ -233,28 +223,24 @@
|
|
|
|
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: sslcert
|
|
|
|
register: sslcert
|
|
|
|
- name: delete a backend service
|
|
|
|
- name: delete a backend service
|
|
|
|
gcp_compute_backend_service:
|
|
|
|
gcp_compute_backend_service:
|
|
|
|
name: 'backendservice-targetsslproxy'
|
|
|
|
name: "backendservice-targetsslproxy"
|
|
|
|
backends:
|
|
|
|
backends:
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
- group: "{{ instancegroup }}"
|
|
|
|
health_checks:
|
|
|
|
health_checks:
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
- "{{ healthcheck.selfLink }}"
|
|
|
|
protocol: 'SSL'
|
|
|
|
protocol: SSL
|
|
|
|
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 health check
|
|
|
|
- name: delete a health check
|
|
|
|
gcp_compute_health_check:
|
|
|
|
gcp_compute_health_check:
|
|
|
|
name: 'healthcheck-targetsslproxy'
|
|
|
|
name: "healthcheck-targetsslproxy"
|
|
|
|
type: TCP
|
|
|
|
type: TCP
|
|
|
|
tcp_health_check:
|
|
|
|
tcp_health_check:
|
|
|
|
port_name: service-health
|
|
|
|
port_name: service-health
|
|
|
@ -266,18 +252,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-targetsslproxy'
|
|
|
|
name: "instancegroup-targetsslproxy"
|
|
|
|
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
|
|
|
|