Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added missing zone parameter in gcp_compute_instance_template #516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/modules/gcp_compute_instance_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
- Reference to a disk type.
- Specifies the disk type to use to create the instance.
- If not specified, the default is pd-standard.
- To use this parameter specify zone parameter as well.
required: false
type: str
source_image:
Expand Down Expand Up @@ -472,6 +473,11 @@
elements: str
required: false
type: list
zone:
description:
- A reference to the zone where the disk type resides
required: false
type: str
simonkey007 marked this conversation as resolved.
Show resolved Hide resolved
project:
description:
- The Google Cloud Platform project to use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,92 @@
assert:
that:
- results['resources'] | length == 0
#----------------------------------------------------------
- name: create a instance template with ssd disk type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
google.cloud.gcp_compute_instance_template:
Expand Down