google.cloud/tests/integration/targets/gcp_compute_region_autoscaler/tasks/autogen.yml
The Magician 1adb69f09a
Ansible - All the Regional Resources (#3264) (#175)
* region url map

* region instance group manager

* target http/https proxy

* region autoscaler

* revert some files

* adding min_version on TF

* Update products/compute/examples/ansible/region_target_https_proxy.yaml

Co-Authored-By: Chris Hawk <41700375+SirGitsalot@users.noreply.github.com>

Co-authored-by: Chris Hawk <41700375+SirGitsalot@users.noreply.github.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Co-authored-by: Chris Hawk <41700375+SirGitsalot@users.noreply.github.com>
2020-03-18 14:55:15 -07:00

251 lines
7.9 KiB
YAML

---
# ----------------------------------------------------------------------------
#
# *** 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 network
google.cloud.gcp_compute_network:
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: network
- name: create a address
google.cloud.gcp_compute_address:
name: address-instancetemplate
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: address
- name: create a instance template
google.cloud.gcp_compute_instance_template:
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: test-config
type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancetemplate
- name: create a region instance group manager
google.cloud.gcp_compute_region_instance_group_manager:
name: "{{ resource_name }}"
base_instance_name: test1-child
region: us-central1
instance_template: "{{ instancetemplate }}"
target_size: 3
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: igrm
- name: delete a region autoscaler
google.cloud.gcp_compute_region_autoscaler:
name: my-region-autoscaler
region: us-central1
autoscaling_policy:
min_num_replicas: 1
max_num_replicas: 5
cool_down_period_sec: 60
cpu_utilization:
utilization_target: 0.5
target: "{{igrm.selfLink}}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
#----------------------------------------------------------
- name: create a region autoscaler
google.cloud.gcp_compute_region_autoscaler:
name: my-region-autoscaler
region: us-central1
autoscaling_policy:
min_num_replicas: 1
max_num_replicas: 5
cool_down_period_sec: 60
cpu_utilization:
utilization_target: 0.5
target: "{{igrm.selfLink}}"
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_autoscaler was created
google.cloud.gcp_compute_region_autoscaler_info:
filters:
- name = my-region-autoscaler
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 autoscaler that already exists
google.cloud.gcp_compute_region_autoscaler:
name: my-region-autoscaler
region: us-central1
autoscaling_policy:
min_num_replicas: 1
max_num_replicas: 5
cool_down_period_sec: 60
cpu_utilization:
utilization_target: 0.5
target: "{{igrm.selfLink}}"
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 autoscaler
google.cloud.gcp_compute_region_autoscaler:
name: my-region-autoscaler
region: us-central1
autoscaling_policy:
min_num_replicas: 1
max_num_replicas: 5
cool_down_period_sec: 60
cpu_utilization:
utilization_target: 0.5
target: "{{igrm.selfLink}}"
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_autoscaler was deleted
google.cloud.gcp_compute_region_autoscaler_info:
filters:
- name = my-region-autoscaler
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 autoscaler that does not exist
google.cloud.gcp_compute_region_autoscaler:
name: my-region-autoscaler
region: us-central1
autoscaling_policy:
min_num_replicas: 1
max_num_replicas: 5
cool_down_period_sec: 60
cpu_utilization:
utilization_target: 0.5
target: "{{igrm.selfLink}}"
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 region instance group manager
google.cloud.gcp_compute_region_instance_group_manager:
name: "{{ resource_name }}"
base_instance_name: test1-child
region: us-central1
instance_template: "{{ instancetemplate }}"
target_size: 3
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: igrm
ignore_errors: true
- name: delete a instance template
google.cloud.gcp_compute_instance_template:
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: test-config
type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: instancetemplate
ignore_errors: true
- name: delete a address
google.cloud.gcp_compute_address:
name: address-instancetemplate
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: address
ignore_errors: true
- name: delete a network
google.cloud.gcp_compute_network:
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: network
ignore_errors: true