From 82678b9bac5e4a97aae55419b991bdeabe7a4a46 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Wed, 15 Aug 2018 11:28:08 -0700 Subject: [PATCH] Bug fixes for gcp_pubsub_topic (#42834) --- .../modules/cloud/google/gcp_pubsub_topic.py | 13 ++++++------ .../targets/gcp_pubsub_topic/tasks/main.yml | 20 +++++-------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py b/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py index 73d04e329b..863c9f39f6 100644 --- a/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py +++ b/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py @@ -56,12 +56,10 @@ extends_documentation_fragment: gcp EXAMPLES = ''' - name: create a topic gcp_pubsub_topic: - name: 'test-topic1' - project: testProject - auth_kind: service_account - service_account_file: /tmp/auth.pem - scopes: - - https://www.googleapis.com/auth/pubsub + name: test-topic1 + project: "test_project" + auth_kind: "service_account" + service_account_file: "/tmp/auth.pem" state: present ''' @@ -95,6 +93,9 @@ def main(): ) ) + if not module.params['scopes']: + module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub'] + state = module.params['state'] fetch = fetch_resource(module, self_link(module)) diff --git a/test/integration/targets/gcp_pubsub_topic/tasks/main.yml b/test/integration/targets/gcp_pubsub_topic/tasks/main.yml index 95fd931d77..b0c2903a51 100644 --- a/test/integration/targets/gcp_pubsub_topic/tasks/main.yml +++ b/test/integration/targets/gcp_pubsub_topic/tasks/main.yml @@ -15,22 +15,18 @@ # Pre-test setup - name: delete a topic gcp_pubsub_topic: - name: 'test-topic1' + name: test-topic1 project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub state: absent #---------------------------------------------------------- - name: create a topic gcp_pubsub_topic: - name: 'test-topic1' + name: test-topic1 project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub state: present register: result - name: assert changed is true @@ -48,12 +44,10 @@ # ---------------------------------------------------------------------------- - name: create a topic that already exists gcp_pubsub_topic: - name: 'test-topic1' + name: test-topic1 project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub state: present register: result - name: assert changed is false @@ -63,12 +57,10 @@ #---------------------------------------------------------- - name: delete a topic gcp_pubsub_topic: - name: 'test-topic1' + name: test-topic1 project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub state: absent register: result - name: assert changed is true @@ -88,12 +80,10 @@ # ---------------------------------------------------------------------------- - name: delete a topic that does not exist gcp_pubsub_topic: - name: 'test-topic1' + name: test-topic1 project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub state: absent register: result - name: assert changed is false