From 8b2a915a09f679c18931fdb53c95c53e59bd2846 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 15 Apr 2019 13:27:50 -0700 Subject: [PATCH] Ansible - non-updatable resources should be deleted/created (#231) /cc @rambleraptor --- plugins/modules/gcp_compute_address.py | 3 ++- plugins/modules/gcp_compute_global_address.py | 3 ++- plugins/modules/gcp_compute_instance_template.py | 3 ++- plugins/modules/gcp_compute_interconnect_attachment.py | 3 ++- plugins/modules/gcp_compute_route.py | 3 ++- plugins/modules/gcp_compute_ssl_certificate.py | 3 ++- plugins/modules/gcp_compute_target_vpn_gateway.py | 3 ++- plugins/modules/gcp_compute_vpn_tunnel.py | 3 ++- plugins/modules/gcp_pubsub_topic.py | 3 ++- plugins/modules/gcp_sourcerepo_repository.py | 3 ++- plugins/modules/gcp_spanner_database.py | 3 ++- 11 files changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/modules/gcp_compute_address.py b/plugins/modules/gcp_compute_address.py index df536ed..9a05e01 100644 --- a/plugins/modules/gcp_compute_address.py +++ b/plugins/modules/gcp_compute_address.py @@ -262,7 +262,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="Address cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_compute_global_address.py b/plugins/modules/gcp_compute_global_address.py index 00bc1af..fff05fb 100644 --- a/plugins/modules/gcp_compute_global_address.py +++ b/plugins/modules/gcp_compute_global_address.py @@ -217,7 +217,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="GlobalAddress cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_compute_instance_template.py b/plugins/modules/gcp_compute_instance_template.py index 566efea..71b7ab3 100644 --- a/plugins/modules/gcp_compute_instance_template.py +++ b/plugins/modules/gcp_compute_instance_template.py @@ -953,7 +953,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="InstanceTemplate cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_compute_interconnect_attachment.py b/plugins/modules/gcp_compute_interconnect_attachment.py index 92b951e..b977a7a 100644 --- a/plugins/modules/gcp_compute_interconnect_attachment.py +++ b/plugins/modules/gcp_compute_interconnect_attachment.py @@ -328,7 +328,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="InterconnectAttachment cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_compute_route.py b/plugins/modules/gcp_compute_route.py index 8f62a2f..cd80b35 100644 --- a/plugins/modules/gcp_compute_route.py +++ b/plugins/modules/gcp_compute_route.py @@ -312,7 +312,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="Route cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_compute_ssl_certificate.py b/plugins/modules/gcp_compute_ssl_certificate.py index 8a4e6ae..3bb5f0a 100644 --- a/plugins/modules/gcp_compute_ssl_certificate.py +++ b/plugins/modules/gcp_compute_ssl_certificate.py @@ -204,7 +204,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="SslCertificate cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_compute_target_vpn_gateway.py b/plugins/modules/gcp_compute_target_vpn_gateway.py index 3e26ef4..9b7a980 100644 --- a/plugins/modules/gcp_compute_target_vpn_gateway.py +++ b/plugins/modules/gcp_compute_target_vpn_gateway.py @@ -222,7 +222,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="TargetVpnGateway cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_compute_vpn_tunnel.py b/plugins/modules/gcp_compute_vpn_tunnel.py index ec7be3d..1302aff 100644 --- a/plugins/modules/gcp_compute_vpn_tunnel.py +++ b/plugins/modules/gcp_compute_vpn_tunnel.py @@ -314,7 +314,8 @@ def create(module, link, kind): def update(module, link, kind): - module.fail_json(msg="VpnTunnel cannot be edited") + delete(module, self_link(module), kind) + create(module, collection(module), kind) def delete(module, link, kind): diff --git a/plugins/modules/gcp_pubsub_topic.py b/plugins/modules/gcp_pubsub_topic.py index 5982ed0..728fc60 100644 --- a/plugins/modules/gcp_pubsub_topic.py +++ b/plugins/modules/gcp_pubsub_topic.py @@ -142,7 +142,8 @@ def create(module, link): def update(module, link): - module.fail_json(msg="Topic cannot be edited") + delete(module, self_link(module)) + create(module, self_link(module)) def delete(module, link): diff --git a/plugins/modules/gcp_sourcerepo_repository.py b/plugins/modules/gcp_sourcerepo_repository.py index d1e1a06..8bfa22e 100644 --- a/plugins/modules/gcp_sourcerepo_repository.py +++ b/plugins/modules/gcp_sourcerepo_repository.py @@ -142,7 +142,8 @@ def create(module, link): def update(module, link): - module.fail_json(msg="Repository cannot be edited") + delete(module, self_link(module)) + create(module, collection(module)) def delete(module, link): diff --git a/plugins/modules/gcp_spanner_database.py b/plugins/modules/gcp_spanner_database.py index 19306cd..fe585a0 100644 --- a/plugins/modules/gcp_spanner_database.py +++ b/plugins/modules/gcp_spanner_database.py @@ -181,7 +181,8 @@ def create(module, link): def update(module, link): - module.fail_json(msg="Database cannot be edited") + delete(module, self_link(module)) + create(module, collection(module)) def delete(module, link):