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 shrink of the CIDR of a subnet but the original module doesn't throw an error if the requested new CIDR is not a superset of the original IP range. So I suggest adding a condition check and error out for this scenario.
Many years ago there was a similar issue reported but closed due to the old ansible module getting migrated to Galaxy Collection ansible/ansible#63348
When there are no changes ansible still shows that the configuration has been changed. Diff on the debug output from 3 consecutive run shows no differences.
#A1: create a network vpc-a
#A2: create a subnetwork {{ sbn_name }} in vpc-a
#A3: shrink the CIDR for {{ sbn_name }}
#A4: Collect fact about subnet {{ sbn_name }}
#A5: Show subnet info {{ sbn_name }}
Since GCP API doesn't allow such CIDR shrink, Step #A4 should through such error but actually not, instead, report the status as changed but didn't shrink the CIDR
ACTUAL RESULTS
Actually, the original doesn't validate the new CIDR is invalid, doesn't throw any error, instead, reports the status as changed but didn't shrink the CIDR.
changed: [localhost] => {
"changed": true,
"creationTimestamp": "2023-03-02T15:24:06.150-08:00",
"fingerprint": "Nz33qz_KLmw=",
"gatewayAddress": "172.16.0.1",
"id": "4466064884805439225",
"invocation": {
"module_args": {
"auth_kind": "application",
"description": null,
"env_type": null,
"ip_cidr_range": "172.16.0.0/21",
"name": "subnet-a",
"network": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/local/bin/python3.11"
},
"autoCreateSubnetworks": false,
"changed": false,
"creationTimestamp": "2023-03-02T15:23:11.142-08:00",
"failed": false,
"id": "2905869197935153456",
"kind": "compute#network",
"name": "vpc-a",
"networkFirewallPolicyEnforcementOrder": "AFTER_CLASSIC_FIREWALL",
"routingConfig": {
"routingMode": "REGIONAL"
},
"selfLink": "https://www.googleapis.com/compute/v1/projects/xx-demo/global/networks/vpc-a",
"selfLinkWithId": "https://www.googleapis.com/compute/v1/projects/xx-demo/global/networks/2905869197935153456",
"subnetworks": [
"https://www.googleapis.com/compute/v1/projects/xx-demo/regions/us-east4/subnetworks/subnet-a"
],
"warnings": [
"Platform darwin on host localhost is using the discovered Python interpreter at /usr/local/bin/python3.11, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.14/reference_appendices/interpreter_discovery.html for more information."
]
},
"private_ip_google_access": null,
"private_ipv6_google_access": null,
"project": "xx-demo",
"region": "us-east4",
"scopes": [
"https://www.googleapis.com/auth/compute"
],
"secondary_ip_ranges": null,
"service_account_contents": null,
"service_account_email": null,
"service_account_file": null,
"state": "present"
}
},
"ipCidrRange": "172.16.0.0/20",
"kind": "compute#subnetwork",
"name": "subnet-a",
"network": "https://www.googleapis.com/compute/v1/projects/xx-demo/global/networks/vpc-a",
"privateIpGoogleAccess": false,
"privateIpv6GoogleAccess": "DISABLE_GOOGLE_ACCESS",
"purpose": "PRIVATE",
"region": "https://www.googleapis.com/compute/v1/projects/xx-demo/regions/us-east4",
"selfLink": "https://www.googleapis.com/compute/v1/projects/xx-demo/regions/us-east4/subnetworks/subnet-a",
"stackType": "IPV4_ONLY"
}
The text was updated successfully, but these errors were encountered:
SUMMARY
GCP doesn't allow to shrink of the CIDR of a subnet but the original module doesn't throw an error if the requested new CIDR is not a superset of the original IP range. So I suggest adding a condition check and error out for this scenario.
Many years ago there was a similar issue reported but closed due to the old ansible module getting migrated to Galaxy Collection
ansible/ansible#63348
When there are no changes ansible still shows that the configuration has been changed. Diff on the debug output from 3 consecutive run shows no differences.
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 {{ sbn_name }} in vpc-a
#A3: shrink the CIDR for {{ sbn_name }}
#A4: Collect fact about subnet {{ sbn_name }}
#A5: Show subnet info {{ sbn_name }}
EXPECTED RESULTS
Since GCP API doesn't allow such CIDR shrink, Step #A4 should through such error but actually not, instead, report the status as changed but didn't shrink the CIDR
ACTUAL RESULTS
Actually, the original doesn't validate the new CIDR is invalid, doesn't throw any error, instead, reports the status as changed but didn't shrink the CIDR.
The text was updated successfully, but these errors were encountered: