Bug fixes for GCP modules (as of 2019-01-09T15:35:45-08:00) (#50786)

This commit is contained in:
Alex Stephen 2019-01-16 09:58:57 -08:00 committed by ansibot
parent a7e81ba500
commit 5137bd5958
18 changed files with 142 additions and 119 deletions

View file

@ -67,7 +67,7 @@ items:
description:
- A reference to a Topic resource.
returned: success
type: dict
type: str
pushConfig:
description:
- If push delivery is used with this subscription, this field is used to configure

View file

@ -65,10 +65,9 @@ options:
description:
- The instance to create the database on.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_spanner_instance
task and then set this instance field to "{{ name-of-resource }}" Alternatively,
you can set this instance to a dictionary with the name key where the value
is the name of your Instance'
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_spanner_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true
extends_documentation_fragment: gcp
'''
@ -118,7 +117,7 @@ instance:
description:
- The instance to create the database on.
returned: success
type: dict
type: str
'''
################################################################################
@ -141,7 +140,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(type='str'),
extra_statements=dict(type='list', elements='str'),
instance=dict(required=True, type='dict')
instance=dict(required=True)
)
)

View file

@ -45,10 +45,9 @@ options:
description:
- The instance to create the database on.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_spanner_instance
task and then set this instance field to "{{ name-of-resource }}" Alternatively,
you can set this instance to a dictionary with the name key where the value
is the name of your Instance'
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_spanner_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true
extends_documentation_fragment: gcp
'''
@ -87,7 +86,7 @@ items:
description:
- The instance to create the database on.
returned: success
type: dict
type: str
'''
################################################################################
@ -104,7 +103,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
instance=dict(required=True, type='dict')
instance=dict(required=True)
)
)

View file

@ -65,10 +65,9 @@ options:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}" Alternatively,
you can set this instance to a dictionary with the name key where the value
is the name of your Instance'
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true
extends_documentation_fragment: gcp
'''
@ -76,7 +75,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a instance
gcp_sql_instance:
name: "instance-database"
name: "{{resource_name}}-3"
settings:
ip_configuration:
authorized_networks:
@ -122,7 +121,7 @@ instance:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
returned: success
type: dict
type: str
'''
################################################################################
@ -147,7 +146,7 @@ def main():
charset=dict(type='str'),
collation=dict(type='str'),
name=dict(type='str'),
instance=dict(required=True, type='dict')
instance=dict(required=True)
)
)

View file

@ -45,10 +45,9 @@ options:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}" Alternatively,
you can set this instance to a dictionary with the name key where the value
is the name of your Instance'
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true
extends_documentation_fragment: gcp
'''
@ -88,7 +87,7 @@ items:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
returned: success
type: dict
type: str
'''
################################################################################
@ -105,7 +104,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
instance=dict(required=True, type='dict')
instance=dict(required=True)
)
)

View file

@ -87,7 +87,7 @@ options:
description:
- The availability status of the failover replica. A false status indicates
that the failover replica is out of sync. The master can only failover to
the falover replica when the status is true.
the failover replica when the status is true.
required: false
type: bool
name:
@ -163,8 +163,8 @@ options:
required: false
client_key:
description:
- PEM representation of the slave's private key. The corresponsing public
key is encoded in the client's asf asd certificate.
- PEM representation of the slave's private key. The corresponding public
key is encoded in the client's certificate.
required: false
connect_retry_interval:
description:
@ -273,7 +273,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a instance
gcp_sql_instance:
name: "test_object"
name: "{{resource_name}}-2"
settings:
ip_configuration:
authorized_networks:
@ -320,7 +320,7 @@ failoverReplica:
description:
- The availability status of the failover replica. A false status indicates
that the failover replica is out of sync. The master can only failover to
the falover replica when the status is true.
the failover replica when the status is true.
returned: success
type: bool
name:
@ -427,8 +427,8 @@ replicaConfiguration:
type: str
clientKey:
description:
- PEM representation of the slave's private key. The corresponsing public
key is encoded in the client's asf asd certificate.
- PEM representation of the slave's private key. The corresponding public
key is encoded in the client's certificate.
returned: success
type: str
connectRetryInterval:

View file

@ -90,7 +90,7 @@ items:
description:
- The availability status of the failover replica. A false status indicates
that the failover replica is out of sync. The master can only failover
to the falover replica when the status is true.
to the failover replica when the status is true.
returned: success
type: bool
name:
@ -200,8 +200,8 @@ items:
type: str
clientKey:
description:
- PEM representation of the slave's private key. The corresponsing public
key is encoded in the client's asf asd certificate.
- PEM representation of the slave's private key. The corresponding public
key is encoded in the client's certificate.
returned: success
type: str
connectRetryInterval:

View file

@ -62,10 +62,9 @@ options:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}" Alternatively,
you can set this instance to a dictionary with the name key where the value
is the name of your Instance'
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true
password:
description:
@ -77,7 +76,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a instance
gcp_sql_instance:
name: "instance-user"
name: "{{resource_name}}-1"
settings:
ip_configuration:
authorized_networks:
@ -120,7 +119,7 @@ instance:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
returned: success
type: dict
type: str
password:
description:
- The password for the user.
@ -149,7 +148,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'),
host=dict(required=True, type='str'),
name=dict(required=True, type='str'),
instance=dict(required=True, type='dict'),
instance=dict(required=True),
password=dict(type='str')
)
)

View file

@ -45,10 +45,9 @@ options:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}" Alternatively,
you can set this instance to a dictionary with the name key where the value
is the name of your Instance'
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true
extends_documentation_fragment: gcp
'''
@ -84,7 +83,7 @@ items:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
returned: success
type: dict
type: str
password:
description:
- The password for the user.
@ -106,7 +105,7 @@ import json
def main():
module = GcpModule(
argument_spec=dict(
instance=dict(required=True, type='dict')
instance=dict(required=True)
)
)

View file

@ -62,10 +62,9 @@ options:
description:
- The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_storage_bucket
task and then set this bucket field to "{{ name-of-resource }}" Alternatively,
you can set this bucket to a dictionary with the name key where the value
is the name of your Bucket'
in two ways. First, you can place in the name of the resource here as a
string Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket
task and then set this bucket field to "{{ name-of-resource }}"'
required: true
domain:
description:
@ -154,10 +153,9 @@ options:
description:
- The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_storage_bucket
task and then set this bucket field to "{{ name-of-resource }}" Alternatively,
you can set this bucket to a dictionary with the name key where the value
is the name of your Bucket'
in two ways. First, you can place in the name of the resource here as a
string Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket
task and then set this bucket field to "{{ name-of-resource }}"'
required: true
domain:
description:
@ -415,7 +413,7 @@ acl:
description:
- The name of the bucket.
returned: success
type: dict
type: str
domain:
description:
- The domain associated with the entity.
@ -509,7 +507,7 @@ defaultObjectAcl:
description:
- The name of the bucket.
returned: success
type: dict
type: str
domain:
description:
- The domain associated with the entity.
@ -793,7 +791,7 @@ def main():
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
acl=dict(type='list', elements='dict', options=dict(
bucket=dict(required=True, type='dict'),
bucket=dict(required=True),
domain=dict(type='str'),
email=dict(type='str'),
entity=dict(required=True, type='str'),
@ -812,7 +810,7 @@ def main():
response_header=dict(type='list', elements='str')
)),
default_object_acl=dict(type='list', elements='dict', options=dict(
bucket=dict(required=True, type='dict'),
bucket=dict(required=True),
domain=dict(type='str'),
email=dict(type='str'),
entity=dict(required=True, type='str'),

View file

@ -61,10 +61,9 @@ options:
description:
- The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_storage_bucket
task and then set this bucket field to "{{ name-of-resource }}" Alternatively,
you can set this bucket to a dictionary with the name key where the value is
the name of your Bucket'
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket
task and then set this bucket field to "{{ name-of-resource }}"'
required: true
entity:
description:
@ -110,7 +109,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a bucket
gcp_storage_bucket:
name: "bucket-bac"
name: "{{ resource_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -133,7 +132,7 @@ bucket:
description:
- The name of the bucket.
returned: success
type: dict
type: str
domain:
description:
- The domain associated with the entity.
@ -205,7 +204,7 @@ def main():
module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
bucket=dict(required=True, type='dict'),
bucket=dict(required=True),
entity=dict(required=True, type='str'),
entity_id=dict(type='str'),
project_team=dict(type='dict', options=dict(

View file

@ -44,7 +44,7 @@
- name: verify that command succeeded
assert:
that:
- results['items'] | length == 1
- "'test-topic1' in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: create a topic that already exists
gcp_pubsub_topic:
@ -82,7 +82,7 @@
- name: verify that command succeeded
assert:
that:
- results['items'] | length == 0
- "'test-topic1' not in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: delete a topic that does not exist
gcp_pubsub_topic:

View file

@ -49,13 +49,18 @@
that:
- result.changed == true
- name: verify that database was created
shell: |
gcloud spanner databases describe --project="{{ gcp_project }}" --instance="{{ instance.name }}" "webstore"
gcp_spanner_database_facts:
instance: "{{ instance }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/spanner.admin
register: results
- name: verify that command succeeded
assert:
that:
- results.rc == 0
- "'webstore' in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: create a database that already exists
gcp_spanner_database:
@ -85,15 +90,18 @@
that:
- result.changed == true
- name: verify that database was deleted
shell: |
gcloud spanner databases describe --project="{{ gcp_project }}" --instance="{{ instance.name }}" "webstore"
gcp_spanner_database_facts:
instance: "{{ instance }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/spanner.admin
register: results
failed_when: results.rc == 0
- name: verify that command succeeded
assert:
that:
- results.rc == 1
- "\"Database not found: projects/{{ gcp_project }}/instances/instance-database/databases/webstore\" in results.stderr"
- "'webstore' not in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: delete a database that does not exist
gcp_spanner_database:
@ -110,6 +118,7 @@
- result.changed == false
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!
- name: delete a instance
gcp_spanner_instance:
name: "instance-database"
@ -123,3 +132,4 @@
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: instance
ignore_errors: true

View file

@ -44,13 +44,17 @@
that:
- result.changed == true
- name: verify that instance was created
shell: |
gcloud spanner instances describe --project="{{ gcp_project }}" "{{ resource_name }}"
gcp_spanner_instance_facts:
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/spanner.admin
register: results
- name: verify that command succeeded
assert:
that:
- results.rc == 0
- "\"{{resource_name}}\" in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: create a instance that already exists
gcp_spanner_instance:
@ -88,15 +92,17 @@
that:
- result.changed == true
- name: verify that instance was deleted
shell: |
gcloud spanner instances describe --project="{{ gcp_project }}" "{{ resource_name }}"
gcp_spanner_instance_facts:
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/spanner.admin
register: results
failed_when: results.rc == 0
- name: verify that command succeeded
assert:
that:
- results.rc == 1
- "\"Instance not found: projects/{{ gcp_project }}/instances/{{ resource_name }}\" in results.stderr"
- "\"{{resource_name}}\" not in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: delete a instance that does not exist
gcp_spanner_instance:

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a instance
gcp_sql_instance:
name: "instance-database"
name: "{{resource_name}}-3"
settings:
ip_configuration:
authorized_networks:
@ -54,13 +54,18 @@
- result.changed == true
- "result.kind == 'sql#database'"
- name: verify that database was created
shell: |
gcloud sql databases describe --instance='instance-database' --project="{{ gcp_project}}" "{{ resource_name }}"
gcp_sql_database_facts:
instance: "{{ instance }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/sqlservice.admin
register: results
- name: verify that command succeeded
assert:
that:
- results.rc == 0
- "\"{{resource_name}}\" in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: create a database that already exists
gcp_sql_database:
@ -94,15 +99,18 @@
- result.changed == true
- result.has_key('kind') == False
- name: verify that database was deleted
shell: |
gcloud sql databases describe --instance='instance-database' --project="{{ gcp_project}}" "{{ resource_name }}"
gcp_sql_database_facts:
instance: "{{ instance }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/sqlservice.admin
register: results
failed_when: results.rc == 0
- name: verify that command succeeded
assert:
that:
- results.rc == 1
- "\"(gcloud.sql.databases.describe) HTTPError 404: Not Found\" in results.stderr"
- "\"{{resource_name}}\" not in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: delete a database that does not exist
gcp_sql_database:
@ -121,9 +129,10 @@
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!
- name: delete a instance
gcp_sql_instance:
name: "instance-database"
name: "{{resource_name}}-3"
settings:
ip_configuration:
authorized_networks:
@ -136,3 +145,4 @@
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: instance
ignore_errors: true

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: delete a instance
gcp_sql_instance:
name: "{{ resource_name }}"
name: "{{resource_name}}-2"
settings:
ip_configuration:
authorized_networks:
@ -30,7 +30,7 @@
#----------------------------------------------------------
- name: create a instance
gcp_sql_instance:
name: "{{ resource_name }}"
name: "{{resource_name}}-2"
settings:
ip_configuration:
authorized_networks:
@ -49,17 +49,21 @@
- result.changed == true
- "result.kind == 'sql#instance'"
- name: verify that instance was created
shell: |
gcloud sql instances describe --project="{{ gcp_project}}" "{{ resource_name }}"
gcp_sql_instance_facts:
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/sqlservice.admin
register: results
- name: verify that command succeeded
assert:
that:
- results.rc == 0
- results['items'] | length >= 1
# ----------------------------------------------------------------------------
- name: create a instance that already exists
gcp_sql_instance:
name: "{{ resource_name }}"
name: "{{resource_name}}-2"
settings:
ip_configuration:
authorized_networks:
@ -80,7 +84,7 @@
#----------------------------------------------------------
- name: delete a instance
gcp_sql_instance:
name: "{{ resource_name }}"
name: "{{resource_name}}-2"
settings:
ip_configuration:
authorized_networks:
@ -99,19 +103,21 @@
- result.changed == true
- result.has_key('kind') == False
- name: verify that instance was deleted
shell: |
gcloud sql instances describe --project="{{ gcp_project}}" "{{ resource_name }}"
gcp_sql_instance_facts:
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/sqlservice.admin
register: results
failed_when: results.rc == 0
- name: verify that command succeeded
assert:
that:
- results.rc == 1
- "\"Cloud SQL instance does not exist\" in results.stderr"
- results['items'] | length == 0
# ----------------------------------------------------------------------------
- name: delete a instance that does not exist
gcp_sql_instance:
name: "{{ resource_name }}"
name: "{{resource_name}}-2"
settings:
ip_configuration:
authorized_networks:

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a instance
gcp_sql_instance:
name: "instance-user"
name: "{{resource_name}}-1"
settings:
ip_configuration:
authorized_networks:
@ -57,8 +57,6 @@
- "result.kind == 'sql#user'"
- name: verify that user was created
gcp_sql_user_facts:
filters:
- name = test-user
instance: "{{ instance }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -69,7 +67,7 @@
- name: verify that command succeeded
assert:
that:
- results['items'] | length == 1
- "'test-user' in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: create a user that already exists
gcp_sql_user:
@ -106,8 +104,6 @@
- result.has_key('kind') == False
- name: verify that user was deleted
gcp_sql_user_facts:
filters:
- name = test-user
instance: "{{ instance }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -118,7 +114,7 @@
- name: verify that command succeeded
assert:
that:
- results['items'] | length == 0
- "'test-user' not in \"{{ results['items'] | map(attribute='name') | list }}\""
# ----------------------------------------------------------------------------
- name: delete a user that does not exist
gcp_sql_user:
@ -138,9 +134,10 @@
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!
- name: delete a instance
gcp_sql_instance:
name: "instance-user"
name: "{{resource_name}}-1"
settings:
ip_configuration:
authorized_networks:
@ -153,3 +150,4 @@
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: instance
ignore_errors: true

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a bucket
gcp_storage_bucket:
name: "bucket-bac"
name: "{{ resource_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -96,11 +96,13 @@
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!
- name: delete a bucket
gcp_storage_bucket:
name: "bucket-bac"
name: "{{ resource_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: bucket
ignore_errors: true