Ansible - Regional SSL Certs + Health Check (#3210) (#174)

* done

* first try!

* copyright

* changing examples

* removing google provider

* test fixes

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
The Magician 2020-03-17 15:56:54 -07:00 committed by GitHub
commit 0be2684fe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1966 additions and 0 deletions

View file

@ -0,0 +1,2 @@
cloud/gcp
unsupported

View file

@ -0,0 +1,2 @@
---
resource_name: "{{ resource_prefix }}"

View file

@ -0,0 +1,149 @@
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file at
# https://www.github.com/GoogleCloudPlatform/magic-modules
#
# ----------------------------------------------------------------------------
# Pre-test setup
- name: delete a region health check
google.cloud.gcp_compute_region_health_check:
name: "{{ resource_name }}"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
#----------------------------------------------------------
- name: create a region health check
google.cloud.gcp_compute_region_health_check:
name: "{{ resource_name }}"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: result
- name: assert changed is true
assert:
that:
- result.changed == true
- name: verify that region_health_check was created
google.cloud.gcp_compute_region_health_check_info:
filters:
- name = {{ resource_name }}
region: us-central1
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['resources'] | length == 1
# ----------------------------------------------------------------------------
- name: create a region health check that already exists
google.cloud.gcp_compute_region_health_check:
name: "{{ resource_name }}"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: result
- name: assert changed is false
assert:
that:
- result.changed == false
#----------------------------------------------------------
- name: delete a region health check
google.cloud.gcp_compute_region_health_check:
name: "{{ resource_name }}"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: result
- name: assert changed is true
assert:
that:
- result.changed == true
- name: verify that region_health_check was deleted
google.cloud.gcp_compute_region_health_check_info:
filters:
- name = {{ resource_name }}
region: us-central1
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['resources'] | length == 0
# ----------------------------------------------------------------------------
- name: delete a region health check that does not exist
google.cloud.gcp_compute_region_health_check:
name: "{{ resource_name }}"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: result
- name: assert changed is false
assert:
that:
- result.changed == false

View file

@ -0,0 +1,2 @@
---
- include_tasks: autogen.yml

View file

@ -16,6 +16,7 @@
- name: delete a SSL certificate
google.cloud.gcp_compute_ssl_certificate:
name: "{{ resource_name }}"
region: us-central1
description: A certificate for testing. Do not use this certificate in production
certificate: |-
-----BEGIN CERTIFICATE-----
@ -49,6 +50,7 @@
- name: create a SSL certificate
google.cloud.gcp_compute_ssl_certificate:
name: "{{ resource_name }}"
region: us-central1
description: A certificate for testing. Do not use this certificate in production
certificate: |-
-----BEGIN CERTIFICATE-----
@ -101,6 +103,7 @@
- name: create a SSL certificate that already exists
google.cloud.gcp_compute_ssl_certificate:
name: "{{ resource_name }}"
region: us-central1
description: A certificate for testing. Do not use this certificate in production
certificate: |-
-----BEGIN CERTIFICATE-----
@ -139,6 +142,7 @@
- name: delete a SSL certificate
google.cloud.gcp_compute_ssl_certificate:
name: "{{ resource_name }}"
region: us-central1
description: A certificate for testing. Do not use this certificate in production
certificate: |-
-----BEGIN CERTIFICATE-----
@ -191,6 +195,7 @@
- name: delete a SSL certificate that does not exist
google.cloud.gcp_compute_ssl_certificate:
name: "{{ resource_name }}"
region: us-central1
description: A certificate for testing. Do not use this certificate in production
certificate: |-
-----BEGIN CERTIFICATE-----