You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GCP doesn't allow to create any subnet with the same name in the same region if already exists in any other VPC network, and the original module doesn't throw error. This PR suggests adding a condition check and error out for this scenario.
#A1: create a network vpc-a
#A2: create a subnetwork subnet-a in vpc-a
#B1: create another network vpc-b
#B2: create a same-name subnetwork subnet-a in vpc-b
---
- name: Define variablesset_fact:
project: your-project-nameregion: us-east4gcp_auth_kind: application
- name: "#A1: create a network vpc-a"google.cloud.gcp_compute_network:
name: "vpc-a"auto_create_subnetworks: 'false'project: "{{ project }}"auth_kind: "{{ gcp_auth_kind }}"state: presentregister: network_a
- name: "#A2: create a subnetwork subnet-a in vpc-a"google.cloud.gcp_compute_subnetwork:
name: "subnet-a"region: "{{ region }}"network: "{{ network_a }}"ip_cidr_range: 172.16.0.0/20project: "{{ project }}"auth_kind: "{{ gcp_auth_kind }}"state: present
- name: "#B1: create another network vpc-b"google.cloud.gcp_compute_network:
name: "vpc-b"auto_create_subnetworks: 'false'project: "{{ project }}"auth_kind: "{{ gcp_auth_kind }}"state: presentregister: network_b
- name: "#B2: create a same name subnetwork subnet-a in vpc-b"google.cloud.gcp_compute_subnetwork:
name: "subnet-a"region: "{{ region }}"network: "{{ network_b }}"ip_cidr_range: 172.16.0.0/20project: "{{ project }}"auth_kind: "{{ gcp_auth_kind }}"state: present
EXPECTED RESULTS
Task #B2 should throw an error saying the same name subnet already exists in another VPC network (vpc-a).
ACTUAL RESULTS
The original module finds the subnet and shows it on a different VPC network (vpc-a), and continues to call the Update() function and actually does nothing. No any error and no any subnet created at vpc-b.
SUMMARY
GCP doesn't allow to create any subnet with the same name in the same region if already exists in any other VPC network, and the original module doesn't throw error. This PR suggests adding a condition check and error out for this scenario.
ISSUE TYPE
COMPONENT NAME
plugins/modules/gcp_compute_subnetwork.py
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
MacOS 13.0 (22A380)
STEPS TO REPRODUCE
#A1: create a network vpc-a
#A2: create a subnetwork subnet-a in vpc-a
#B1: create another network vpc-b
#B2: create a same-name subnetwork subnet-a in vpc-b
EXPECTED RESULTS
Task #B2 should throw an error saying the same name subnet already exists in another VPC network (vpc-a).
ACTUAL RESULTS
The original module finds the subnet and shows it on a different VPC network (vpc-a), and continues to call the Update() function and actually does nothing. No any error and no any subnet created at vpc-b.
The text was updated successfully, but these errors were encountered: