diff --git a/lib/ansible/modules/cloud/google/gcp_sql_database.py b/lib/ansible/modules/cloud/google/gcp_sql_database.py index 459c4a90032..47eb46d7392 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_database.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_database.py @@ -99,7 +99,7 @@ EXAMPLES = ''' gcp_sql_database: name: test_object charset: utf8 - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" diff --git a/lib/ansible/modules/cloud/google/gcp_sql_database_info.py b/lib/ansible/modules/cloud/google/gcp_sql_database_info.py index 03625eaed1c..f767be824f2 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_database_info.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_database_info.py @@ -53,7 +53,7 @@ extends_documentation_fragment: gcp EXAMPLES = ''' - name: get info on a database gcp_sql_database_info: - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: test_project auth_kind: serviceaccount service_account_file: "/tmp/auth.pem" diff --git a/lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py b/lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py index 6d58a496bcb..37cbc13613d 100644 --- a/lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py +++ b/lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py @@ -120,7 +120,7 @@ EXAMPLES = ''' - name: create a bucket access control gcp_storage_bucket_access_control: - bucket: test_object + bucket: "{{ bucket }}" entity: user-alexstephen@google.com role: WRITER project: test_project @@ -220,10 +220,7 @@ def main(): state = module.params['state'] kind = 'storage#bucketAccessControl' - if module.params['id']: - fetch = fetch_resource(module, self_link(module), kind) - else: - fetch = {} + fetch = fetch_resource(module, self_link(module), kind) changed = False if fetch: @@ -286,11 +283,13 @@ def fetch_resource(module, link, kind, allow_not_found=True): def self_link(module): - return "https://www.googleapis.com/storage/v1/b/{bucket}/acl/{entity}".format(**module.params) + res = {'bucket': replace_resource_dict(module.params['bucket'], 'name'), 'entity': module.params['entity']} + return "https://www.googleapis.com/storage/v1/b/{bucket}/acl/{entity}".format(**res) def collection(module): - return "https://www.googleapis.com/storage/v1/b/{bucket}/acl".format(**module.params) + res = {'bucket': replace_resource_dict(module.params['bucket'], 'name')} + return "https://www.googleapis.com/storage/v1/b/{bucket}/acl".format(**res) def return_if_object(module, response, kind, allow_not_found=False): diff --git a/test/integration/targets/gcp_sql_database/tasks/main.yml b/test/integration/targets/gcp_sql_database/tasks/main.yml index 0c22c3f6403..ebe9cbdc06d 100644 --- a/test/integration/targets/gcp_sql_database/tasks/main.yml +++ b/test/integration/targets/gcp_sql_database/tasks/main.yml @@ -32,7 +32,7 @@ gcp_sql_database: name: "{{ resource_name }}" charset: utf8 - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -42,7 +42,7 @@ gcp_sql_database: name: "{{ resource_name }}" charset: utf8 - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -54,7 +54,7 @@ - result.changed == true - name: verify that database was created gcp_sql_database_info: - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -70,7 +70,7 @@ gcp_sql_database: name: "{{ resource_name }}" charset: utf8 - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -85,7 +85,7 @@ gcp_sql_database: name: "{{ resource_name }}" charset: utf8 - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -97,7 +97,7 @@ - result.changed == true - name: verify that database was deleted gcp_sql_database_info: - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" @@ -113,7 +113,7 @@ gcp_sql_database: name: "{{ resource_name }}" charset: utf8 - instance: "{{ instance }}" + instance: "{{ instance.name }}" project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" 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 301505a1fe8..5a78a87e7a0 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 @@ -23,7 +23,7 @@ register: bucket - name: delete a bucket access control gcp_storage_bucket_access_control: - bucket: "{{ resource_name }}" + bucket: "{{ bucket }}" entity: user-alexstephen@google.com role: WRITER project: "{{ gcp_project }}" @@ -33,7 +33,7 @@ #---------------------------------------------------------- - name: create a bucket access control gcp_storage_bucket_access_control: - bucket: "{{ resource_name }}" + bucket: "{{ bucket }}" entity: user-alexstephen@google.com role: WRITER project: "{{ gcp_project }}" @@ -48,7 +48,7 @@ # ---------------------------------------------------------------------------- - name: create a bucket access control that already exists gcp_storage_bucket_access_control: - bucket: "{{ resource_name }}" + bucket: "{{ bucket }}" entity: user-alexstephen@google.com role: WRITER project: "{{ gcp_project }}" @@ -63,7 +63,7 @@ #---------------------------------------------------------- - name: delete a bucket access control gcp_storage_bucket_access_control: - bucket: "{{ resource_name }}" + bucket: "{{ bucket }}" entity: user-alexstephen@google.com role: WRITER project: "{{ gcp_project }}" @@ -78,7 +78,7 @@ # ---------------------------------------------------------------------------- - name: delete a bucket access control that does not exist gcp_storage_bucket_access_control: - bucket: "{{ resource_name }}" + bucket: "{{ bucket }}" entity: user-alexstephen@google.com role: WRITER project: "{{ gcp_project }}"