fix: added missing zone parameter in gcp_compute_instance_template

This commit is contained in:
szymon.kodrebski 2022-11-19 00:02:58 +01:00
parent 0fc41bbda4
commit 0a15282e9c
No known key found for this signature in database
GPG key ID: 7FFB0B078032D645
2 changed files with 92 additions and 0 deletions

View file

@ -165,6 +165,7 @@ options:
- Reference to a disk type. - Reference to a disk type.
- Specifies the disk type to use to create the instance. - Specifies the disk type to use to create the instance.
- If not specified, the default is pd-standard. - If not specified, the default is pd-standard.
- To use this parameter specify zone parameter as well.
required: false required: false
type: str type: str
source_image: source_image:
@ -472,6 +473,11 @@ options:
elements: str elements: str
required: false required: false
type: list type: list
zone:
description:
- A reference to the zone where the disk type resides
required: false
type: str
project: project:
description: description:
- The Google Cloud Platform project to use. - The Google Cloud Platform project to use.

View file

@ -157,6 +157,92 @@
assert: assert:
that: that:
- results['resources'] | length == 0 - results['resources'] | length == 0
#----------------------------------------------------------
- name: create a instance template with ssd disk type
google.cloud.gcp_compute_instance_template:
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: 'true'
boot: 'true'
initialize_params:
disk_size_gb: 10
disk_type: "pd-ssd"
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-minimal-2204-lts
machine_type: n1-standard-1
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: test-config
type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}"
zone: us-central1-a
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 instance_template was created
google.cloud.gcp_compute_instance_template_info:
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['resources'] | length == 1
#----------------------------------------------------------
- name: delete a instance template
google.cloud.gcp_compute_instance_template:
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: 'true'
boot: 'true'
initialize_params:
disk_size_gb: 10
disk_type: "pd-ssd"
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-minimal-2204-lts
machine_type: n1-standard-1
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: test-config
type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}"
zone: us-central1-a
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 instance_template was deleted
google.cloud.gcp_compute_instance_template_info:
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['resources'] | length == 0
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: delete a instance template that does not exist - name: delete a instance template that does not exist
google.cloud.gcp_compute_instance_template: google.cloud.gcp_compute_instance_template: