Ansible Region Backend Services

Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
Alex Stephen 2019-10-03 23:52:53 +00:00 committed by Modular Magician
commit 5976ff606d
9 changed files with 1050 additions and 0 deletions

View file

@ -0,0 +1,164 @@
---
# ----------------------------------------------------------------------------
#
# *** 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: create a health check
google.cloud.gcp_compute_health_check:
name: "{{ resource_name }}"
type: TCP
tcp_health_check:
port: 80
check_interval_sec: 1
timeout_sec: 1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: healthcheck
- name: delete a region backend service
google.cloud.gcp_compute_region_backend_service:
name: "{{ resource_name }}"
region: us-central1
health_checks:
- "{{ healthcheck.selfLink }}"
connection_draining:
draining_timeout_sec: 10
session_affinity: CLIENT_IP
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
#----------------------------------------------------------
- name: create a region backend service
google.cloud.gcp_compute_region_backend_service:
name: "{{ resource_name }}"
region: us-central1
health_checks:
- "{{ healthcheck.selfLink }}"
connection_draining:
draining_timeout_sec: 10
session_affinity: CLIENT_IP
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_backend_service was created
google.cloud.gcp_compute_region_backend_service_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 backend service that already exists
google.cloud.gcp_compute_region_backend_service:
name: "{{ resource_name }}"
region: us-central1
health_checks:
- "{{ healthcheck.selfLink }}"
connection_draining:
draining_timeout_sec: 10
session_affinity: CLIENT_IP
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 backend service
google.cloud.gcp_compute_region_backend_service:
name: "{{ resource_name }}"
region: us-central1
health_checks:
- "{{ healthcheck.selfLink }}"
connection_draining:
draining_timeout_sec: 10
session_affinity: CLIENT_IP
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_backend_service was deleted
google.cloud.gcp_compute_region_backend_service_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 backend service that does not exist
google.cloud.gcp_compute_region_backend_service:
name: "{{ resource_name }}"
region: us-central1
health_checks:
- "{{ healthcheck.selfLink }}"
connection_draining:
draining_timeout_sec: 10
session_affinity: CLIENT_IP
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
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!
- name: delete a health check
google.cloud.gcp_compute_health_check:
name: "{{ resource_name }}"
type: TCP
tcp_health_check:
port: 80
check_interval_sec: 1
timeout_sec: 1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: healthcheck
ignore_errors: true

View file

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