From 2220b9c851fadb42145f1ea01b9d66a3a5e8d3ff Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 28 May 2019 10:41:20 -0700 Subject: [PATCH] Bug fixes for GCP modules (#56766) --- .../cloud/google/gcp_spanner_instance.py | 4 +- .../google/gcp_spanner_instance_facts.py | 2 +- .../modules/cloud/google/gcp_sql_instance.py | 28 +++------- .../cloud/google/gcp_storage_bucket.py | 54 +++++-------------- .../gcp_storage_bucket_access_control.py | 14 ++--- .../cloud/google/gcp_storage_object.py | 6 +-- 6 files changed, 31 insertions(+), 77 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py b/lib/ansible/modules/cloud/google/gcp_spanner_instance.py index ed2cf449f8..588a594a24 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_instance.py @@ -59,7 +59,7 @@ options: your databases in this instance. It determines where your data is stored. Values are typically of the form `regional-europe-west1` , `us-central` etc. - In order to obtain a valid list please consult the [Configuration section of - the docs](U(https://cloud.google.com/spanner/docs/instances).) + the docs](U(https://cloud.google.com/spanner/docs/instances)). required: true display_name: description: @@ -111,7 +111,7 @@ config: databases in this instance. It determines where your data is stored. Values are typically of the form `regional-europe-west1` , `us-central` etc. - In order to obtain a valid list please consult the [Configuration section of the - docs](U(https://cloud.google.com/spanner/docs/instances).) + docs](U(https://cloud.google.com/spanner/docs/instances)). returned: success type: str displayName: 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 7c64a9e5b5..6b1ecf487a 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_instance_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_instance_facts.py @@ -71,7 +71,7 @@ resources: your databases in this instance. It determines where your data is stored. Values are typically of the form `regional-europe-west1` , `us-central` etc. - In order to obtain a valid list please consult the [Configuration section - of the docs](U(https://cloud.google.com/spanner/docs/instances).) + of the docs](U(https://cloud.google.com/spanner/docs/instances)). returned: success type: str displayName: diff --git a/lib/ansible/modules/cloud/google/gcp_sql_instance.py b/lib/ansible/modules/cloud/google/gcp_sql_instance.py index 9cfa57d2fb..8b8349c32b 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_instance.py @@ -54,11 +54,8 @@ options: - "* FIRST_GEN: First Generation instance. MySQL only." - "* SECOND_GEN: Second Generation instance or PostgreSQL instance." - "* EXTERNAL: A database server that is not managed by Google." + - 'Some valid choices include: "FIRST_GEN", "SECOND_GEN", "EXTERNAL"' required: false - choices: - - FIRST_GEN - - SECOND_GEN - - EXTERNAL connection_name: description: - Connection name of the Cloud SQL instance used in connection strings. @@ -70,12 +67,8 @@ options: MYSQL_5_7. Defaults to MYSQL_5_6. - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be changed after instance creation.' + - 'Some valid choices include: "MYSQL_5_5", "MYSQL_5_6", "MYSQL_5_7", "POSTGRES_9_6"' required: false - choices: - - MYSQL_5_5 - - MYSQL_5_6 - - MYSQL_5_7 - - POSTGRES_9_6 failover_replica: description: - The name and status of the failover replica. This property is applicable only @@ -94,11 +87,8 @@ options: - "* CLOUD_SQL_INSTANCE: A Cloud SQL instance that is not replicating from a master." - "* ON_PREMISES_INSTANCE: An instance running on the customer's premises." - "* READ_REPLICA_INSTANCE: A Cloud SQL instance configured as a read-replica." + - 'Some valid choices include: "CLOUD_SQL_INSTANCE", "ON_PREMISES_INSTANCE", "READ_REPLICA_INSTANCE"' required: false - choices: - - CLOUD_SQL_INSTANCE - - ON_PREMISES_INSTANCE - - READ_REPLICA_INSTANCE ipv6_address: description: - The IPv6 address assigned to the instance. This property is applicable only @@ -255,10 +245,8 @@ options: availability_type: description: - The availabilityType define if your postgres instance is run zonal or regional. + - 'Some valid choices include: "ZONAL", "REGIONAL"' required: false - choices: - - ZONAL - - REGIONAL backup_configuration: description: - The daily backup configuration for the instance. @@ -607,11 +595,11 @@ def main(): module = GcpModule( argument_spec=dict( state=dict(default='present', choices=['present', 'absent'], type='str'), - backend_type=dict(type='str', choices=['FIRST_GEN', 'SECOND_GEN', 'EXTERNAL']), + backend_type=dict(type='str'), connection_name=dict(type='str'), - database_version=dict(type='str', choices=['MYSQL_5_5', 'MYSQL_5_6', 'MYSQL_5_7', 'POSTGRES_9_6']), + database_version=dict(type='str'), failover_replica=dict(type='dict', options=dict(name=dict(type='str'))), - instance_type=dict(type='str', choices=['CLOUD_SQL_INSTANCE', 'ON_PREMISES_INSTANCE', 'READ_REPLICA_INSTANCE']), + instance_type=dict(type='str'), ipv6_address=dict(type='str'), master_instance_name=dict(type='str'), max_disk_size=dict(type='int'), @@ -654,7 +642,7 @@ def main(): ), ), tier=dict(type='str'), - availability_type=dict(type='str', choices=['ZONAL', 'REGIONAL']), + availability_type=dict(type='str'), backup_configuration=dict( type='dict', options=dict(enabled=dict(type='bool'), binary_log_enabled=dict(type='bool'), start_time=dict(type='str')) ), diff --git a/lib/ansible/modules/cloud/google/gcp_storage_bucket.py b/lib/ansible/modules/cloud/google/gcp_storage_bucket.py index e33cbed230..3c483eff40 100644 --- a/lib/ansible/modules/cloud/google/gcp_storage_bucket.py +++ b/lib/ansible/modules/cloud/google/gcp_storage_bucket.py @@ -92,19 +92,13 @@ options: team: description: - The team. + - 'Some valid choices include: "editors", "owners", "viewers"' required: false - choices: - - editors - - owners - - viewers role: description: - The access permission for the entity. + - 'Some valid choices include: "OWNER", "READER", "WRITER"' required: false - choices: - - OWNER - - READER - - WRITER cors: description: - The bucket's Cross-Origin Resource Sharing (CORS) configuration. @@ -161,10 +155,8 @@ options: role: description: - The access permission for the entity. + - 'Some valid choices include: "OWNER", "READER"' required: true - choices: - - OWNER - - READER lifecycle: description: - The bucket's lifecycle configuration. @@ -190,10 +182,8 @@ options: description: - Type of the action. Currently, only Delete and SetStorageClass are supported. + - 'Some valid choices include: "Delete", "SetStorageClass"' required: false - choices: - - Delete - - SetStorageClass condition: description: - The condition(s) under which the action will be taken. @@ -274,14 +264,9 @@ options: - Values include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, and DURABLE_REDUCED_AVAILABILITY. If this value is not specified when the bucket is created, it will default to STANDARD. For more information, see storage classes. + - 'Some valid choices include: "MULTI_REGIONAL", "REGIONAL", "STANDARD", "NEARLINE", + "COLDLINE", "DURABLE_REDUCED_AVAILABILITY"' required: false - choices: - - MULTI_REGIONAL - - REGIONAL - - STANDARD - - NEARLINE - - COLDLINE - - DURABLE_REDUCED_AVAILABILITY versioning: description: - The bucket's versioning configuration. @@ -329,14 +314,9 @@ options: - '- "projectPrivate": Object owner gets OWNER access, and project team members get access according to their roles.' - '- "publicRead": Object owner gets OWNER access, and allUsers get READER access.' + - 'Some valid choices include: "authenticatedRead", "bucketOwnerFullControl", + "bucketOwnerRead", "private", "projectPrivate", "publicRead"' required: false - choices: - - authenticatedRead - - bucketOwnerFullControl - - bucketOwnerRead - - private - - projectPrivate - - publicRead extends_documentation_fragment: gcp ''' @@ -745,10 +725,8 @@ def main(): bucket=dict(required=True, type='dict'), entity=dict(required=True, type='str'), entity_id=dict(type='str'), - project_team=dict( - type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers'])) - ), - role=dict(type='str', choices=['OWNER', 'READER', 'WRITER']), + project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str'))), + role=dict(type='str'), ), ), cors=dict( @@ -768,7 +746,7 @@ def main(): bucket=dict(required=True, type='dict'), entity=dict(required=True, type='str'), object=dict(type='str'), - role=dict(required=True, type='str', choices=['OWNER', 'READER']), + role=dict(required=True, type='str'), ), ), lifecycle=dict( @@ -778,9 +756,7 @@ def main(): type='list', elements='dict', options=dict( - action=dict( - type='dict', options=dict(storage_class=dict(type='str'), type=dict(type='str', choices=['Delete', 'SetStorageClass'])) - ), + action=dict(type='dict', options=dict(storage_class=dict(type='str'), type=dict(type='str'))), condition=dict( type='dict', options=dict( @@ -800,13 +776,11 @@ def main(): metageneration=dict(type='int'), name=dict(type='str'), owner=dict(type='dict', options=dict(entity=dict(type='str'))), - storage_class=dict(type='str', choices=['MULTI_REGIONAL', 'REGIONAL', 'STANDARD', 'NEARLINE', 'COLDLINE', 'DURABLE_REDUCED_AVAILABILITY']), + storage_class=dict(type='str'), versioning=dict(type='dict', options=dict(enabled=dict(type='bool'))), website=dict(type='dict', options=dict(main_page_suffix=dict(type='str'), not_found_page=dict(type='str'))), project=dict(type='str'), - predefined_default_object_acl=dict( - type='str', choices=['authenticatedRead', 'bucketOwnerFullControl', 'bucketOwnerRead', 'private', 'projectPrivate', 'publicRead'] - ), + predefined_default_object_acl=dict(type='str'), ) ) 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 49c9dc76e7..a91068cb32 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 @@ -90,19 +90,13 @@ options: team: description: - The team. + - 'Some valid choices include: "editors", "owners", "viewers"' required: false - choices: - - editors - - owners - - viewers role: description: - The access permission for the entity. + - 'Some valid choices include: "OWNER", "READER", "WRITER"' required: false - choices: - - OWNER - - READER - - WRITER extends_documentation_fragment: gcp ''' @@ -207,8 +201,8 @@ def main(): bucket=dict(required=True, type='dict'), entity=dict(required=True, type='str'), entity_id=dict(type='str'), - project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']))), - role=dict(type='str', choices=['OWNER', 'READER', 'WRITER']), + project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str'))), + role=dict(type='str'), ) ) diff --git a/lib/ansible/modules/cloud/google/gcp_storage_object.py b/lib/ansible/modules/cloud/google/gcp_storage_object.py index 756b2016fa..3158e174c1 100644 --- a/lib/ansible/modules/cloud/google/gcp_storage_object.py +++ b/lib/ansible/modules/cloud/google/gcp_storage_object.py @@ -50,10 +50,8 @@ options: action: description: - Upload or download from the bucket. + - 'Some valid choices include: "download", "upload"' required: false - choices: - - download - - upload overwrite: description: - "'Overwrite the file on the bucket/local machine. If overwrite is false and @@ -140,7 +138,7 @@ def main(): module = GcpModule( argument_spec=dict( state=dict(default='present', choices=['present', 'absent'], type='str'), - action=dict(type='str', choices=['download', 'upload']), + action=dict(type='str'), overwrite=dict(type='bool'), src=dict(type='path'), dest=dict(type='path'),