From 0234937ca378b65618e2576e8b97c1ee02dc7d6b Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 5 Aug 2019 15:25:49 -0700 Subject: [PATCH] Bug fixes for GCP modules (#60092) --- .../modules/cloud/google/gcp_pubsub_subscription_facts.py | 1 - lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py | 1 - lib/ansible/modules/cloud/google/gcp_redis_instance_facts.py | 1 - .../modules/cloud/google/gcp_resourcemanager_project_facts.py | 1 - .../modules/cloud/google/gcp_sourcerepo_repository_facts.py | 1 - lib/ansible/modules/cloud/google/gcp_spanner_database.py | 3 +-- lib/ansible/modules/cloud/google/gcp_spanner_database_facts.py | 1 - lib/ansible/modules/cloud/google/gcp_spanner_instance.py | 3 +-- lib/ansible/modules/cloud/google/gcp_spanner_instance_facts.py | 1 - lib/ansible/modules/cloud/google/gcp_sql_database.py | 3 +-- lib/ansible/modules/cloud/google/gcp_sql_database_facts.py | 1 - lib/ansible/modules/cloud/google/gcp_sql_instance.py | 3 +-- lib/ansible/modules/cloud/google/gcp_sql_instance_facts.py | 1 - lib/ansible/modules/cloud/google/gcp_sql_user.py | 2 +- lib/ansible/modules/cloud/google/gcp_sql_user_facts.py | 1 - test/integration/targets/gcp_sql_database/tasks/main.yml | 2 -- test/integration/targets/gcp_sql_instance/tasks/main.yml | 2 -- test/integration/targets/gcp_sql_user/tasks/main.yml | 2 -- test/integration/targets/gcp_storage_bucket/tasks/main.yml | 2 -- .../targets/gcp_storage_bucket_access_control/tasks/main.yml | 2 -- 20 files changed, 5 insertions(+), 29 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py index 062a91e9cc5..478bf57c46b 100644 --- a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py @@ -49,7 +49,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py b/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py index 7b794fc8ec8..527da46be4a 100644 --- a/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py @@ -49,7 +49,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_redis_instance_facts.py b/lib/ansible/modules/cloud/google/gcp_redis_instance_facts.py index 4c8ea10e329..555bd93afe5 100644 --- a/lib/ansible/modules/cloud/google/gcp_redis_instance_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_redis_instance_facts.py @@ -55,7 +55,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_resourcemanager_project_facts.py b/lib/ansible/modules/cloud/google/gcp_resourcemanager_project_facts.py index 512ccbf3e44..7d66ff91655 100644 --- a/lib/ansible/modules/cloud/google/gcp_resourcemanager_project_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_resourcemanager_project_facts.py @@ -49,7 +49,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_facts.py b/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_facts.py index 1104fc9dbd9..328a39a70d9 100644 --- a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_facts.py @@ -49,7 +49,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_database.py b/lib/ansible/modules/cloud/google/gcp_spanner_database.py index 1ce4fb3dd51..0b54f498745 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_database.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_database.py @@ -186,8 +186,7 @@ def create(module, link): def update(module, link): - delete(module, self_link(module)) - create(module, collection(module)) + module.fail_json(msg="Spanner objects can't be updated to ensure data safety") def delete(module, link): diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_database_facts.py b/lib/ansible/modules/cloud/google/gcp_spanner_database_facts.py index 90130dd5f82..b0027a221d7 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_database_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_database_facts.py @@ -60,7 +60,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py b/lib/ansible/modules/cloud/google/gcp_spanner_instance.py index 9cfd81b5cd3..764214fff1e 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_instance.py @@ -202,8 +202,7 @@ def create(module, link): def update(module, link): - auth = GcpSession(module, 'spanner') - return wait_for_operation(module, auth.patch(link, resource_to_update(module))) + module.fail_json(msg="Spanner objects can't be updated to ensure data safety") def delete(module, link): diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_instance_facts.py b/lib/ansible/modules/cloud/google/gcp_spanner_instance_facts.py index 6b1ecf487a6..8891c4e68d7 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_instance_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_instance_facts.py @@ -49,7 +49,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_sql_database.py b/lib/ansible/modules/cloud/google/gcp_sql_database.py index 398d28c1110..f1d55122a14 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_database.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_database.py @@ -187,8 +187,7 @@ def create(module, link, kind): def update(module, link, kind): - auth = GcpSession(module, 'sql') - return wait_for_operation(module, auth.put(link, resource_to_request(module))) + module.fail_json(msg="SQL objects can't be updated to ensure data safety") def delete(module, link, kind): diff --git a/lib/ansible/modules/cloud/google/gcp_sql_database_facts.py b/lib/ansible/modules/cloud/google/gcp_sql_database_facts.py index 017f5d3161d..bea7019fcc4 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_database_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_database_facts.py @@ -55,7 +55,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_sql_instance.py b/lib/ansible/modules/cloud/google/gcp_sql_instance.py index c8ba028a613..49a08284767 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_instance.py @@ -763,8 +763,7 @@ def create(module, link, kind): def update(module, link, kind, fetch): - auth = GcpSession(module, 'sql') - return wait_for_operation(module, auth.put(link, resource_to_request(module))) + module.fail_json(msg="SQL objects can't be updated to ensure data safety") def delete(module, link, kind, fetch): diff --git a/lib/ansible/modules/cloud/google/gcp_sql_instance_facts.py b/lib/ansible/modules/cloud/google/gcp_sql_instance_facts.py index 1587eafec33..c7a0f71f5b2 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_instance_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_instance_facts.py @@ -49,7 +49,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_sql_user.py b/lib/ansible/modules/cloud/google/gcp_sql_user.py index 64dca81f6fc..50d4a5386aa 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_user.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_user.py @@ -215,7 +215,7 @@ def resource_to_request(module): def unwrap_resource_filter(module): - return {'host': module.params['host'], 'name': module.params['name']} + return {'name': module.params['name'], 'host': module.params['host']} def unwrap_resource(result, module): diff --git a/lib/ansible/modules/cloud/google/gcp_sql_user_facts.py b/lib/ansible/modules/cloud/google/gcp_sql_user_facts.py index 989652cbce7..2ea0ff9c64c 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_user_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_user_facts.py @@ -60,7 +60,6 @@ EXAMPLES = ''' project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" - state: facts ''' RETURN = ''' diff --git a/test/integration/targets/gcp_sql_database/tasks/main.yml b/test/integration/targets/gcp_sql_database/tasks/main.yml index 9b300adc689..827900e390f 100644 --- a/test/integration/targets/gcp_sql_database/tasks/main.yml +++ b/test/integration/targets/gcp_sql_database/tasks/main.yml @@ -52,7 +52,6 @@ assert: that: - result.changed == true - - "result.kind == 'sql#database'" - name: verify that database was created gcp_sql_database_facts: instance: "{{ instance }}" @@ -81,7 +80,6 @@ assert: that: - result.changed == false - - "result.kind == 'sql#database'" #---------------------------------------------------------- - name: delete a database gcp_sql_database: diff --git a/test/integration/targets/gcp_sql_instance/tasks/main.yml b/test/integration/targets/gcp_sql_instance/tasks/main.yml index 96aa398a45f..ada068d21a4 100644 --- a/test/integration/targets/gcp_sql_instance/tasks/main.yml +++ b/test/integration/targets/gcp_sql_instance/tasks/main.yml @@ -47,7 +47,6 @@ assert: that: - result.changed == true - - "result.kind == 'sql#instance'" - name: verify that instance was created gcp_sql_instance_facts: project: "{{ gcp_project }}" @@ -80,7 +79,6 @@ assert: that: - result.changed == false - - "result.kind == 'sql#instance'" #---------------------------------------------------------- - name: delete a instance gcp_sql_instance: diff --git a/test/integration/targets/gcp_sql_user/tasks/main.yml b/test/integration/targets/gcp_sql_user/tasks/main.yml index 78e10059910..e7c5b2b0ace 100644 --- a/test/integration/targets/gcp_sql_user/tasks/main.yml +++ b/test/integration/targets/gcp_sql_user/tasks/main.yml @@ -54,7 +54,6 @@ assert: that: - result.changed == true - - "result.kind == 'sql#user'" - name: verify that user was created gcp_sql_user_facts: instance: "{{ instance }}" @@ -84,7 +83,6 @@ assert: that: - result.changed == false - - "result.kind == 'sql#user'" #---------------------------------------------------------- - name: delete a user gcp_sql_user: diff --git a/test/integration/targets/gcp_storage_bucket/tasks/main.yml b/test/integration/targets/gcp_storage_bucket/tasks/main.yml index dcf45d5569b..d49ec899c1d 100644 --- a/test/integration/targets/gcp_storage_bucket/tasks/main.yml +++ b/test/integration/targets/gcp_storage_bucket/tasks/main.yml @@ -33,7 +33,6 @@ assert: that: - result.changed == true - - "result.kind == 'storage#bucket'" # ---------------------------------------------------------------------------- - name: create a bucket that already exists gcp_storage_bucket: @@ -47,7 +46,6 @@ assert: that: - result.changed == false - - "result.kind == 'storage#bucket'" #---------------------------------------------------------- - name: delete a bucket gcp_storage_bucket: diff --git a/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml b/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml index c37b4397c72..301505a1fe8 100644 --- a/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml +++ b/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml @@ -45,7 +45,6 @@ assert: that: - result.changed == true - - "result.kind == 'storage#bucketAccessControl'" # ---------------------------------------------------------------------------- - name: create a bucket access control that already exists gcp_storage_bucket_access_control: @@ -61,7 +60,6 @@ assert: that: - result.changed == false - - "result.kind == 'storage#bucketAccessControl'" #---------------------------------------------------------- - name: delete a bucket access control gcp_storage_bucket_access_control: