Bug fixes for GCP modules (#61251)

This commit is contained in:
The Magician 2019-08-26 12:04:24 -07:00 committed by ansibot
parent 8ee7d9f598
commit 1631554c1b
5 changed files with 20 additions and 21 deletions

View file

@ -99,7 +99,7 @@ EXAMPLES = '''
gcp_sql_database: gcp_sql_database:
name: test_object name: test_object
charset: utf8 charset: utf8
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: get info on a database - name: get info on a database
gcp_sql_database_info: gcp_sql_database_info:
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"

View file

@ -120,7 +120,7 @@ EXAMPLES = '''
- name: create a bucket access control - name: create a bucket access control
gcp_storage_bucket_access_control: gcp_storage_bucket_access_control:
bucket: test_object bucket: "{{ bucket }}"
entity: user-alexstephen@google.com entity: user-alexstephen@google.com
role: WRITER role: WRITER
project: test_project project: test_project
@ -220,10 +220,7 @@ def main():
state = module.params['state'] state = module.params['state']
kind = 'storage#bucketAccessControl' kind = 'storage#bucketAccessControl'
if module.params['id']:
fetch = fetch_resource(module, self_link(module), kind) fetch = fetch_resource(module, self_link(module), kind)
else:
fetch = {}
changed = False changed = False
if fetch: if fetch:
@ -286,11 +283,13 @@ def fetch_resource(module, link, kind, allow_not_found=True):
def self_link(module): 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): 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): def return_if_object(module, response, kind, allow_not_found=False):

View file

@ -32,7 +32,7 @@
gcp_sql_database: gcp_sql_database:
name: "{{ resource_name }}" name: "{{ resource_name }}"
charset: utf8 charset: utf8
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -42,7 +42,7 @@
gcp_sql_database: gcp_sql_database:
name: "{{ resource_name }}" name: "{{ resource_name }}"
charset: utf8 charset: utf8
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -54,7 +54,7 @@
- result.changed == true - result.changed == true
- name: verify that database was created - name: verify that database was created
gcp_sql_database_info: gcp_sql_database_info:
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -70,7 +70,7 @@
gcp_sql_database: gcp_sql_database:
name: "{{ resource_name }}" name: "{{ resource_name }}"
charset: utf8 charset: utf8
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -85,7 +85,7 @@
gcp_sql_database: gcp_sql_database:
name: "{{ resource_name }}" name: "{{ resource_name }}"
charset: utf8 charset: utf8
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -97,7 +97,7 @@
- result.changed == true - result.changed == true
- name: verify that database was deleted - name: verify that database was deleted
gcp_sql_database_info: gcp_sql_database_info:
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -113,7 +113,7 @@
gcp_sql_database: gcp_sql_database:
name: "{{ resource_name }}" name: "{{ resource_name }}"
charset: utf8 charset: utf8
instance: "{{ instance }}" instance: "{{ instance.name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"

View file

@ -23,7 +23,7 @@
register: bucket register: bucket
- name: delete a bucket access control - name: delete a bucket access control
gcp_storage_bucket_access_control: gcp_storage_bucket_access_control:
bucket: "{{ resource_name }}" bucket: "{{ bucket }}"
entity: user-alexstephen@google.com entity: user-alexstephen@google.com
role: WRITER role: WRITER
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
@ -33,7 +33,7 @@
#---------------------------------------------------------- #----------------------------------------------------------
- name: create a bucket access control - name: create a bucket access control
gcp_storage_bucket_access_control: gcp_storage_bucket_access_control:
bucket: "{{ resource_name }}" bucket: "{{ bucket }}"
entity: user-alexstephen@google.com entity: user-alexstephen@google.com
role: WRITER role: WRITER
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
@ -48,7 +48,7 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a bucket access control that already exists - name: create a bucket access control that already exists
gcp_storage_bucket_access_control: gcp_storage_bucket_access_control:
bucket: "{{ resource_name }}" bucket: "{{ bucket }}"
entity: user-alexstephen@google.com entity: user-alexstephen@google.com
role: WRITER role: WRITER
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
@ -63,7 +63,7 @@
#---------------------------------------------------------- #----------------------------------------------------------
- name: delete a bucket access control - name: delete a bucket access control
gcp_storage_bucket_access_control: gcp_storage_bucket_access_control:
bucket: "{{ resource_name }}" bucket: "{{ bucket }}"
entity: user-alexstephen@google.com entity: user-alexstephen@google.com
role: WRITER role: WRITER
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
@ -78,7 +78,7 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: delete a bucket access control that does not exist - name: delete a bucket access control that does not exist
gcp_storage_bucket_access_control: gcp_storage_bucket_access_control:
bucket: "{{ resource_name }}" bucket: "{{ bucket }}"
entity: user-alexstephen@google.com entity: user-alexstephen@google.com
role: WRITER role: WRITER
project: "{{ gcp_project }}" project: "{{ gcp_project }}"