From 5ad5677b716bf8feb3c221b20c1c4931b74bd384 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 15 Nov 2018 05:44:10 -0800 Subject: [PATCH] GCP Bug Fixes (#48276) * GCP Bug fixes * added util file changes --- lib/ansible/module_utils/gcp_utils.py | 2 +- .../cloud/google/gcp_compute_address.py | 276 +-- .../cloud/google/gcp_compute_address_facts.py | 164 +- .../google/gcp_compute_backend_bucket.py | 150 +- .../gcp_compute_backend_bucket_facts.py | 101 +- .../google/gcp_compute_backend_service.py | 1006 +++++------ .../gcp_compute_backend_service_facts.py | 544 +++--- .../modules/cloud/google/gcp_compute_disk.py | 636 ++++--- .../cloud/google/gcp_compute_disk_facts.py | 402 ++--- .../cloud/google/gcp_compute_firewall.py | 664 ++++---- .../google/gcp_compute_firewall_facts.py | 362 ++-- .../google/gcp_compute_forwarding_rule.py | 629 ++++--- .../gcp_compute_forwarding_rule_facts.py | 329 ++-- .../google/gcp_compute_global_address.py | 218 ++- .../gcp_compute_global_address_facts.py | 134 +- .../gcp_compute_global_forwarding_rule.py | 545 +++--- ...cp_compute_global_forwarding_rule_facts.py | 294 ++-- .../cloud/google/gcp_compute_health_check.py | 819 ++++----- .../google/gcp_compute_health_check_facts.py | 446 ++--- .../google/gcp_compute_http_health_check.py | 272 +-- .../gcp_compute_http_health_check_facts.py | 168 +- .../google/gcp_compute_https_health_check.py | 267 +-- .../gcp_compute_https_health_check_facts.py | 168 +- .../modules/cloud/google/gcp_compute_image.py | 677 ++++---- .../cloud/google/gcp_compute_image_facts.py | 423 ++--- .../cloud/google/gcp_compute_instance.py | 1468 ++++++++-------- .../google/gcp_compute_instance_facts.py | 820 ++++----- .../google/gcp_compute_instance_group.py | 296 ++-- .../gcp_compute_instance_group_facts.py | 181 +- .../gcp_compute_instance_group_manager.py | 436 ++--- ...cp_compute_instance_group_manager_facts.py | 328 ++-- .../google/gcp_compute_instance_template.py | 1488 +++++++++-------- .../gcp_compute_instance_template_facts.py | 790 ++++----- .../cloud/google/gcp_compute_network.py | 275 +-- .../cloud/google/gcp_compute_network_facts.py | 166 +- .../cloud/google/gcp_compute_region_disk.py | 508 +++--- .../google/gcp_compute_region_disk_facts.py | 325 ++-- .../modules/cloud/google/gcp_compute_route.py | 328 ++-- .../cloud/google/gcp_compute_route_facts.py | 175 +- .../cloud/google/gcp_compute_router.py | 319 ++-- .../cloud/google/gcp_compute_router_facts.py | 199 +-- .../google/gcp_compute_ssl_certificate.py | 148 +- .../gcp_compute_ssl_certificate_facts.py | 103 +- .../cloud/google/gcp_compute_ssl_policy.py | 249 +-- .../google/gcp_compute_ssl_policy_facts.py | 178 +- .../cloud/google/gcp_compute_subnetwork.py | 374 ++--- .../google/gcp_compute_subnetwork_facts.py | 218 +-- .../google/gcp_compute_target_http_proxy.py | 131 +- .../gcp_compute_target_http_proxy_facts.py | 90 +- .../google/gcp_compute_target_https_proxy.py | 195 +-- .../gcp_compute_target_https_proxy_facts.py | 121 +- .../cloud/google/gcp_compute_target_pool.py | 349 ++-- .../google/gcp_compute_target_pool_facts.py | 205 ++- .../google/gcp_compute_target_ssl_proxy.py | 242 +-- .../gcp_compute_target_ssl_proxy_facts.py | 114 +- .../google/gcp_compute_target_tcp_proxy.py | 156 +- .../gcp_compute_target_tcp_proxy_facts.py | 101 +- .../google/gcp_compute_target_vpn_gateway.py | 166 +- .../gcp_compute_target_vpn_gateway_facts.py | 128 +- .../cloud/google/gcp_compute_url_map.py | 510 +++--- .../cloud/google/gcp_compute_url_map_facts.py | 286 ++-- .../cloud/google/gcp_compute_vpn_tunnel.py | 326 ++-- .../google/gcp_compute_vpn_tunnel_facts.py | 204 +-- .../cloud/google/gcp_container_cluster.py | 1033 ++++++------ .../cloud/google/gcp_container_node_pool.py | 705 ++++---- .../cloud/google/gcp_dns_managed_zone.py | 142 +- .../google/gcp_dns_managed_zone_facts.py | 106 +- .../google/gcp_dns_resource_record_set.py | 146 +- .../gcp_dns_resource_record_set_facts.py | 90 +- .../cloud/google/gcp_pubsub_subscription.py | 192 +-- .../google/gcp_pubsub_subscription_facts.py | 104 +- .../modules/cloud/google/gcp_pubsub_topic.py | 38 +- .../cloud/google/gcp_pubsub_topic_facts.py | 29 +- .../cloud/google/gcp_spanner_database.py | 102 +- .../cloud/google/gcp_spanner_instance.py | 190 +-- .../modules/cloud/google/gcp_sql_database.py | 114 +- .../modules/cloud/google/gcp_sql_instance.py | 953 +++++------ .../modules/cloud/google/gcp_sql_user.py | 118 +- .../cloud/google/gcp_storage_bucket.py | 1368 +++++++-------- .../gcp_storage_bucket_access_control.py | 238 +-- 80 files changed, 14198 insertions(+), 13862 deletions(-) diff --git a/lib/ansible/module_utils/gcp_utils.py b/lib/ansible/module_utils/gcp_utils.py index 9171e3f358..6ae28598fe 100644 --- a/lib/ansible/module_utils/gcp_utils.py +++ b/lib/ansible/module_utils/gcp_utils.py @@ -153,7 +153,7 @@ class GcpModule(AnsibleModule): arg_spec, dict( project=dict( - required=True, + required=False, type='str', fallback=(env_fallback, ['GCP_PROJECT'])), auth_kind=dict( diff --git a/lib/ansible/modules/cloud/google/gcp_compute_address.py b/lib/ansible/modules/cloud/google/gcp_compute_address.py index 7ac0cbec69..b5b8726b47 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_address.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_address.py @@ -32,85 +32,92 @@ DOCUMENTATION = ''' --- module: gcp_compute_address description: - - Represents an Address resource. - - Each virtual machine instance has an ephemeral internal IP address and, optionally, - an external IP address. To communicate between instances on the same network, you - can use an instance's internal IP address. To communicate with the Internet and - instances outside of the same network, you must specify the instance's external - IP address. - - Internal IP addresses are ephemeral and only belong to an instance for the lifetime - of the instance; if the instance is deleted and recreated, the instance is assigned - a new internal IP address, either by Compute Engine or by you. External IP addresses - can be either ephemeral or static. +- Represents an Address resource. +- Each virtual machine instance has an ephemeral internal IP address and, optionally, + an external IP address. To communicate between instances on the same network, you + can use an instance's internal IP address. To communicate with the Internet and + instances outside of the same network, you must specify the instance's external + IP address. +- Internal IP addresses are ephemeral and only belong to an instance for the lifetime + of the instance; if the instance is deleted and recreated, the instance is assigned + a new internal IP address, either by Compute Engine or by you. External IP addresses + can be either ephemeral or static. short_description: Creates a GCP Address version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - address: - description: - - The static external IP address represented by this resource. Only IPv4 is supported. - An address may only be specified for INTERNAL address types. The IP address must - be inside the specified subnetwork, if any. - required: false - address_type: - description: - - The type of address to reserve, either INTERNAL or EXTERNAL. - - If unspecified, defaults to EXTERNAL. - required: false - default: EXTERNAL - version_added: 2.7 - choices: ['INTERNAL', 'EXTERNAL'] + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - required: true - network_tier: - description: - - 'The networking tier used for configuring this address. This field can take the - following values: PREMIUM or STANDARD. If this field is not specified, it is assumed - to be PREMIUM.' - required: false - version_added: 2.8 - choices: ['PREMIUM', 'STANDARD'] - subnetwork: - description: - - The URL of the subnetwork in which to reserve the address. If an IP address is specified, - it must be within the subnetwork's IP range. - - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER purposes. - - 'This field represents a link to a Subnetwork resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork - task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, - you can set this subnetwork to a dictionary with the selfLink key where the value - is the selfLink of your Subnetwork.' - required: false - version_added: 2.7 - region: - description: - - URL of the region where the regional address resides. - - This field is not applicable to global addresses. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + address: + description: + - The static external IP address represented by this resource. Only IPv4 is supported. + An address may only be specified for INTERNAL address types. The IP address + must be inside the specified subnetwork, if any. + required: false + address_type: + description: + - The type of address to reserve, either INTERNAL or EXTERNAL. + - If unspecified, defaults to EXTERNAL. + required: false + default: EXTERNAL + version_added: 2.7 + choices: + - INTERNAL + - EXTERNAL + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match the regular + expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must + be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + required: true + network_tier: + description: + - 'The networking tier used for configuring this address. This field can take + the following values: PREMIUM or STANDARD. If this field is not specified, it + is assumed to be PREMIUM.' + required: false + version_added: 2.8 + choices: + - PREMIUM + - STANDARD + subnetwork: + description: + - The URL of the subnetwork in which to reserve the address. If an IP address + is specified, it must be within the subnetwork's IP range. + - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER + purposes. + - 'This field represents a link to a Subnetwork resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork + task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, + you can set this subnetwork to a dictionary with the selfLink key where the + value is the selfLink of your Subnetwork' + required: false + version_added: 2.7 + region: + description: + - URL of the region where the regional address resides. + - This field is not applicable to global addresses. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/beta/addresses)" - - "Reserving a Static External IP Address: U(https://cloud.google.com/compute/docs/instances-and-network)" - - "Reserving a Static Internal IP Address: U(https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/beta/addresses)' +- 'Reserving a Static External IP Address: U(https://cloud.google.com/compute/docs/instances-and-network)' +- 'Reserving a Static Internal IP Address: U(https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address)' ''' EXAMPLES = ''' @@ -125,68 +132,69 @@ EXAMPLES = ''' ''' RETURN = ''' - address: - description: - - The static external IP address represented by this resource. Only IPv4 is supported. - An address may only be specified for INTERNAL address types. The IP address must - be inside the specified subnetwork, if any. - returned: success - type: str - addressType: - description: - - The type of address to reserve, either INTERNAL or EXTERNAL. - - If unspecified, defaults to EXTERNAL. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - returned: success - type: str - networkTier: - description: - - 'The networking tier used for configuring this address. This field can take the - following values: PREMIUM or STANDARD. If this field is not specified, it is assumed - to be PREMIUM.' - returned: success - type: str - subnetwork: - description: - - The URL of the subnetwork in which to reserve the address. If an IP address is specified, - it must be within the subnetwork's IP range. - - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER purposes. - returned: success - type: dict - users: - description: - - The URLs of the resources that are using this address. - returned: success - type: list - region: - description: - - URL of the region where the regional address resides. - - This field is not applicable to global addresses. - returned: success - type: str +address: + description: + - The static external IP address represented by this resource. Only IPv4 is supported. + An address may only be specified for INTERNAL address types. The IP address must + be inside the specified subnetwork, if any. + returned: success + type: str +addressType: + description: + - The type of address to reserve, either INTERNAL or EXTERNAL. + - If unspecified, defaults to EXTERNAL. + returned: success + type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. + Specifically, the name must be 1-63 characters long and match the regular expression + `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase + letter, and all following characters must be a dash, lowercase letter, or digit, + except the last character, which cannot be a dash. + returned: success + type: str +networkTier: + description: + - 'The networking tier used for configuring this address. This field can take the + following values: PREMIUM or STANDARD. If this field is not specified, it is assumed + to be PREMIUM.' + returned: success + type: str +subnetwork: + description: + - The URL of the subnetwork in which to reserve the address. If an IP address is + specified, it must be within the subnetwork's IP range. + - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER + purposes. + returned: success + type: dict +users: + description: + - The URLs of the resources that are using this address. + returned: success + type: list +region: + description: + - URL of the region where the regional address resides. + - This field is not applicable to global addresses. + returned: success + type: str ''' ################################################################################ @@ -373,8 +381,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_address_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_address_facts.py index 4e6ed2792d..ba06eb409c 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_address_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_address_facts.py @@ -32,26 +32,25 @@ DOCUMENTATION = ''' --- module: gcp_compute_address_facts description: - - Gather facts for GCP Address +- Gather facts for GCP Address short_description: Gather facts for GCP Address version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - URL of the region where the regional address resides. - - This field is not applicable to global addresses. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - URL of the region where the regional address resides. + - This field is not applicable to global addresses. + required: true extends_documentation_fragment: gcp ''' @@ -68,72 +67,73 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - address: - description: - - The static external IP address represented by this resource. Only IPv4 is supported. - An address may only be specified for INTERNAL address types. The IP address must - be inside the specified subnetwork, if any. - returned: success - type: str - addressType: - description: - - The type of address to reserve, either INTERNAL or EXTERNAL. - - If unspecified, defaults to EXTERNAL. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - returned: success - type: str - networkTier: - description: - - 'The networking tier used for configuring this address. This field can take the - following values: PREMIUM or STANDARD. If this field is not specified, it is assumed - to be PREMIUM.' - returned: success - type: str - subnetwork: - description: - - The URL of the subnetwork in which to reserve the address. If an IP address is specified, - it must be within the subnetwork's IP range. - - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER purposes. - returned: success - type: dict - users: - description: - - The URLs of the resources that are using this address. - returned: success - type: list - region: - description: - - URL of the region where the regional address resides. - - This field is not applicable to global addresses. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + address: + description: + - The static external IP address represented by this resource. Only IPv4 is + supported. An address may only be specified for INTERNAL address types. The + IP address must be inside the specified subnetwork, if any. + returned: success + type: str + addressType: + description: + - The type of address to reserve, either INTERNAL or EXTERNAL. + - If unspecified, defaults to EXTERNAL. + returned: success + type: str + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match the + regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character + must be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + returned: success + type: str + networkTier: + description: + - 'The networking tier used for configuring this address. This field can take + the following values: PREMIUM or STANDARD. If this field is not specified, + it is assumed to be PREMIUM.' + returned: success + type: str + subnetwork: + description: + - The URL of the subnetwork in which to reserve the address. If an IP address + is specified, it must be within the subnetwork's IP range. + - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER + purposes. + returned: success + type: dict + users: + description: + - The URLs of the resources that are using this address. + returned: success + type: list + region: + description: + - URL of the region where the regional address resides. + - This field is not applicable to global addresses. + returned: success + type: str ''' ################################################################################ @@ -155,7 +155,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py index 0ef41ad3c8..3cbc235d42 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py @@ -32,51 +32,53 @@ DOCUMENTATION = ''' --- module: gcp_compute_backend_bucket description: - - Backend buckets allow you to use Google Cloud Storage buckets with HTTP(S) load - balancing. - - An HTTP(S) load balancer can direct traffic to specified URLs to a backend bucket - rather than a backend service. It can send requests for static content to a Cloud - Storage bucket and requests for dynamic content a virtual machine instance. +- Backend buckets allow you to use Google Cloud Storage buckets with HTTP(S) load + balancing. +- An HTTP(S) load balancer can direct traffic to specified URLs to a backend bucket + rather than a backend service. It can send requests for static content to a Cloud + Storage bucket and requests for dynamic content a virtual machine instance. short_description: Creates a GCP BackendBucket version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - bucket_name: - description: - - Cloud Storage bucket name. - required: true + state: description: - description: - - An optional textual description of the resource; provided by the client when the - resource is created. - required: false - enable_cdn: - description: - - If true, enable Cloud CDN for this BackendBucket. - required: false - type: bool - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + bucket_name: + description: + - Cloud Storage bucket name. + required: true + description: + description: + - An optional textual description of the resource; provided by the client when + the resource is created. + required: false + enable_cdn: + description: + - If true, enable Cloud CDN for this BackendBucket. + required: false + type: bool + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/backendBuckets)" - - "Using a Cloud Storage bucket as a load balancer backend: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-bucket)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/backendBuckets)' +- 'Using a Cloud Storage bucket as a load balancer backend: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-bucket)' ''' EXAMPLES = ''' @@ -102,42 +104,42 @@ EXAMPLES = ''' ''' RETURN = ''' - bucketName: - description: - - Cloud Storage bucket name. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional textual description of the resource; provided by the client when the - resource is created. - returned: success - type: str - enableCdn: - description: - - If true, enable Cloud CDN for this BackendBucket. - returned: success - type: bool - id: - description: - - Unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str +bucketName: + description: + - Cloud Storage bucket name. + returned: success + type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional textual description of the resource; provided by the client when the + resource is created. + returned: success + type: str +enableCdn: + description: + - If true, enable Cloud CDN for this BackendBucket. + returned: success + type: bool +id: + description: + - Unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str ''' ################################################################################ @@ -317,8 +319,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_facts.py index 29a7dea603..9e607bf6ef 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_backend_bucket_facts description: - - Gather facts for GCP BackendBucket +- Gather facts for GCP BackendBucket short_description: Gather facts for GCP BackendBucket version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,46 +61,46 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - bucketName: - description: - - Cloud Storage bucket name. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional textual description of the resource; provided by the client when the - resource is created. - returned: success - type: str - enableCdn: - description: - - If true, enable Cloud CDN for this BackendBucket. - returned: success - type: bool - id: - description: - - Unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + bucketName: + description: + - Cloud Storage bucket name. + returned: success + type: str + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional textual description of the resource; provided by the client when + the resource is created. + returned: success + type: str + enableCdn: + description: + - If true, enable Cloud CDN for this BackendBucket. + returned: success + type: bool + id: + description: + - Unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str ''' ################################################################################ @@ -122,7 +121,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_service.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_service.py index 56c77ac556..6f69be8da6 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_backend_service.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_backend_service.py @@ -32,248 +32,271 @@ DOCUMENTATION = ''' --- module: gcp_compute_backend_service description: - - Creates a BackendService resource in the specified project using the data included - in the request. +- Creates a BackendService resource in the specified project using the data included + in the request. short_description: Creates a GCP BackendService version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - affinity_cookie_ttl_sec: - description: - - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set to - 0, the cookie is non-persistent and lasts only until the end of the browser session - (or equivalent). The maximum allowed value for TTL is one day. - - When the load balancing scheme is INTERNAL, this field is not used. - required: false - backends: - description: - - The list of backends that serve this BackendService. - required: false - suboptions: - balancing_mode: - description: - - Specifies the balancing mode for this backend. - - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. Valid - values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). - - This cannot be used for internal load balancing. - required: false - choices: ['UTILIZATION', 'RATE', 'CONNECTION'] - capacity_scaler: - description: - - A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION, - RATE or CONNECTION). - - Default value is 1, which means the group will serve up to 100% of its configured - capacity (depending on balancingMode). A setting of 0 means the group is completely - drained, offering 0% of its available Capacity. Valid range is [0.0,1.0]. - - This cannot be used for internal load balancing. - required: false - description: - description: - - An optional description of this resource. - - Provide this property when you create the resource. - required: false - group: - description: - - This instance group defines the list of instances that serve traffic. Member virtual - machine instances from each instance group must live in the same zone as the instance - group itself. - - No two backends in a backend service are allowed to use same Instance Group resource. - - When the BackendService has load balancing scheme INTERNAL, the instance group must - be in a zone within the same region as the BackendService. - - 'This field represents a link to a InstanceGroup resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_instance_group - task and then set this group field to "{{ name-of-resource }}" Alternatively, you - can set this group to a dictionary with the selfLink key where the value is the - selfLink of your InstanceGroup.' - required: false - max_connections: - description: - - The max number of simultaneous connections for the group. Can be used with either - CONNECTION or UTILIZATION balancing modes. - - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be - set. - - This cannot be used for internal load balancing. - required: false - max_connections_per_instance: - description: - - The max number of simultaneous connections that a single backend instance can handle. - This is used to calculate the capacity of the group. Can be used in either CONNECTION - or UTILIZATION balancing modes. - - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be - set. - - This cannot be used for internal load balancing. - required: false - max_rate: - description: - - The max requests per second (RPS) of the group. - - Can be used with either RATE or UTILIZATION balancing modes, but required if RATE - mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - - This cannot be used for internal load balancing. - required: false - max_rate_per_instance: - description: - - The max requests per second (RPS) that a single backend instance can handle. This - is used to calculate the capacity of the group. Can be used in either balancing - mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - - This cannot be used for internal load balancing. - required: false - max_utilization: - description: - - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization target - for the group. The default is 0.8. Valid range is [0.0, 1.0]. - - This cannot be used for internal load balancing. - required: false - cdn_policy: - description: - - Cloud CDN configuration for this BackendService. - required: false - suboptions: - cache_key_policy: - description: - - The CacheKeyPolicy for this CdnPolicy. - required: false - suboptions: - include_host: - description: - - If true requests to different hosts will be cached separately. - required: false - type: bool - include_protocol: - description: - - If true, http and https requests will be cached separately. - required: false - type: bool - include_query_string: - description: - - If true, include query string parameters in the cache key according to query_string_whitelist - and query_string_blacklist. If neither is set, the entire query string will be included. - - If false, the query string will be excluded from the cache key entirely. - required: false - type: bool - query_string_blacklist: - description: - - Names of query string parameters to exclude in cache keys. - - All other parameters will be included. Either specify query_string_whitelist or - query_string_blacklist, not both. - - "'&' and '=' will be percent encoded and not treated as delimiters." - required: false - query_string_whitelist: - description: - - Names of query string parameters to include in cache keys. - - All other parameters will be excluded. Either specify query_string_whitelist or - query_string_blacklist, not both. - - "'&' and '=' will be percent encoded and not treated as delimiters." - required: false - connection_draining: - description: - - Settings for connection draining. - required: false - suboptions: - draining_timeout_sec: - description: - - Time for which instance will be drained (not accept new connections, but still work - to finish started). - required: false + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + affinity_cookie_ttl_sec: + description: + - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set + to 0, the cookie is non-persistent and lasts only until the end of the browser + session (or equivalent). The maximum allowed value for TTL is one day. + - When the load balancing scheme is INTERNAL, this field is not used. + required: false + backends: + description: + - The list of backends that serve this BackendService. + required: false + suboptions: + balancing_mode: description: - - An optional description of this resource. + - Specifies the balancing mode for this backend. + - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. + Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). + - This cannot be used for internal load balancing. required: false - enable_cdn: + choices: + - UTILIZATION + - RATE + - CONNECTION + capacity_scaler: description: - - If true, enable Cloud CDN for this BackendService. - - When the load balancing scheme is INTERNAL, this field is not used. + - A multiplier applied to the group's maximum servicing capacity (based on + UTILIZATION, RATE or CONNECTION). + - Default value is 1, which means the group will serve up to 100% of its configured + capacity (depending on balancingMode). A setting of 0 means the group is + completely drained, offering 0% of its available Capacity. Valid range is + [0.0,1.0]. + - This cannot be used for internal load balancing. + required: false + description: + description: + - An optional description of this resource. + - Provide this property when you create the resource. + required: false + group: + description: + - This instance group defines the list of instances that serve traffic. Member + virtual machine instances from each instance group must live in the same + zone as the instance group itself. + - No two backends in a backend service are allowed to use same Instance Group + resource. + - When the BackendService has load balancing scheme INTERNAL, the instance + group must be in a zone within the same region as the BackendService. + - 'This field represents a link to a InstanceGroup resource in GCP. It can + be specified in two ways. You can add `register: name-of-resource` to a + gcp_compute_instance_group task and then set this group field to "{{ name-of-resource + }}" Alternatively, you can set this group to a dictionary with the selfLink + key where the value is the selfLink of your InstanceGroup' + required: false + max_connections: + description: + - The max number of simultaneous connections for the group. Can be used with + either CONNECTION or UTILIZATION balancing modes. + - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance + must be set. + - This cannot be used for internal load balancing. + required: false + max_connections_per_instance: + description: + - The max number of simultaneous connections that a single backend instance + can handle. This is used to calculate the capacity of the group. Can be + used in either CONNECTION or UTILIZATION balancing modes. + - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance + must be set. + - This cannot be used for internal load balancing. + required: false + max_rate: + description: + - The max requests per second (RPS) of the group. + - Can be used with either RATE or UTILIZATION balancing modes, but required + if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be + set. + - This cannot be used for internal load balancing. + required: false + max_rate_per_instance: + description: + - The max requests per second (RPS) that a single backend instance can handle. + This is used to calculate the capacity of the group. Can be used in either + balancing mode. For RATE mode, either maxRate or maxRatePerInstance must + be set. + - This cannot be used for internal load balancing. + required: false + max_utilization: + description: + - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization + target for the group. The default is 0.8. Valid range is [0.0, 1.0]. + - This cannot be used for internal load balancing. + required: false + cdn_policy: + description: + - Cloud CDN configuration for this BackendService. + required: false + suboptions: + cache_key_policy: + description: + - The CacheKeyPolicy for this CdnPolicy. + required: false + suboptions: + include_host: + description: + - If true requests to different hosts will be cached separately. + required: false + type: bool + include_protocol: + description: + - If true, http and https requests will be cached separately. + required: false + type: bool + include_query_string: + description: + - If true, include query string parameters in the cache key according + to query_string_whitelist and query_string_blacklist. If neither is + set, the entire query string will be included. + - If false, the query string will be excluded from the cache key entirely. + required: false + type: bool + query_string_blacklist: + description: + - Names of query string parameters to exclude in cache keys. + - All other parameters will be included. Either specify query_string_whitelist + or query_string_blacklist, not both. + - "'&' and '=' will be percent encoded and not treated as delimiters." + required: false + query_string_whitelist: + description: + - Names of query string parameters to include in cache keys. + - All other parameters will be excluded. Either specify query_string_whitelist + or query_string_blacklist, not both. + - "'&' and '=' will be percent encoded and not treated as delimiters." + required: false + connection_draining: + description: + - Settings for connection draining. + required: false + suboptions: + draining_timeout_sec: + description: + - Time for which instance will be drained (not accept new connections, but + still work to finish started). + required: false + description: + description: + - An optional description of this resource. + required: false + enable_cdn: + description: + - If true, enable Cloud CDN for this BackendService. + - When the load balancing scheme is INTERNAL, this field is not used. + required: false + type: bool + health_checks: + description: + - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health + checking this BackendService. Currently at most one health check can be specified, + and a health check is required. + - For internal load balancing, a URL to a HealthCheck resource must be specified + instead. + required: false + iap: + description: + - Settings for enabling Cloud Identity Aware Proxy. + required: false + version_added: 2.7 + suboptions: + enabled: + description: + - Enables IAP. required: false type: bool - health_checks: + oauth2_client_id: description: - - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health - checking this BackendService. Currently at most one health check can be specified, - and a health check is required. - - For internal load balancing, a URL to a HealthCheck resource must be specified instead. + - OAuth2 Client ID for IAP. required: false - iap: + oauth2_client_secret: description: - - Settings for enabling Cloud Identity Aware Proxy. + - OAuth2 Client Secret for IAP. required: false - version_added: 2.7 - suboptions: - enabled: - description: - - Enables IAP. - required: false - type: bool - oauth2_client_id: - description: - - OAuth2 Client ID for IAP. - required: false - oauth2_client_secret: - description: - - OAuth2 Client Secret for IAP. - required: false - oauth2_client_secret_sha256: - description: - - OAuth2 Client Secret SHA-256 for IAP. - required: false - load_balancing_scheme: + oauth2_client_secret_sha256: description: - - Indicates whether the backend service will be used with internal or external load - balancing. A backend service created for one type of load balancing cannot be used - with the other. + - OAuth2 Client Secret SHA-256 for IAP. required: false - version_added: 2.7 - choices: ['INTERNAL', 'EXTERNAL'] - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: false - port_name: - description: - - Name of backend port. The same name should appear in the instance groups referenced - by this service. Required when the load balancing scheme is EXTERNAL. - - When the load balancing scheme is INTERNAL, this field is not used. - required: false - protocol: - description: - - The protocol this BackendService uses to communicate with backends. - - Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. - - For internal load balancing, the possible values are TCP and UDP, and the default - is TCP. - required: false - choices: ['HTTP', 'HTTPS', 'TCP', 'SSL'] - region: - description: - - The region where the regional backend service resides. - - This field is not applicable to global backend services. - required: false - session_affinity: - description: - - Type of session affinity to use. The default is NONE. - - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. - - When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, - or CLIENT_IP_PORT_PROTO. - - When the protocol is UDP, this field is not used. - required: false - choices: ['NONE', 'CLIENT_IP', 'GENERATED_COOKIE', 'CLIENT_IP_PROTO', 'CLIENT_IP_PORT_PROTO'] - timeout_sec: - description: - - How many seconds to wait for the backend before considering it a failed request. - Default is 30 seconds. Valid range is [1, 86400]. - required: false - aliases: [timeout_seconds] + load_balancing_scheme: + description: + - Indicates whether the backend service will be used with internal or external + load balancing. A backend service created for one type of load balancing cannot + be used with the other. + required: false + version_added: 2.7 + choices: + - INTERNAL + - EXTERNAL + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: false + port_name: + description: + - Name of backend port. The same name should appear in the instance groups referenced + by this service. Required when the load balancing scheme is EXTERNAL. + - When the load balancing scheme is INTERNAL, this field is not used. + required: false + protocol: + description: + - The protocol this BackendService uses to communicate with backends. + - Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. + - For internal load balancing, the possible values are TCP and UDP, and the default + is TCP. + required: false + choices: + - HTTP + - HTTPS + - TCP + - SSL + region: + description: + - The region where the regional backend service resides. + - This field is not applicable to global backend services. + required: false + session_affinity: + description: + - Type of session affinity to use. The default is NONE. + - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. + - When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, + or CLIENT_IP_PORT_PROTO. + - When the protocol is UDP, this field is not used. + required: false + choices: + - NONE + - CLIENT_IP + - GENERATED_COOKIE + - CLIENT_IP_PROTO + - CLIENT_IP_PORT_PROTO + timeout_sec: + description: + - How many seconds to wait for the backend before considering it a failed request. + Default is 30 seconds. Valid range is [1, 86400]. + required: false + aliases: + - timeout_seconds extends_documentation_fragment: gcp ''' @@ -316,261 +339,266 @@ EXAMPLES = ''' ''' RETURN = ''' - affinityCookieTtlSec: - description: - - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set to - 0, the cookie is non-persistent and lasts only until the end of the browser session - (or equivalent). The maximum allowed value for TTL is one day. - - When the load balancing scheme is INTERNAL, this field is not used. - returned: success - type: int - backends: - description: - - The list of backends that serve this BackendService. - returned: success - type: complex - contains: - balancingMode: - description: - - Specifies the balancing mode for this backend. - - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. Valid - values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). - - This cannot be used for internal load balancing. - returned: success - type: str - capacityScaler: - description: - - A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION, - RATE or CONNECTION). - - Default value is 1, which means the group will serve up to 100% of its configured - capacity (depending on balancingMode). A setting of 0 means the group is completely - drained, offering 0% of its available Capacity. Valid range is [0.0,1.0]. - - This cannot be used for internal load balancing. - returned: success - type: str - description: - description: - - An optional description of this resource. - - Provide this property when you create the resource. - returned: success - type: str - group: - description: - - This instance group defines the list of instances that serve traffic. Member virtual - machine instances from each instance group must live in the same zone as the instance - group itself. - - No two backends in a backend service are allowed to use same Instance Group resource. - - When the BackendService has load balancing scheme INTERNAL, the instance group must - be in a zone within the same region as the BackendService. - returned: success - type: dict - maxConnections: - description: - - The max number of simultaneous connections for the group. Can be used with either - CONNECTION or UTILIZATION balancing modes. - - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be - set. - - This cannot be used for internal load balancing. - returned: success - type: int - maxConnectionsPerInstance: - description: - - The max number of simultaneous connections that a single backend instance can handle. - This is used to calculate the capacity of the group. Can be used in either CONNECTION - or UTILIZATION balancing modes. - - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be - set. - - This cannot be used for internal load balancing. - returned: success - type: int - maxRate: - description: - - The max requests per second (RPS) of the group. - - Can be used with either RATE or UTILIZATION balancing modes, but required if RATE - mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - - This cannot be used for internal load balancing. - returned: success - type: int - maxRatePerInstance: - description: - - The max requests per second (RPS) that a single backend instance can handle. This - is used to calculate the capacity of the group. Can be used in either balancing - mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - - This cannot be used for internal load balancing. - returned: success - type: str - maxUtilization: - description: - - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization target - for the group. The default is 0.8. Valid range is [0.0, 1.0]. - - This cannot be used for internal load balancing. - returned: success - type: str - cdnPolicy: - description: - - Cloud CDN configuration for this BackendService. - returned: success - type: complex - contains: - cacheKeyPolicy: - description: - - The CacheKeyPolicy for this CdnPolicy. - returned: success - type: complex - contains: - includeHost: - description: - - If true requests to different hosts will be cached separately. - returned: success - type: bool - includeProtocol: - description: - - If true, http and https requests will be cached separately. - returned: success - type: bool - includeQueryString: - description: - - If true, include query string parameters in the cache key according to query_string_whitelist - and query_string_blacklist. If neither is set, the entire query string will be included. - - If false, the query string will be excluded from the cache key entirely. - returned: success - type: bool - queryStringBlacklist: - description: - - Names of query string parameters to exclude in cache keys. - - All other parameters will be included. Either specify query_string_whitelist or - query_string_blacklist, not both. - - "'&' and '=' will be percent encoded and not treated as delimiters." - returned: success - type: list - queryStringWhitelist: - description: - - Names of query string parameters to include in cache keys. - - All other parameters will be excluded. Either specify query_string_whitelist or - query_string_blacklist, not both. - - "'&' and '=' will be percent encoded and not treated as delimiters." - returned: success - type: list - connectionDraining: - description: - - Settings for connection draining. - returned: success - type: complex - contains: - drainingTimeoutSec: - description: - - Time for which instance will be drained (not accept new connections, but still work - to finish started). - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str +affinityCookieTtlSec: + description: + - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set + to 0, the cookie is non-persistent and lasts only until the end of the browser + session (or equivalent). The maximum allowed value for TTL is one day. + - When the load balancing scheme is INTERNAL, this field is not used. + returned: success + type: int +backends: + description: + - The list of backends that serve this BackendService. + returned: success + type: complex + contains: + balancingMode: + description: + - Specifies the balancing mode for this backend. + - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. + Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). + - This cannot be used for internal load balancing. + returned: success + type: str + capacityScaler: + description: + - A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION, + RATE or CONNECTION). + - Default value is 1, which means the group will serve up to 100% of its configured + capacity (depending on balancingMode). A setting of 0 means the group is completely + drained, offering 0% of its available Capacity. Valid range is [0.0,1.0]. + - This cannot be used for internal load balancing. + returned: success + type: str description: - description: - - An optional description of this resource. - returned: success - type: str - enableCDN: - description: - - If true, enable Cloud CDN for this BackendService. - - When the load balancing scheme is INTERNAL, this field is not used. - returned: success - type: bool - healthChecks: - description: - - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health - checking this BackendService. Currently at most one health check can be specified, - and a health check is required. - - For internal load balancing, a URL to a HealthCheck resource must be specified instead. - returned: success - type: list - id: - description: - - The unique identifier for the resource. - returned: success - type: int - iap: - description: - - Settings for enabling Cloud Identity Aware Proxy. - returned: success - type: complex - contains: - enabled: - description: - - Enables IAP. - returned: success - type: bool - oauth2ClientId: - description: - - OAuth2 Client ID for IAP. - returned: success - type: str - oauth2ClientSecret: - description: - - OAuth2 Client Secret for IAP. - returned: success - type: str - oauth2ClientSecretSha256: - description: - - OAuth2 Client Secret SHA-256 for IAP. - returned: success - type: str - loadBalancingScheme: - description: - - Indicates whether the backend service will be used with internal or external load - balancing. A backend service created for one type of load balancing cannot be used - with the other. - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - portName: - description: - - Name of backend port. The same name should appear in the instance groups referenced - by this service. Required when the load balancing scheme is EXTERNAL. - - When the load balancing scheme is INTERNAL, this field is not used. - returned: success - type: str - protocol: - description: - - The protocol this BackendService uses to communicate with backends. - - Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. - - For internal load balancing, the possible values are TCP and UDP, and the default - is TCP. - returned: success - type: str - region: - description: - - The region where the regional backend service resides. - - This field is not applicable to global backend services. - returned: success - type: str - sessionAffinity: - description: - - Type of session affinity to use. The default is NONE. - - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. - - When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, - or CLIENT_IP_PORT_PROTO. - - When the protocol is UDP, this field is not used. - returned: success - type: str - timeoutSec: - description: - - How many seconds to wait for the backend before considering it a failed request. - Default is 30 seconds. Valid range is [1, 86400]. - returned: success - type: int + description: + - An optional description of this resource. + - Provide this property when you create the resource. + returned: success + type: str + group: + description: + - This instance group defines the list of instances that serve traffic. Member + virtual machine instances from each instance group must live in the same zone + as the instance group itself. + - No two backends in a backend service are allowed to use same Instance Group + resource. + - When the BackendService has load balancing scheme INTERNAL, the instance group + must be in a zone within the same region as the BackendService. + returned: success + type: dict + maxConnections: + description: + - The max number of simultaneous connections for the group. Can be used with + either CONNECTION or UTILIZATION balancing modes. + - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must + be set. + - This cannot be used for internal load balancing. + returned: success + type: int + maxConnectionsPerInstance: + description: + - The max number of simultaneous connections that a single backend instance + can handle. This is used to calculate the capacity of the group. Can be used + in either CONNECTION or UTILIZATION balancing modes. + - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must + be set. + - This cannot be used for internal load balancing. + returned: success + type: int + maxRate: + description: + - The max requests per second (RPS) of the group. + - Can be used with either RATE or UTILIZATION balancing modes, but required + if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be + set. + - This cannot be used for internal load balancing. + returned: success + type: int + maxRatePerInstance: + description: + - The max requests per second (RPS) that a single backend instance can handle. + This is used to calculate the capacity of the group. Can be used in either + balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be + set. + - This cannot be used for internal load balancing. + returned: success + type: str + maxUtilization: + description: + - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization + target for the group. The default is 0.8. Valid range is [0.0, 1.0]. + - This cannot be used for internal load balancing. + returned: success + type: str +cdnPolicy: + description: + - Cloud CDN configuration for this BackendService. + returned: success + type: complex + contains: + cacheKeyPolicy: + description: + - The CacheKeyPolicy for this CdnPolicy. + returned: success + type: complex + contains: + includeHost: + description: + - If true requests to different hosts will be cached separately. + returned: success + type: bool + includeProtocol: + description: + - If true, http and https requests will be cached separately. + returned: success + type: bool + includeQueryString: + description: + - If true, include query string parameters in the cache key according to + query_string_whitelist and query_string_blacklist. If neither is set, + the entire query string will be included. + - If false, the query string will be excluded from the cache key entirely. + returned: success + type: bool + queryStringBlacklist: + description: + - Names of query string parameters to exclude in cache keys. + - All other parameters will be included. Either specify query_string_whitelist + or query_string_blacklist, not both. + - "'&' and '=' will be percent encoded and not treated as delimiters." + returned: success + type: list + queryStringWhitelist: + description: + - Names of query string parameters to include in cache keys. + - All other parameters will be excluded. Either specify query_string_whitelist + or query_string_blacklist, not both. + - "'&' and '=' will be percent encoded and not treated as delimiters." + returned: success + type: list +connectionDraining: + description: + - Settings for connection draining. + returned: success + type: complex + contains: + drainingTimeoutSec: + description: + - Time for which instance will be drained (not accept new connections, but still + work to finish started). + returned: success + type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +enableCDN: + description: + - If true, enable Cloud CDN for this BackendService. + - When the load balancing scheme is INTERNAL, this field is not used. + returned: success + type: bool +healthChecks: + description: + - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health + checking this BackendService. Currently at most one health check can be specified, + and a health check is required. + - For internal load balancing, a URL to a HealthCheck resource must be specified + instead. + returned: success + type: list +id: + description: + - The unique identifier for the resource. + returned: success + type: int +iap: + description: + - Settings for enabling Cloud Identity Aware Proxy. + returned: success + type: complex + contains: + enabled: + description: + - Enables IAP. + returned: success + type: bool + oauth2ClientId: + description: + - OAuth2 Client ID for IAP. + returned: success + type: str + oauth2ClientSecret: + description: + - OAuth2 Client Secret for IAP. + returned: success + type: str + oauth2ClientSecretSha256: + description: + - OAuth2 Client Secret SHA-256 for IAP. + returned: success + type: str +loadBalancingScheme: + description: + - Indicates whether the backend service will be used with internal or external load + balancing. A backend service created for one type of load balancing cannot be + used with the other. + returned: success + type: str +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +portName: + description: + - Name of backend port. The same name should appear in the instance groups referenced + by this service. Required when the load balancing scheme is EXTERNAL. + - When the load balancing scheme is INTERNAL, this field is not used. + returned: success + type: str +protocol: + description: + - The protocol this BackendService uses to communicate with backends. + - Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. + - For internal load balancing, the possible values are TCP and UDP, and the default + is TCP. + returned: success + type: str +region: + description: + - The region where the regional backend service resides. + - This field is not applicable to global backend services. + returned: success + type: str +sessionAffinity: + description: + - Type of session affinity to use. The default is NONE. + - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. + - When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, + or CLIENT_IP_PORT_PROTO. + - When the protocol is UDP, this field is not used. + returned: success + type: str +timeoutSec: + description: + - How many seconds to wait for the backend before considering it a failed request. + Default is 30 seconds. Valid range is [1, 86400]. + returned: success + type: int ''' ################################################################################ @@ -687,8 +715,8 @@ def resource_to_request(module): u'kind': 'compute#backendService', u'affinityCookieTtlSec': module.params.get('affinity_cookie_ttl_sec'), u'backends': BackendServiceBackendsArray(module.params.get('backends', []), module).to_request(), - u'cdnPolicy': BackendServiceCdnPolicy(module.params.get('cdn_policy', {}), module).to_request(), - u'connectionDraining': BackendServiceConnectionDraining(module.params.get('connection_draining', {}), module).to_request(), + u'cdnPolicy': BackendServiceCdnpolicy(module.params.get('cdn_policy', {}), module).to_request(), + u'connectionDraining': BackendServiceConnectiondraining(module.params.get('connection_draining', {}), module).to_request(), u'description': module.params.get('description'), u'enableCDN': module.params.get('enable_cdn'), u'healthChecks': module.params.get('health_checks'), @@ -767,8 +795,8 @@ def response_to_hash(module, response): return { u'affinityCookieTtlSec': response.get(u'affinityCookieTtlSec'), u'backends': BackendServiceBackendsArray(response.get(u'backends', []), module).from_response(), - u'cdnPolicy': BackendServiceCdnPolicy(response.get(u'cdnPolicy', {}), module).from_response(), - u'connectionDraining': BackendServiceConnectionDraining(response.get(u'connectionDraining', {}), module).from_response(), + u'cdnPolicy': BackendServiceCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(), + u'connectionDraining': BackendServiceConnectiondraining(response.get(u'connectionDraining', {}), module).from_response(), u'creationTimestamp': response.get(u'creationTimestamp'), u'description': response.get(u'description'), u'enableCDN': response.get(u'enableCDN'), @@ -818,8 +846,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -878,7 +904,7 @@ class BackendServiceBackendsArray(object): }) -class BackendServiceCdnPolicy(object): +class BackendServiceCdnpolicy(object): def __init__(self, request, module): self.module = module if request: @@ -888,16 +914,16 @@ class BackendServiceCdnPolicy(object): def to_request(self): return remove_nones_from_dict({ - u'cacheKeyPolicy': BackendServiceCacheKeyPolicy(self.request.get('cache_key_policy', {}), self.module).to_request() + u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request() }) def from_response(self): return remove_nones_from_dict({ - u'cacheKeyPolicy': BackendServiceCacheKeyPolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response() + u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response() }) -class BackendServiceCacheKeyPolicy(object): +class BackendServiceCachekeypolicy(object): def __init__(self, request, module): self.module = module if request: @@ -924,7 +950,7 @@ class BackendServiceCacheKeyPolicy(object): }) -class BackendServiceConnectionDraining(object): +class BackendServiceConnectiondraining(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_service_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_service_facts.py index c303c75686..e6d7feaa91 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_backend_service_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_backend_service_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_backend_service_facts description: - - Gather facts for GCP BackendService +- Gather facts for GCP BackendService short_description: Gather facts for GCP BackendService version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,265 +61,272 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - affinityCookieTtlSec: - description: - - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set to - 0, the cookie is non-persistent and lasts only until the end of the browser session - (or equivalent). The maximum allowed value for TTL is one day. - - When the load balancing scheme is INTERNAL, this field is not used. - returned: success - type: int - backends: - description: - - The list of backends that serve this BackendService. - returned: success - type: complex - contains: - balancingMode: - description: - - Specifies the balancing mode for this backend. - - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. Valid - values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). - - This cannot be used for internal load balancing. - returned: success - type: str - capacityScaler: - description: - - A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION, - RATE or CONNECTION). - - Default value is 1, which means the group will serve up to 100% of its configured - capacity (depending on balancingMode). A setting of 0 means the group is completely - drained, offering 0% of its available Capacity. Valid range is [0.0,1.0]. - - This cannot be used for internal load balancing. - returned: success - type: str - description: - description: - - An optional description of this resource. - - Provide this property when you create the resource. - returned: success - type: str - group: - description: - - This instance group defines the list of instances that serve traffic. Member virtual - machine instances from each instance group must live in the same zone as the instance - group itself. - - No two backends in a backend service are allowed to use same Instance Group resource. - - When the BackendService has load balancing scheme INTERNAL, the instance group must - be in a zone within the same region as the BackendService. - returned: success - type: dict - maxConnections: - description: - - The max number of simultaneous connections for the group. Can be used with either - CONNECTION or UTILIZATION balancing modes. - - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be - set. - - This cannot be used for internal load balancing. - returned: success - type: int - maxConnectionsPerInstance: - description: - - The max number of simultaneous connections that a single backend instance can handle. - This is used to calculate the capacity of the group. Can be used in either CONNECTION - or UTILIZATION balancing modes. - - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must be - set. - - This cannot be used for internal load balancing. - returned: success - type: int - maxRate: - description: - - The max requests per second (RPS) of the group. - - Can be used with either RATE or UTILIZATION balancing modes, but required if RATE - mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - - This cannot be used for internal load balancing. - returned: success - type: int - maxRatePerInstance: - description: - - The max requests per second (RPS) that a single backend instance can handle. This - is used to calculate the capacity of the group. Can be used in either balancing - mode. For RATE mode, either maxRate or maxRatePerInstance must be set. - - This cannot be used for internal load balancing. - returned: success - type: str - maxUtilization: - description: - - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization target - for the group. The default is 0.8. Valid range is [0.0, 1.0]. - - This cannot be used for internal load balancing. - returned: success - type: str - cdnPolicy: - description: - - Cloud CDN configuration for this BackendService. - returned: success - type: complex - contains: - cacheKeyPolicy: - description: - - The CacheKeyPolicy for this CdnPolicy. - returned: success - type: complex - contains: - includeHost: - description: - - If true requests to different hosts will be cached separately. - returned: success - type: bool - includeProtocol: - description: - - If true, http and https requests will be cached separately. - returned: success - type: bool - includeQueryString: - description: - - If true, include query string parameters in the cache key according to query_string_whitelist - and query_string_blacklist. If neither is set, the entire query string will be included. - - If false, the query string will be excluded from the cache key entirely. - returned: success - type: bool - queryStringBlacklist: - description: - - Names of query string parameters to exclude in cache keys. - - All other parameters will be included. Either specify query_string_whitelist or - query_string_blacklist, not both. - - "'&' and '=' will be percent encoded and not treated as delimiters." - returned: success - type: list - queryStringWhitelist: - description: - - Names of query string parameters to include in cache keys. - - All other parameters will be excluded. Either specify query_string_whitelist or - query_string_blacklist, not both. - - "'&' and '=' will be percent encoded and not treated as delimiters." - returned: success - type: list - connectionDraining: - description: - - Settings for connection draining. - returned: success - type: complex - contains: - drainingTimeoutSec: - description: - - Time for which instance will be drained (not accept new connections, but still work - to finish started). - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + affinityCookieTtlSec: + description: + - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If + set to 0, the cookie is non-persistent and lasts only until the end of the + browser session (or equivalent). The maximum allowed value for TTL is one + day. + - When the load balancing scheme is INTERNAL, this field is not used. + returned: success + type: int + backends: + description: + - The list of backends that serve this BackendService. + returned: success + type: complex + contains: + balancingMode: + description: + - Specifies the balancing mode for this backend. + - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. + Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). + - This cannot be used for internal load balancing. + returned: success + type: str + capacityScaler: + description: + - A multiplier applied to the group's maximum servicing capacity (based + on UTILIZATION, RATE or CONNECTION). + - Default value is 1, which means the group will serve up to 100% of its + configured capacity (depending on balancingMode). A setting of 0 means + the group is completely drained, offering 0% of its available Capacity. + Valid range is [0.0,1.0]. + - This cannot be used for internal load balancing. + returned: success + type: str description: - description: - - An optional description of this resource. - returned: success - type: str - enableCDN: - description: - - If true, enable Cloud CDN for this BackendService. - - When the load balancing scheme is INTERNAL, this field is not used. - returned: success - type: bool - healthChecks: - description: - - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health - checking this BackendService. Currently at most one health check can be specified, - and a health check is required. - - For internal load balancing, a URL to a HealthCheck resource must be specified instead. - returned: success - type: list - id: - description: - - The unique identifier for the resource. - returned: success - type: int - iap: - description: - - Settings for enabling Cloud Identity Aware Proxy. - returned: success - type: complex - contains: - enabled: - description: - - Enables IAP. - returned: success - type: bool - oauth2ClientId: - description: - - OAuth2 Client ID for IAP. - returned: success - type: str - oauth2ClientSecret: - description: - - OAuth2 Client Secret for IAP. - returned: success - type: str - oauth2ClientSecretSha256: - description: - - OAuth2 Client Secret SHA-256 for IAP. - returned: success - type: str - loadBalancingScheme: - description: - - Indicates whether the backend service will be used with internal or external load - balancing. A backend service created for one type of load balancing cannot be used - with the other. - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - portName: - description: - - Name of backend port. The same name should appear in the instance groups referenced - by this service. Required when the load balancing scheme is EXTERNAL. - - When the load balancing scheme is INTERNAL, this field is not used. - returned: success - type: str - protocol: - description: - - The protocol this BackendService uses to communicate with backends. - - Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. - - For internal load balancing, the possible values are TCP and UDP, and the default - is TCP. - returned: success - type: str - region: - description: - - The region where the regional backend service resides. - - This field is not applicable to global backend services. - returned: success - type: str - sessionAffinity: - description: - - Type of session affinity to use. The default is NONE. - - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. - - When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, - or CLIENT_IP_PORT_PROTO. - - When the protocol is UDP, this field is not used. - returned: success - type: str - timeoutSec: - description: - - How many seconds to wait for the backend before considering it a failed request. - Default is 30 seconds. Valid range is [1, 86400]. - returned: success - type: int + description: + - An optional description of this resource. + - Provide this property when you create the resource. + returned: success + type: str + group: + description: + - This instance group defines the list of instances that serve traffic. + Member virtual machine instances from each instance group must live in + the same zone as the instance group itself. + - No two backends in a backend service are allowed to use same Instance + Group resource. + - When the BackendService has load balancing scheme INTERNAL, the instance + group must be in a zone within the same region as the BackendService. + returned: success + type: dict + maxConnections: + description: + - The max number of simultaneous connections for the group. Can be used + with either CONNECTION or UTILIZATION balancing modes. + - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance + must be set. + - This cannot be used for internal load balancing. + returned: success + type: int + maxConnectionsPerInstance: + description: + - The max number of simultaneous connections that a single backend instance + can handle. This is used to calculate the capacity of the group. Can be + used in either CONNECTION or UTILIZATION balancing modes. + - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance + must be set. + - This cannot be used for internal load balancing. + returned: success + type: int + maxRate: + description: + - The max requests per second (RPS) of the group. + - Can be used with either RATE or UTILIZATION balancing modes, but required + if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must + be set. + - This cannot be used for internal load balancing. + returned: success + type: int + maxRatePerInstance: + description: + - The max requests per second (RPS) that a single backend instance can handle. + This is used to calculate the capacity of the group. Can be used in either + balancing mode. For RATE mode, either maxRate or maxRatePerInstance must + be set. + - This cannot be used for internal load balancing. + returned: success + type: str + maxUtilization: + description: + - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization + target for the group. The default is 0.8. Valid range is [0.0, 1.0]. + - This cannot be used for internal load balancing. + returned: success + type: str + cdnPolicy: + description: + - Cloud CDN configuration for this BackendService. + returned: success + type: complex + contains: + cacheKeyPolicy: + description: + - The CacheKeyPolicy for this CdnPolicy. + returned: success + type: complex + contains: + includeHost: + description: + - If true requests to different hosts will be cached separately. + returned: success + type: bool + includeProtocol: + description: + - If true, http and https requests will be cached separately. + returned: success + type: bool + includeQueryString: + description: + - If true, include query string parameters in the cache key according + to query_string_whitelist and query_string_blacklist. If neither is + set, the entire query string will be included. + - If false, the query string will be excluded from the cache key entirely. + returned: success + type: bool + queryStringBlacklist: + description: + - Names of query string parameters to exclude in cache keys. + - All other parameters will be included. Either specify query_string_whitelist + or query_string_blacklist, not both. + - "'&' and '=' will be percent encoded and not treated as delimiters." + returned: success + type: list + queryStringWhitelist: + description: + - Names of query string parameters to include in cache keys. + - All other parameters will be excluded. Either specify query_string_whitelist + or query_string_blacklist, not both. + - "'&' and '=' will be percent encoded and not treated as delimiters." + returned: success + type: list + connectionDraining: + description: + - Settings for connection draining. + returned: success + type: complex + contains: + drainingTimeoutSec: + description: + - Time for which instance will be drained (not accept new connections, but + still work to finish started). + returned: success + type: int + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + enableCDN: + description: + - If true, enable Cloud CDN for this BackendService. + - When the load balancing scheme is INTERNAL, this field is not used. + returned: success + type: bool + healthChecks: + description: + - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health + checking this BackendService. Currently at most one health check can be specified, + and a health check is required. + - For internal load balancing, a URL to a HealthCheck resource must be specified + instead. + returned: success + type: list + id: + description: + - The unique identifier for the resource. + returned: success + type: int + iap: + description: + - Settings for enabling Cloud Identity Aware Proxy. + returned: success + type: complex + contains: + enabled: + description: + - Enables IAP. + returned: success + type: bool + oauth2ClientId: + description: + - OAuth2 Client ID for IAP. + returned: success + type: str + oauth2ClientSecret: + description: + - OAuth2 Client Secret for IAP. + returned: success + type: str + oauth2ClientSecretSha256: + description: + - OAuth2 Client Secret SHA-256 for IAP. + returned: success + type: str + loadBalancingScheme: + description: + - Indicates whether the backend service will be used with internal or external + load balancing. A backend service created for one type of load balancing cannot + be used with the other. + returned: success + type: str + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + portName: + description: + - Name of backend port. The same name should appear in the instance groups referenced + by this service. Required when the load balancing scheme is EXTERNAL. + - When the load balancing scheme is INTERNAL, this field is not used. + returned: success + type: str + protocol: + description: + - The protocol this BackendService uses to communicate with backends. + - Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. + - For internal load balancing, the possible values are TCP and UDP, and the + default is TCP. + returned: success + type: str + region: + description: + - The region where the regional backend service resides. + - This field is not applicable to global backend services. + returned: success + type: str + sessionAffinity: + description: + - Type of session affinity to use. The default is NONE. + - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. + - When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO, + or CLIENT_IP_PORT_PROTO. + - When the protocol is UDP, this field is not used. + returned: success + type: str + timeoutSec: + description: + - How many seconds to wait for the backend before considering it a failed request. + Default is 30 seconds. Valid range is [1, 86400]. + returned: success + type: int ''' ################################################################################ @@ -341,7 +347,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_disk.py b/lib/ansible/modules/cloud/google/gcp_compute_disk.py index ff840386d2..c8156e2db4 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_disk.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_disk.py @@ -32,155 +32,156 @@ DOCUMENTATION = ''' --- module: gcp_compute_disk description: - - Persistent disks are durable storage devices that function similarly to the physical - disks in a desktop or a server. Compute Engine manages the hardware behind these - devices to ensure data redundancy and optimize performance for you. Persistent disks - are available as either standard hard disk drives (HDD) or solid-state drives (SSD). - - Persistent disks are located independently from your virtual machine instances, - so you can detach or move persistent disks to keep your data even after you delete - your instances. Persistent disk performance scales automatically with size, so you - can resize your existing persistent disks or add more persistent disks to an instance - to meet your performance and storage space requirements. - - Add a persistent disk to your instance when you need reliable and affordable storage - with consistent performance characteristics. +- Persistent disks are durable storage devices that function similarly to the physical + disks in a desktop or a server. Compute Engine manages the hardware behind these + devices to ensure data redundancy and optimize performance for you. Persistent disks + are available as either standard hard disk drives (HDD) or solid-state drives (SSD). +- Persistent disks are located independently from your virtual machine instances, + so you can detach or move persistent disks to keep your data even after you delete + your instances. Persistent disk performance scales automatically with size, so you + can resize your existing persistent disks or add more persistent disks to an instance + to meet your performance and storage space requirements. +- Add a persistent disk to your instance when you need reliable and affordable storage + with consistent performance characteristics. short_description: Creates a GCP Disk version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + labels: + description: + - Labels to apply to this disk. A list of key->value pairs. + required: false + version_added: 2.7 + licenses: + description: + - Any applicable publicly visible licenses. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + size_gb: + description: + - Size of the persistent disk, specified in GB. You can specify this field when + creating a persistent disk using the sourceImage or sourceSnapshot parameter, + or specify it alone to create an empty persistent disk. + - If you specify this field along with sourceImage or sourceSnapshot, the value + of sizeGb must not be less than the size of the sourceImage or the size of the + snapshot. + required: false + type: + description: + - URL of the disk type resource describing which disk type to use to create the + disk. Provide this when creating the disk. + required: false + version_added: 2.7 + source_image: + description: + - The source image used to create this disk. If the source image is deleted, this + field will not be set. + - 'To create a disk with one of the public operating system images, specify the + image by its family name. For example, specify family/debian-8 to use the latest + Debian 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively, + use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD + To create a disk with a private image that you created, specify the image name + in the following format: global/images/my-private-image You can also specify + a private image by its image family, which returns the latest version of the + image in that family. Replace the image name with family/family-name: global/images/family/my-private-family + .' + required: false + zone: + description: + - A reference to the zone where the disk resides. + required: true + source_image_encryption_key: + description: + - The customer-supplied encryption key of the source image. Required if the source + image is protected by a customer-supplied encryption key. + required: false + suboptions: + raw_key: description: - - An optional description of this resource. Provide this property when you create - the resource. + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. required: false - labels: + sha256: description: - - Labels to apply to this disk. A list of key->value pairs. + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. required: false - version_added: 2.7 - licenses: + disk_encryption_key: + description: + - Encrypts the disk using a customer-supplied encryption key. + - After you encrypt a disk with a customer-supplied key, you must provide the + same key if you use the disk later (e.g. to create a disk snapshot or an image, + or to attach the disk to a virtual machine). + - Customer-supplied encryption keys do not protect access to metadata of the disk. + - If you do not provide an encryption key when creating the disk, then the disk + will be encrypted using an automatically generated key and you do not need to + provide a key to use the disk later. + required: false + suboptions: + raw_key: description: - - Any applicable publicly visible licenses. + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. required: false - name: + sha256: description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - size_gb: - description: - - Size of the persistent disk, specified in GB. You can specify this field when creating - a persistent disk using the sourceImage or sourceSnapshot parameter, or specify - it alone to create an empty persistent disk. - - If you specify this field along with sourceImage or sourceSnapshot, the value of - sizeGb must not be less than the size of the sourceImage or the size of the snapshot. + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. required: false - type: + source_snapshot: + description: + - The source snapshot used to create this disk. You can provide this as a partial + or full URL to the resource. + - 'This field represents a link to a Snapshot resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_snapshot + task and then set this source_snapshot field to "{{ name-of-resource }}" Alternatively, + you can set this source_snapshot to a dictionary with the selfLink key where + the value is the selfLink of your Snapshot' + required: false + source_snapshot_encryption_key: + description: + - The customer-supplied encryption key of the source snapshot. Required if the + source snapshot is protected by a customer-supplied encryption key. + required: false + suboptions: + raw_key: description: - - URL of the disk type resource describing which disk type to use to create the disk. - Provide this when creating the disk. + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. required: false - version_added: 2.7 - source_image: + sha256: description: - - The source image used to create this disk. If the source image is deleted, this - field will not be set. - - 'To create a disk with one of the public operating system images, specify the image - by its family name. For example, specify family/debian-8 to use the latest Debian - 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively, use - a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To - create a disk with a private image that you created, specify the image name in the - following format: global/images/my-private-image You can also specify a private - image by its image family, which returns the latest version of the image in that - family. Replace the image name with family/family-name: global/images/family/my-private-family - .' + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. required: false - zone: - description: - - A reference to the zone where the disk resides. - required: true - source_image_encryption_key: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - disk_encryption_key: - description: - - Encrypts the disk using a customer-supplied encryption key. - - After you encrypt a disk with a customer-supplied key, you must provide the same - key if you use the disk later (e.g. to create a disk snapshot or an image, or to - attach the disk to a virtual machine). - - Customer-supplied encryption keys do not protect access to metadata of the disk. - - If you do not provide an encryption key when creating the disk, then the disk will - be encrypted using an automatically generated key and you do not need to provide - a key to use the disk later. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - source_snapshot: - description: - - 'The source snapshot used to create this disk. You can provide this as a partial or - full URL to the resource. For example, the following are valid values: * - `U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`) - * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .' - - 'This field represents a link to a Snapshot resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_snapshot - task and then set this source_snapshot field to "{{ name-of-resource }}" Alternatively, - you can set this source_snapshot to a dictionary with the selfLink key where the - value is the selfLink of your Snapshot.' - required: false - source_snapshot_encryption_key: - description: - - The customer-supplied encryption key of the source snapshot. Required if the source - snapshot is protected by a customer-supplied encryption key. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/disks)" - - "Adding a persistent disk: U(https://cloud.google.com/compute/docs/disks/add-persistent-disk)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/disks)' +- 'Adding a persistent disk: U(https://cloud.google.com/compute/docs/disks/add-persistent-disk)' ''' EXAMPLES = ''' @@ -198,188 +199,187 @@ EXAMPLES = ''' ''' RETURN = ''' - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - lastAttachTimestamp: - description: - - Last attach timestamp in RFC3339 text format. - returned: success - type: str - lastDetachTimestamp: - description: - - Last dettach timestamp in RFC3339 text format. - returned: success - type: str - labels: - description: - - Labels to apply to this disk. A list of key->value pairs. - returned: success - type: dict - licenses: - description: - - Any applicable publicly visible licenses. - returned: success - type: list - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - sizeGb: - description: - - Size of the persistent disk, specified in GB. You can specify this field when creating - a persistent disk using the sourceImage or sourceSnapshot parameter, or specify - it alone to create an empty persistent disk. - - If you specify this field along with sourceImage or sourceSnapshot, the value of - sizeGb must not be less than the size of the sourceImage or the size of the snapshot. - returned: success - type: int - users: - description: - - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance - .' - returned: success - type: list - type: - description: - - URL of the disk type resource describing which disk type to use to create the disk. - Provide this when creating the disk. - returned: success - type: str - sourceImage: - description: - - The source image used to create this disk. If the source image is deleted, this - field will not be set. - - 'To create a disk with one of the public operating system images, specify the image - by its family name. For example, specify family/debian-8 to use the latest Debian - 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively, use - a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To - create a disk with a private image that you created, specify the image name in the - following format: global/images/my-private-image You can also specify a private - image by its image family, which returns the latest version of the image in that - family. Replace the image name with family/family-name: global/images/family/my-private-family - .' - returned: success - type: str - zone: - description: - - A reference to the zone where the disk resides. - returned: success - type: str - sourceImageEncryptionKey: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceImageId: - description: - - The ID value of the image used to create this disk. This value identifies the exact - image that was used to create this persistent disk. For example, if you created - the persistent disk from an image that was later deleted and recreated under the - same name, the source image ID would identify the exact version of the image that - was used. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts the disk using a customer-supplied encryption key. - - After you encrypt a disk with a customer-supplied key, you must provide the same - key if you use the disk later (e.g. to create a disk snapshot or an image, or to - attach the disk to a virtual machine). - - Customer-supplied encryption keys do not protect access to metadata of the disk. - - If you do not provide an encryption key when creating the disk, then the disk will - be encrypted using an automatically generated key and you do not need to provide - a key to use the disk later. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshot: - description: - - 'The source snapshot used to create this disk. You can provide this as a partial or - full URL to the resource. For example, the following are valid values: * - `U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`) - * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .' - returned: success - type: dict - sourceSnapshotEncryptionKey: - description: - - The customer-supplied encryption key of the source snapshot. Required if the source - snapshot is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshotId: - description: - - The unique ID of the snapshot used to create this disk. This value identifies the - exact snapshot that was used to create this persistent disk. For example, if you - created the persistent disk from a snapshot that was later deleted and recreated - under the same name, the source snapshot ID would identify the exact version of - the snapshot that was used. - returned: success - type: str +labelFingerprint: + description: + - The fingerprint used for optimistic locking of this resource. Used internally + during updates. + returned: success + type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +lastAttachTimestamp: + description: + - Last attach timestamp in RFC3339 text format. + returned: success + type: str +lastDetachTimestamp: + description: + - Last dettach timestamp in RFC3339 text format. + returned: success + type: str +labels: + description: + - Labels to apply to this disk. A list of key->value pairs. + returned: success + type: dict +licenses: + description: + - Any applicable publicly visible licenses. + returned: success + type: list +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +sizeGb: + description: + - Size of the persistent disk, specified in GB. You can specify this field when + creating a persistent disk using the sourceImage or sourceSnapshot parameter, + or specify it alone to create an empty persistent disk. + - If you specify this field along with sourceImage or sourceSnapshot, the value + of sizeGb must not be less than the size of the sourceImage or the size of the + snapshot. + returned: success + type: int +users: + description: + - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance + .' + returned: success + type: list +type: + description: + - URL of the disk type resource describing which disk type to use to create the + disk. Provide this when creating the disk. + returned: success + type: str +sourceImage: + description: + - The source image used to create this disk. If the source image is deleted, this + field will not be set. + - 'To create a disk with one of the public operating system images, specify the + image by its family name. For example, specify family/debian-8 to use the latest + Debian 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively, + use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD + To create a disk with a private image that you created, specify the image name + in the following format: global/images/my-private-image You can also specify a + private image by its image family, which returns the latest version of the image + in that family. Replace the image name with family/family-name: global/images/family/my-private-family + .' + returned: success + type: str +zone: + description: + - A reference to the zone where the disk resides. + returned: success + type: str +sourceImageEncryptionKey: + description: + - The customer-supplied encryption key of the source image. Required if the source + image is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str +sourceImageId: + description: + - The ID value of the image used to create this disk. This value identifies the + exact image that was used to create this persistent disk. For example, if you + created the persistent disk from an image that was later deleted and recreated + under the same name, the source image ID would identify the exact version of the + image that was used. + returned: success + type: str +diskEncryptionKey: + description: + - Encrypts the disk using a customer-supplied encryption key. + - After you encrypt a disk with a customer-supplied key, you must provide the same + key if you use the disk later (e.g. to create a disk snapshot or an image, or + to attach the disk to a virtual machine). + - Customer-supplied encryption keys do not protect access to metadata of the disk. + - If you do not provide an encryption key when creating the disk, then the disk + will be encrypted using an automatically generated key and you do not need to + provide a key to use the disk later. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str +sourceSnapshot: + description: + - The source snapshot used to create this disk. You can provide this as a partial + or full URL to the resource. + returned: success + type: dict +sourceSnapshotEncryptionKey: + description: + - The customer-supplied encryption key of the source snapshot. Required if the source + snapshot is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str +sourceSnapshotId: + description: + - The unique ID of the snapshot used to create this disk. This value identifies + the exact snapshot that was used to create this persistent disk. For example, + if you created the persistent disk from a snapshot that was later deleted and + recreated under the same name, the source snapshot ID would identify the exact + version of the snapshot that was used. + returned: success + type: str ''' ################################################################################ @@ -510,9 +510,9 @@ def delete(module, link, kind): def resource_to_request(module): request = { u'kind': 'compute#disk', - u'sourceImageEncryptionKey': DiskSourceImageEncryptionKey(module.params.get('source_image_encryption_key', {}), module).to_request(), - u'diskEncryptionKey': DiskDiskEncryptionKey(module.params.get('disk_encryption_key', {}), module).to_request(), - u'sourceSnapshotEncryptionKey': DiskSourceSnapshotEncryptionKey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(), + u'sourceImageEncryptionKey': DiskSourceimageencryptionkey(module.params.get('source_image_encryption_key', {}), module).to_request(), + u'diskEncryptionKey': DiskDiskencryptionkey(module.params.get('disk_encryption_key', {}), module).to_request(), + u'sourceSnapshotEncryptionKey': DiskSourcesnapshotencryptionkey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(), u'description': module.params.get('description'), u'labels': module.params.get('labels'), u'licenses': module.params.get('licenses'), @@ -634,8 +634,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -647,7 +645,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class DiskSourceImageEncryptionKey(object): +class DiskSourceimageencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -668,7 +666,7 @@ class DiskSourceImageEncryptionKey(object): }) -class DiskDiskEncryptionKey(object): +class DiskDiskencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -689,7 +687,7 @@ class DiskDiskEncryptionKey(object): }) -class DiskSourceSnapshotEncryptionKey(object): +class DiskSourcesnapshotencryptionkey(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_disk_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_disk_facts.py index 5c7795d013..bf5af4150c 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_disk_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_disk_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_disk_facts description: - - Gather facts for GCP Disk +- Gather facts for GCP Disk short_description: Gather facts for GCP Disk version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - zone: - description: - - A reference to the zone where the disk resides. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + zone: + description: + - A reference to the zone where the disk resides. + required: true extends_documentation_fragment: gcp ''' @@ -67,192 +66,193 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - lastAttachTimestamp: - description: - - Last attach timestamp in RFC3339 text format. - returned: success - type: str - lastDetachTimestamp: - description: - - Last dettach timestamp in RFC3339 text format. - returned: success - type: str - labels: - description: - - Labels to apply to this disk. A list of key->value pairs. - returned: success - type: dict - licenses: - description: - - Any applicable publicly visible licenses. - returned: success - type: list - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - sizeGb: - description: - - Size of the persistent disk, specified in GB. You can specify this field when creating - a persistent disk using the sourceImage or sourceSnapshot parameter, or specify - it alone to create an empty persistent disk. - - If you specify this field along with sourceImage or sourceSnapshot, the value of - sizeGb must not be less than the size of the sourceImage or the size of the snapshot. - returned: success - type: int - users: - description: - - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance - .' - returned: success - type: list - type: - description: - - URL of the disk type resource describing which disk type to use to create the disk. - Provide this when creating the disk. - returned: success - type: str - sourceImage: - description: - - The source image used to create this disk. If the source image is deleted, this - field will not be set. - - 'To create a disk with one of the public operating system images, specify the image - by its family name. For example, specify family/debian-8 to use the latest Debian - 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively, use - a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To - create a disk with a private image that you created, specify the image name in the - following format: global/images/my-private-image You can also specify a private - image by its image family, which returns the latest version of the image in that - family. Replace the image name with family/family-name: global/images/family/my-private-family - .' - returned: success - type: str - zone: - description: - - A reference to the zone where the disk resides. - returned: success - type: str - sourceImageEncryptionKey: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceImageId: - description: - - The ID value of the image used to create this disk. This value identifies the exact - image that was used to create this persistent disk. For example, if you created - the persistent disk from an image that was later deleted and recreated under the - same name, the source image ID would identify the exact version of the image that - was used. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts the disk using a customer-supplied encryption key. - - After you encrypt a disk with a customer-supplied key, you must provide the same - key if you use the disk later (e.g. to create a disk snapshot or an image, or to - attach the disk to a virtual machine). - - Customer-supplied encryption keys do not protect access to metadata of the disk. - - If you do not provide an encryption key when creating the disk, then the disk will - be encrypted using an automatically generated key and you do not need to provide - a key to use the disk later. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshot: - description: - - 'The source snapshot used to create this disk. You can provide this as a partial - or full URL to the resource. For example, the following are valid values: * - `U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`) - * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .' - returned: success - type: dict - sourceSnapshotEncryptionKey: - description: - - The customer-supplied encryption key of the source snapshot. Required if the source - snapshot is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshotId: - description: - - The unique ID of the snapshot used to create this disk. This value identifies the - exact snapshot that was used to create this persistent disk. For example, if you - created the persistent disk from a snapshot that was later deleted and recreated - under the same name, the source snapshot ID would identify the exact version of - the snapshot that was used. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + labelFingerprint: + description: + - The fingerprint used for optimistic locking of this resource. Used internally + during updates. + returned: success + type: str + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + lastAttachTimestamp: + description: + - Last attach timestamp in RFC3339 text format. + returned: success + type: str + lastDetachTimestamp: + description: + - Last dettach timestamp in RFC3339 text format. + returned: success + type: str + labels: + description: + - Labels to apply to this disk. A list of key->value pairs. + returned: success + type: dict + licenses: + description: + - Any applicable publicly visible licenses. + returned: success + type: list + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + sizeGb: + description: + - Size of the persistent disk, specified in GB. You can specify this field when + creating a persistent disk using the sourceImage or sourceSnapshot parameter, + or specify it alone to create an empty persistent disk. + - If you specify this field along with sourceImage or sourceSnapshot, the value + of sizeGb must not be less than the size of the sourceImage or the size of + the snapshot. + returned: success + type: int + users: + description: + - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance + .' + returned: success + type: list + type: + description: + - URL of the disk type resource describing which disk type to use to create + the disk. Provide this when creating the disk. + returned: success + type: str + sourceImage: + description: + - The source image used to create this disk. If the source image is deleted, + this field will not be set. + - 'To create a disk with one of the public operating system images, specify + the image by its family name. For example, specify family/debian-8 to use + the latest Debian 8 image: projects/debian-cloud/global/images/family/debian-8 + Alternatively, use a specific version of a public operating system image: + projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To create a + disk with a private image that you created, specify the image name in the + following format: global/images/my-private-image You can also specify a private + image by its image family, which returns the latest version of the image in + that family. Replace the image name with family/family-name: global/images/family/my-private-family + .' + returned: success + type: str + zone: + description: + - A reference to the zone where the disk resides. + returned: success + type: str + sourceImageEncryptionKey: + description: + - The customer-supplied encryption key of the source image. Required if the + source image is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + sourceImageId: + description: + - The ID value of the image used to create this disk. This value identifies + the exact image that was used to create this persistent disk. For example, + if you created the persistent disk from an image that was later deleted and + recreated under the same name, the source image ID would identify the exact + version of the image that was used. + returned: success + type: str + diskEncryptionKey: + description: + - Encrypts the disk using a customer-supplied encryption key. + - After you encrypt a disk with a customer-supplied key, you must provide the + same key if you use the disk later (e.g. to create a disk snapshot or an image, + or to attach the disk to a virtual machine). + - Customer-supplied encryption keys do not protect access to metadata of the + disk. + - If you do not provide an encryption key when creating the disk, then the disk + will be encrypted using an automatically generated key and you do not need + to provide a key to use the disk later. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + sourceSnapshot: + description: + - The source snapshot used to create this disk. You can provide this as a partial + or full URL to the resource. + returned: success + type: dict + sourceSnapshotEncryptionKey: + description: + - The customer-supplied encryption key of the source snapshot. Required if the + source snapshot is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + sourceSnapshotId: + description: + - The unique ID of the snapshot used to create this disk. This value identifies + the exact snapshot that was used to create this persistent disk. For example, + if you created the persistent disk from a snapshot that was later deleted + and recreated under the same name, the source snapshot ID would identify the + exact version of the snapshot that was used. + returned: success + type: str ''' ################################################################################ @@ -274,7 +274,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_firewall.py b/lib/ansible/modules/cloud/google/gcp_compute_firewall.py index 09fcadb93f..f75f16bdf3 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_firewall.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_firewall.py @@ -32,182 +32,190 @@ DOCUMENTATION = ''' --- module: gcp_compute_firewall description: - - Each network has its own firewall controlling access to and from the instances. - - All traffic to instances, even from other instances, is blocked by the firewall - unless firewall rules are created to allow it. - - The default network has automatically created firewall rules that are shown in default - firewall rules. No manually created network has automatically created firewall rules - except for a default "allow" rule for outgoing traffic and a default "deny" for - incoming traffic. For all networks except the default network, you must create any - firewall rules you need. +- Each network has its own firewall controlling access to and from the instances. +- All traffic to instances, even from other instances, is blocked by the firewall + unless firewall rules are created to allow it. +- The default network has automatically created firewall rules that are shown in default + firewall rules. No manually created network has automatically created firewall rules + except for a default "allow" rule for outgoing traffic and a default "deny" for + incoming traffic. For all networks except the default network, you must create any + firewall rules you need. short_description: Creates a GCP Firewall version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - allowed: - description: - - The list of ALLOW rules specified by this firewall. Each rule specifies a protocol - and port-range tuple that describes a permitted connection. - required: false - suboptions: - ip_protocol: - description: - - The IP protocol to which this rule applies. The protocol type is required when creating - a firewall rule. This value can either be one of the following well known protocol - strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. - required: true - ports: - description: - - An optional list of ports to which this rule applies. This field is only applicable - for UDP or TCP protocol. Each entry must be either an integer or a range. If not - specified, this rule applies to connections through any port. - - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' - required: false - denied: - description: - - The list of DENY rules specified by this firewall. Each rule specifies a protocol - and port-range tuple that describes a denied connection. - required: false - version_added: 2.8 - suboptions: - ip_protocol: - description: - - The IP protocol to which this rule applies. The protocol type is required when creating - a firewall rule. This value can either be one of the following well known protocol - strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. - required: true - ports: - description: - - An optional list of ports to which this rule applies. This field is only applicable - for UDP or TCP protocol. Each entry must be either an integer or a range. If not - specified, this rule applies to connections through any port. - - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' - required: false + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + allowed: + description: + - The list of ALLOW rules specified by this firewall. Each rule specifies a protocol + and port-range tuple that describes a permitted connection. + required: false + suboptions: + ip_protocol: description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - destination_ranges: - description: - - If destination ranges are specified, the firewall will apply only to traffic that - has destination IP address in these ranges. These ranges must be expressed in CIDR - format. Only IPv4 is supported. - required: false - version_added: 2.8 - direction: - description: - - 'Direction of traffic to which this firewall applies; default is INGRESS. Note: - For INGRESS traffic, it is NOT supported to specify destinationRanges; For EGRESS - traffic, it is NOT supported to specify sourceRanges OR sourceTags.' - required: false - version_added: 2.8 - choices: ['INGRESS', 'EGRESS'] - disabled: - description: - - Denotes whether the firewall rule is disabled, i.e not applied to the network it - is associated with. When set to true, the firewall rule is not enforced and the - network behaves as if it did not exist. If this is unspecified, the firewall rule - will be enabled. - required: false - type: bool - version_added: 2.8 - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. + - The IP protocol to which this rule applies. The protocol type is required + when creating a firewall rule. This value can either be one of the following + well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol + number. required: true - network: + ports: description: - - 'URL of the network resource for this firewall rule. If not specified when creating - a firewall rule, the default network is used: global/networks/default If you choose to - specify this property, you can specify the network as a full or partial URL. For - example, the following are all valid URLs: - U(https://www.googleapis.com/compute/v1/projects/myproject/global/) - networks/my-network projects/myproject/global/networks/my-network - global/networks/default .' - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' + - An optional list of ports to which this rule applies. This field is only + applicable for UDP or TCP protocol. Each entry must be either an integer + or a range. If not specified, this rule applies to connections through any + port. + - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' + required: false + denied: + description: + - The list of DENY rules specified by this firewall. Each rule specifies a protocol + and port-range tuple that describes a denied connection. + required: false + version_added: 2.8 + suboptions: + ip_protocol: + description: + - The IP protocol to which this rule applies. The protocol type is required + when creating a firewall rule. This value can either be one of the following + well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol + number. required: true - priority: + ports: description: - - Priority for this rule. This is an integer between 0 and 65535, both inclusive. - When not specified, the value assumed is 1000. Relative priorities determine precedence - of conflicting rules. Lower value of priority implies higher precedence (eg, a rule - with priority 0 has higher precedence than a rule with priority 1). DENY rules take - precedence over ALLOW rules having equal priority. - required: false - default: 1000 - version_added: 2.8 - source_ranges: - description: - - If source ranges are specified, the firewall will apply only to traffic that has - source IP address in these ranges. These ranges must be expressed in CIDR format. - One or both of sourceRanges and sourceTags may be set. If both properties are set, - the firewall will apply to traffic that has source IP address within sourceRanges - OR the source IP that belongs to a tag listed in the sourceTags property. The connection - does not need to match both properties for the firewall to apply. Only IPv4 is supported. - required: false - source_service_accounts: - description: - - If source service accounts are specified, the firewall will apply only to traffic - originating from an instance with a service account in this list. Source service - accounts cannot be used to control traffic to an instance's external IP address - because service accounts are associated with an instance, not an IP address. sourceRanges - can be set at the same time as sourceServiceAccounts. If both are set, the firewall - will apply to traffic that has source IP address within sourceRanges OR the source - IP belongs to an instance with service account listed in sourceServiceAccount. The - connection does not need to match both properties for the firewall to apply. sourceServiceAccounts - cannot be used at the same time as sourceTags or targetTags. - required: false - version_added: 2.8 - source_tags: - description: - - If source tags are specified, the firewall will apply only to traffic with source - IP that belongs to a tag listed in source tags. Source tags cannot be used to control - traffic to an instance's external IP address. Because tags are associated with an - instance, not an IP address. One or both of sourceRanges and sourceTags may be set. - If both properties are set, the firewall will apply to traffic that has source IP - address within sourceRanges OR the source IP that belongs to a tag listed in the - sourceTags property. The connection does not need to match both properties for the - firewall to apply. - required: false - target_service_accounts: - description: - - A list of service accounts indicating sets of instances located in the network that - may make network connections as specified in allowed[]. - - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags. - If neither targetServiceAccounts nor targetTags are specified, the firewall rule - applies to all instances on the specified network. - required: false - version_added: 2.8 - target_tags: - description: - - A list of instance tags indicating sets of instances located in the network that - may make network connections as specified in allowed[]. - - If no targetTags are specified, the firewall rule applies to all instances on the - specified network. + - An optional list of ports to which this rule applies. This field is only + applicable for UDP or TCP protocol. Each entry must be either an integer + or a range. If not specified, this rule applies to connections through any + port. + - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' required: false + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + destination_ranges: + description: + - If destination ranges are specified, the firewall will apply only to traffic + that has destination IP address in these ranges. These ranges must be expressed + in CIDR format. Only IPv4 is supported. + required: false + version_added: 2.8 + direction: + description: + - 'Direction of traffic to which this firewall applies; default is INGRESS. Note: + For INGRESS traffic, it is NOT supported to specify destinationRanges; For EGRESS + traffic, it is NOT supported to specify sourceRanges OR sourceTags.' + required: false + version_added: 2.8 + choices: + - INGRESS + - EGRESS + disabled: + description: + - Denotes whether the firewall rule is disabled, i.e not applied to the network + it is associated with. When set to true, the firewall rule is not enforced and + the network behaves as if it did not exist. If this is unspecified, the firewall + rule will be enabled. + required: false + type: bool + version_added: 2.8 + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + network: + description: + - 'URL of the network resource for this firewall rule. If not specified when creating + a firewall rule, the default network is used: global/networks/default If you + choose to specify this property, you can specify the network as a full or partial + URL. For example, the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/myproject/global/) + networks/my-network projects/myproject/global/networks/my-network global/networks/default + .' + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: true + priority: + description: + - Priority for this rule. This is an integer between 0 and 65535, both inclusive. + When not specified, the value assumed is 1000. Relative priorities determine + precedence of conflicting rules. Lower value of priority implies higher precedence + (eg, a rule with priority 0 has higher precedence than a rule with priority + 1). DENY rules take precedence over ALLOW rules having equal priority. + required: false + default: '1000' + version_added: 2.8 + source_ranges: + description: + - If source ranges are specified, the firewall will apply only to traffic that + has source IP address in these ranges. These ranges must be expressed in CIDR + format. One or both of sourceRanges and sourceTags may be set. If both properties + are set, the firewall will apply to traffic that has source IP address within + sourceRanges OR the source IP that belongs to a tag listed in the sourceTags + property. The connection does not need to match both properties for the firewall + to apply. Only IPv4 is supported. + required: false + source_service_accounts: + description: + - If source service accounts are specified, the firewall will apply only to traffic + originating from an instance with a service account in this list. Source service + accounts cannot be used to control traffic to an instance's external IP address + because service accounts are associated with an instance, not an IP address. + sourceRanges can be set at the same time as sourceServiceAccounts. If both are + set, the firewall will apply to traffic that has source IP address within sourceRanges + OR the source IP belongs to an instance with service account listed in sourceServiceAccount. + The connection does not need to match both properties for the firewall to apply. + sourceServiceAccounts cannot be used at the same time as sourceTags or targetTags. + required: false + version_added: 2.8 + source_tags: + description: + - If source tags are specified, the firewall will apply only to traffic with source + IP that belongs to a tag listed in source tags. Source tags cannot be used to + control traffic to an instance's external IP address. Because tags are associated + with an instance, not an IP address. One or both of sourceRanges and sourceTags + may be set. If both properties are set, the firewall will apply to traffic that + has source IP address within sourceRanges OR the source IP that belongs to a + tag listed in the sourceTags property. The connection does not need to match + both properties for the firewall to apply. + required: false + target_service_accounts: + description: + - A list of service accounts indicating sets of instances located in the network + that may make network connections as specified in allowed[]. + - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags. + If neither targetServiceAccounts nor targetTags are specified, the firewall + rule applies to all instances on the specified network. + required: false + version_added: 2.8 + target_tags: + description: + - A list of instance tags indicating sets of instances located in the network + that may make network connections as specified in allowed[]. + - If no targetTags are specified, the firewall rule applies to all instances on + the specified network. + required: false extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/firewalls)" - - "Official Documentation: U(https://cloud.google.com/vpc/docs/firewalls)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/firewalls)' +- 'Official Documentation: U(https://cloud.google.com/vpc/docs/firewalls)' ''' EXAMPLES = ''' @@ -230,170 +238,172 @@ EXAMPLES = ''' ''' RETURN = ''' - allowed: - description: - - The list of ALLOW rules specified by this firewall. Each rule specifies a protocol - and port-range tuple that describes a permitted connection. - returned: success - type: complex - contains: - ip_protocol: - description: - - The IP protocol to which this rule applies. The protocol type is required when creating - a firewall rule. This value can either be one of the following well known protocol - strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. - returned: success - type: str - ports: - description: - - An optional list of ports to which this rule applies. This field is only applicable - for UDP or TCP protocol. Each entry must be either an integer or a range. If not - specified, this rule applies to connections through any port. - - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' - returned: success - type: list - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - denied: - description: - - The list of DENY rules specified by this firewall. Each rule specifies a protocol - and port-range tuple that describes a denied connection. - returned: success - type: complex - contains: - ip_protocol: - description: - - The IP protocol to which this rule applies. The protocol type is required when creating - a firewall rule. This value can either be one of the following well known protocol - strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. - returned: success - type: str - ports: - description: - - An optional list of ports to which this rule applies. This field is only applicable - for UDP or TCP protocol. Each entry must be either an integer or a range. If not - specified, this rule applies to connections through any port. - - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' - returned: success - type: list - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - destinationRanges: - description: - - If destination ranges are specified, the firewall will apply only to traffic that - has destination IP address in these ranges. These ranges must be expressed in CIDR - format. Only IPv4 is supported. - returned: success - type: list - direction: - description: - - 'Direction of traffic to which this firewall applies; default is INGRESS. Note: - For INGRESS traffic, it is NOT supported to specify destinationRanges; For EGRESS - traffic, it is NOT supported to specify sourceRanges OR sourceTags.' - returned: success - type: str - disabled: - description: - - Denotes whether the firewall rule is disabled, i.e not applied to the network it - is associated with. When set to true, the firewall rule is not enforced and the - network behaves as if it did not exist. If this is unspecified, the firewall rule - will be enabled. - returned: success - type: bool - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - 'URL of the network resource for this firewall rule. If not specified when creating - a firewall rule, the default network is used: global/networks/default If you choose to - specify this property, you can specify the network as a full or partial URL. For - example, the following are all valid URLs: - U(https://www.googleapis.com/compute/v1/projects/myproject/global/) - networks/my-network projects/myproject/global/networks/my-network - global/networks/default .' - returned: success - type: dict - priority: - description: - - Priority for this rule. This is an integer between 0 and 65535, both inclusive. - When not specified, the value assumed is 1000. Relative priorities determine precedence - of conflicting rules. Lower value of priority implies higher precedence (eg, a rule - with priority 0 has higher precedence than a rule with priority 1). DENY rules take - precedence over ALLOW rules having equal priority. - returned: success - type: int - sourceRanges: - description: - - If source ranges are specified, the firewall will apply only to traffic that has - source IP address in these ranges. These ranges must be expressed in CIDR format. - One or both of sourceRanges and sourceTags may be set. If both properties are set, - the firewall will apply to traffic that has source IP address within sourceRanges - OR the source IP that belongs to a tag listed in the sourceTags property. The connection - does not need to match both properties for the firewall to apply. Only IPv4 is supported. - returned: success - type: list - sourceServiceAccounts: - description: - - If source service accounts are specified, the firewall will apply only to traffic - originating from an instance with a service account in this list. Source service - accounts cannot be used to control traffic to an instance's external IP address - because service accounts are associated with an instance, not an IP address. sourceRanges - can be set at the same time as sourceServiceAccounts. If both are set, the firewall - will apply to traffic that has source IP address within sourceRanges OR the source - IP belongs to an instance with service account listed in sourceServiceAccount. The - connection does not need to match both properties for the firewall to apply. sourceServiceAccounts - cannot be used at the same time as sourceTags or targetTags. - returned: success - type: list - sourceTags: - description: - - If source tags are specified, the firewall will apply only to traffic with source - IP that belongs to a tag listed in source tags. Source tags cannot be used to control - traffic to an instance's external IP address. Because tags are associated with an - instance, not an IP address. One or both of sourceRanges and sourceTags may be set. - If both properties are set, the firewall will apply to traffic that has source IP - address within sourceRanges OR the source IP that belongs to a tag listed in the - sourceTags property. The connection does not need to match both properties for the - firewall to apply. - returned: success - type: list - targetServiceAccounts: - description: - - A list of service accounts indicating sets of instances located in the network that - may make network connections as specified in allowed[]. - - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags. - If neither targetServiceAccounts nor targetTags are specified, the firewall rule - applies to all instances on the specified network. - returned: success - type: list - targetTags: - description: - - A list of instance tags indicating sets of instances located in the network that - may make network connections as specified in allowed[]. - - If no targetTags are specified, the firewall rule applies to all instances on the - specified network. - returned: success - type: list +allowed: + description: + - The list of ALLOW rules specified by this firewall. Each rule specifies a protocol + and port-range tuple that describes a permitted connection. + returned: success + type: complex + contains: + ip_protocol: + description: + - The IP protocol to which this rule applies. The protocol type is required + when creating a firewall rule. This value can either be one of the following + well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol + number. + returned: success + type: str + ports: + description: + - An optional list of ports to which this rule applies. This field is only applicable + for UDP or TCP protocol. Each entry must be either an integer or a range. + If not specified, this rule applies to connections through any port. + - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' + returned: success + type: list +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +denied: + description: + - The list of DENY rules specified by this firewall. Each rule specifies a protocol + and port-range tuple that describes a denied connection. + returned: success + type: complex + contains: + ip_protocol: + description: + - The IP protocol to which this rule applies. The protocol type is required + when creating a firewall rule. This value can either be one of the following + well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol + number. + returned: success + type: str + ports: + description: + - An optional list of ports to which this rule applies. This field is only applicable + for UDP or TCP protocol. Each entry must be either an integer or a range. + If not specified, this rule applies to connections through any port. + - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' + returned: success + type: list +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +destinationRanges: + description: + - If destination ranges are specified, the firewall will apply only to traffic that + has destination IP address in these ranges. These ranges must be expressed in + CIDR format. Only IPv4 is supported. + returned: success + type: list +direction: + description: + - 'Direction of traffic to which this firewall applies; default is INGRESS. Note: + For INGRESS traffic, it is NOT supported to specify destinationRanges; For EGRESS + traffic, it is NOT supported to specify sourceRanges OR sourceTags.' + returned: success + type: str +disabled: + description: + - Denotes whether the firewall rule is disabled, i.e not applied to the network + it is associated with. When set to true, the firewall rule is not enforced and + the network behaves as if it did not exist. If this is unspecified, the firewall + rule will be enabled. + returned: success + type: bool +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +network: + description: + - 'URL of the network resource for this firewall rule. If not specified when creating + a firewall rule, the default network is used: global/networks/default If you choose + to specify this property, you can specify the network as a full or partial URL. + For example, the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/myproject/global/) + networks/my-network projects/myproject/global/networks/my-network global/networks/default + .' + returned: success + type: dict +priority: + description: + - Priority for this rule. This is an integer between 0 and 65535, both inclusive. + When not specified, the value assumed is 1000. Relative priorities determine precedence + of conflicting rules. Lower value of priority implies higher precedence (eg, a + rule with priority 0 has higher precedence than a rule with priority 1). DENY + rules take precedence over ALLOW rules having equal priority. + returned: success + type: int +sourceRanges: + description: + - If source ranges are specified, the firewall will apply only to traffic that has + source IP address in these ranges. These ranges must be expressed in CIDR format. + One or both of sourceRanges and sourceTags may be set. If both properties are + set, the firewall will apply to traffic that has source IP address within sourceRanges + OR the source IP that belongs to a tag listed in the sourceTags property. The + connection does not need to match both properties for the firewall to apply. Only + IPv4 is supported. + returned: success + type: list +sourceServiceAccounts: + description: + - If source service accounts are specified, the firewall will apply only to traffic + originating from an instance with a service account in this list. Source service + accounts cannot be used to control traffic to an instance's external IP address + because service accounts are associated with an instance, not an IP address. sourceRanges + can be set at the same time as sourceServiceAccounts. If both are set, the firewall + will apply to traffic that has source IP address within sourceRanges OR the source + IP belongs to an instance with service account listed in sourceServiceAccount. + The connection does not need to match both properties for the firewall to apply. + sourceServiceAccounts cannot be used at the same time as sourceTags or targetTags. + returned: success + type: list +sourceTags: + description: + - If source tags are specified, the firewall will apply only to traffic with source + IP that belongs to a tag listed in source tags. Source tags cannot be used to + control traffic to an instance's external IP address. Because tags are associated + with an instance, not an IP address. One or both of sourceRanges and sourceTags + may be set. If both properties are set, the firewall will apply to traffic that + has source IP address within sourceRanges OR the source IP that belongs to a tag + listed in the sourceTags property. The connection does not need to match both + properties for the firewall to apply. + returned: success + type: list +targetServiceAccounts: + description: + - A list of service accounts indicating sets of instances located in the network + that may make network connections as specified in allowed[]. + - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags. + If neither targetServiceAccounts nor targetTags are specified, the firewall rule + applies to all instances on the specified network. + returned: success + type: list +targetTags: + description: + - A list of instance tags indicating sets of instances located in the network that + may make network connections as specified in allowed[]. + - If no targetTags are specified, the firewall rule applies to all instances on + the specified network. + returned: success + type: list ''' ################################################################################ @@ -609,8 +619,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_firewall_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_firewall_facts.py index 5fce2e9fba..1cc69b5d68 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_firewall_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_firewall_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_firewall_facts description: - - Gather facts for GCP Firewall +- Gather facts for GCP Firewall short_description: Gather facts for GCP Firewall version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,174 +61,179 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - allowed: - description: - - The list of ALLOW rules specified by this firewall. Each rule specifies a protocol - and port-range tuple that describes a permitted connection. - returned: success - type: complex - contains: - ip_protocol: - description: - - The IP protocol to which this rule applies. The protocol type is required when creating - a firewall rule. This value can either be one of the following well known protocol - strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. - returned: success - type: str - ports: - description: - - An optional list of ports to which this rule applies. This field is only applicable - for UDP or TCP protocol. Each entry must be either an integer or a range. If not - specified, this rule applies to connections through any port. - - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' - returned: success - type: list - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - denied: - description: - - The list of DENY rules specified by this firewall. Each rule specifies a protocol - and port-range tuple that describes a denied connection. - returned: success - type: complex - contains: - ip_protocol: - description: - - The IP protocol to which this rule applies. The protocol type is required when creating - a firewall rule. This value can either be one of the following well known protocol - strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol number. - returned: success - type: str - ports: - description: - - An optional list of ports to which this rule applies. This field is only applicable - for UDP or TCP protocol. Each entry must be either an integer or a range. If not - specified, this rule applies to connections through any port. - - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' - returned: success - type: list - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - destinationRanges: - description: - - If destination ranges are specified, the firewall will apply only to traffic that - has destination IP address in these ranges. These ranges must be expressed in CIDR - format. Only IPv4 is supported. - returned: success - type: list - direction: - description: - - 'Direction of traffic to which this firewall applies; default is INGRESS. Note: - For INGRESS traffic, it is NOT supported to specify destinationRanges; For EGRESS - traffic, it is NOT supported to specify sourceRanges OR sourceTags.' - returned: success - type: str - disabled: - description: - - Denotes whether the firewall rule is disabled, i.e not applied to the network it - is associated with. When set to true, the firewall rule is not enforced and the - network behaves as if it did not exist. If this is unspecified, the firewall rule - will be enabled. - returned: success - type: bool - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - 'URL of the network resource for this firewall rule. If not specified when - creating a firewall rule, the default network is used: global/networks/default If - you choose to specify this property, you can specify the network as a full or - partial URL. For example, the following are all valid URLs: - U(https://www.googleapis.com/compute/v1/projects/myproject/global/) - networks/my-network projects/myproject/global/networks/my-network - global/networks/default .' - returned: success - type: dict - priority: - description: - - Priority for this rule. This is an integer between 0 and 65535, both inclusive. - When not specified, the value assumed is 1000. Relative priorities determine precedence - of conflicting rules. Lower value of priority implies higher precedence (eg, a rule - with priority 0 has higher precedence than a rule with priority 1). DENY rules take - precedence over ALLOW rules having equal priority. - returned: success - type: int - sourceRanges: - description: - - If source ranges are specified, the firewall will apply only to traffic that has - source IP address in these ranges. These ranges must be expressed in CIDR format. - One or both of sourceRanges and sourceTags may be set. If both properties are set, - the firewall will apply to traffic that has source IP address within sourceRanges - OR the source IP that belongs to a tag listed in the sourceTags property. The connection - does not need to match both properties for the firewall to apply. Only IPv4 is supported. - returned: success - type: list - sourceServiceAccounts: - description: - - If source service accounts are specified, the firewall will apply only to traffic - originating from an instance with a service account in this list. Source service - accounts cannot be used to control traffic to an instance's external IP address - because service accounts are associated with an instance, not an IP address. sourceRanges - can be set at the same time as sourceServiceAccounts. If both are set, the firewall - will apply to traffic that has source IP address within sourceRanges OR the source - IP belongs to an instance with service account listed in sourceServiceAccount. The - connection does not need to match both properties for the firewall to apply. sourceServiceAccounts - cannot be used at the same time as sourceTags or targetTags. - returned: success - type: list - sourceTags: - description: - - If source tags are specified, the firewall will apply only to traffic with source - IP that belongs to a tag listed in source tags. Source tags cannot be used to control - traffic to an instance's external IP address. Because tags are associated with an - instance, not an IP address. One or both of sourceRanges and sourceTags may be set. - If both properties are set, the firewall will apply to traffic that has source IP - address within sourceRanges OR the source IP that belongs to a tag listed in the - sourceTags property. The connection does not need to match both properties for the - firewall to apply. - returned: success - type: list - targetServiceAccounts: - description: - - A list of service accounts indicating sets of instances located in the network that - may make network connections as specified in allowed[]. - - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags. - If neither targetServiceAccounts nor targetTags are specified, the firewall rule - applies to all instances on the specified network. - returned: success - type: list - targetTags: - description: - - A list of instance tags indicating sets of instances located in the network that - may make network connections as specified in allowed[]. - - If no targetTags are specified, the firewall rule applies to all instances on the - specified network. - returned: success - type: list + description: List of items + returned: always + type: complex + contains: + allowed: + description: + - The list of ALLOW rules specified by this firewall. Each rule specifies a + protocol and port-range tuple that describes a permitted connection. + returned: success + type: complex + contains: + ip_protocol: + description: + - The IP protocol to which this rule applies. The protocol type is required + when creating a firewall rule. This value can either be one of the following + well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP + protocol number. + returned: success + type: str + ports: + description: + - An optional list of ports to which this rule applies. This field is only + applicable for UDP or TCP protocol. Each entry must be either an integer + or a range. If not specified, this rule applies to connections through + any port. + - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' + returned: success + type: list + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + denied: + description: + - The list of DENY rules specified by this firewall. Each rule specifies a protocol + and port-range tuple that describes a denied connection. + returned: success + type: complex + contains: + ip_protocol: + description: + - The IP protocol to which this rule applies. The protocol type is required + when creating a firewall rule. This value can either be one of the following + well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP + protocol number. + returned: success + type: str + ports: + description: + - An optional list of ports to which this rule applies. This field is only + applicable for UDP or TCP protocol. Each entry must be either an integer + or a range. If not specified, this rule applies to connections through + any port. + - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].' + returned: success + type: list + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + destinationRanges: + description: + - If destination ranges are specified, the firewall will apply only to traffic + that has destination IP address in these ranges. These ranges must be expressed + in CIDR format. Only IPv4 is supported. + returned: success + type: list + direction: + description: + - 'Direction of traffic to which this firewall applies; default is INGRESS. + Note: For INGRESS traffic, it is NOT supported to specify destinationRanges; + For EGRESS traffic, it is NOT supported to specify sourceRanges OR sourceTags.' + returned: success + type: str + disabled: + description: + - Denotes whether the firewall rule is disabled, i.e not applied to the network + it is associated with. When set to true, the firewall rule is not enforced + and the network behaves as if it did not exist. If this is unspecified, the + firewall rule will be enabled. + returned: success + type: bool + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + network: + description: + - 'URL of the network resource for this firewall rule. If not specified when + creating a firewall rule, the default network is used: global/networks/default + If you choose to specify this property, you can specify the network as a full + or partial URL. For example, the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/myproject/global/) + networks/my-network projects/myproject/global/networks/my-network global/networks/default + .' + returned: success + type: dict + priority: + description: + - Priority for this rule. This is an integer between 0 and 65535, both inclusive. + When not specified, the value assumed is 1000. Relative priorities determine + precedence of conflicting rules. Lower value of priority implies higher precedence + (eg, a rule with priority 0 has higher precedence than a rule with priority + 1). DENY rules take precedence over ALLOW rules having equal priority. + returned: success + type: int + sourceRanges: + description: + - If source ranges are specified, the firewall will apply only to traffic that + has source IP address in these ranges. These ranges must be expressed in CIDR + format. One or both of sourceRanges and sourceTags may be set. If both properties + are set, the firewall will apply to traffic that has source IP address within + sourceRanges OR the source IP that belongs to a tag listed in the sourceTags + property. The connection does not need to match both properties for the firewall + to apply. Only IPv4 is supported. + returned: success + type: list + sourceServiceAccounts: + description: + - If source service accounts are specified, the firewall will apply only to + traffic originating from an instance with a service account in this list. + Source service accounts cannot be used to control traffic to an instance's + external IP address because service accounts are associated with an instance, + not an IP address. sourceRanges can be set at the same time as sourceServiceAccounts. + If both are set, the firewall will apply to traffic that has source IP address + within sourceRanges OR the source IP belongs to an instance with service account + listed in sourceServiceAccount. The connection does not need to match both + properties for the firewall to apply. sourceServiceAccounts cannot be used + at the same time as sourceTags or targetTags. + returned: success + type: list + sourceTags: + description: + - If source tags are specified, the firewall will apply only to traffic with + source IP that belongs to a tag listed in source tags. Source tags cannot + be used to control traffic to an instance's external IP address. Because tags + are associated with an instance, not an IP address. One or both of sourceRanges + and sourceTags may be set. If both properties are set, the firewall will apply + to traffic that has source IP address within sourceRanges OR the source IP + that belongs to a tag listed in the sourceTags property. The connection does + not need to match both properties for the firewall to apply. + returned: success + type: list + targetServiceAccounts: + description: + - A list of service accounts indicating sets of instances located in the network + that may make network connections as specified in allowed[]. + - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags. + If neither targetServiceAccounts nor targetTags are specified, the firewall + rule applies to all instances on the specified network. + returned: success + type: list + targetTags: + description: + - A list of instance tags indicating sets of instances located in the network + that may make network connections as specified in allowed[]. + - If no targetTags are specified, the firewall rule applies to all instances + on the specified network. + returned: success + type: list ''' ################################################################################ @@ -250,7 +254,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py index a712c5e709..9ba834304a 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py @@ -32,168 +32,185 @@ DOCUMENTATION = ''' --- module: gcp_compute_forwarding_rule description: - - A ForwardingRule resource. A ForwardingRule resource specifies which pool of target - virtual machines to forward a packet to if it matches the given [IPAddress, IPProtocol, - portRange] tuple. +- A ForwardingRule resource. A ForwardingRule resource specifies which pool of target + virtual machines to forward a packet to if it matches the given [IPAddress, IPProtocol, + portRange] tuple. short_description: Creates a GCP ForwardingRule version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - ip_address: - description: - - The IP address that this forwarding rule is serving on behalf of. - - Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL - or INTERNAL) and scope (global or regional). - - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address - must be a global IP, and for regional forwarding rules, the address must live in - the same region as the forwarding rule. If this field is empty, an ephemeral IPv4 - address from the same scope (global or regional) will be assigned. A regional forwarding - rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6. - - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address - belonging to the network/subnet configured for the forwarding rule. By default, - if this field is empty, an ephemeral internal IP address will be automatically allocated - from the IP range of the subnet or network configured for this forwarding rule. - - 'An address can be specified either by a literal IP address or a URL reference to - an existing Address resource. The following examples are all valid: * 100.1.2.3 - * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) - * projects/project/regions/region/addresses/address * regions/region/addresses/address - * global/addresses/address * address .' - required: false - ip_protocol: - description: - - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, - SCTP or ICMP. - - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. - required: false - choices: ['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP'] - backend_service: - description: - - A reference to a BackendService to receive the matched traffic. - - This is used for internal load balancing. - - "(not used for external load balancing) ." - - 'This field represents a link to a BackendService resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service - task and then set this backend_service field to "{{ name-of-resource }}" Alternatively, - you can set this backend_service to a dictionary with the selfLink key where the - value is the selfLink of your BackendService.' - required: false - ip_version: - description: - - The IP Version that will be used by this forwarding rule. Valid options are IPV4 - or IPV6. This can only be specified for a global forwarding rule. - required: false - choices: ['IPV4', 'IPV6'] - load_balancing_scheme: - description: - - 'This signifies what the ForwardingRule will be used for and can only take the following - values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for - Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this - will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) - .' - required: false - choices: ['INTERNAL', 'EXTERNAL'] - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - network: - description: - - For internal load balancing, this field identifies the network that the load balanced - IP should belong to for this Forwarding Rule. If this field is not specified, the - default network will be used. - - This field is not used for external load balancing. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: false - port_range: - description: - - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. - - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to - ports in the specified range will be forwarded to target. - - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port - ranges. - - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: - 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, - 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, - 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: - 500, 4500 .' - required: false - ports: - description: - - This field is used along with the backend_service field for internal load balancing. - - When the load balancing scheme is INTERNAL, a single port or a comma separated list - of ports can be configured. Only packets addressed to these ports will be forwarded - to the backends configured with this forwarding rule. - - You may specify a maximum of up to 5 ports. - required: false - subnetwork: - description: - - A reference to a subnetwork. - - For internal load balancing, this field identifies the subnetwork that the load - balanced IP should belong to for this Forwarding Rule. - - If the network specified is in auto subnet mode, this field is optional. However, - if the network is in custom subnet mode, a subnetwork must be specified. - - This field is not used for external load balancing. - - 'This field represents a link to a Subnetwork resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork - task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, - you can set this subnetwork to a dictionary with the selfLink key where the value - is the selfLink of your Subnetwork.' - required: false - target: - description: - - A reference to a TargetPool resource to receive the matched traffic. - - For regional forwarding rules, this target must live in the same region as the forwarding - rule. For global forwarding rules, this target must be a global load balancing resource. - The forwarded traffic must be of a type appropriate to the target object. - - This field is not used for internal load balancing. - - 'This field represents a link to a TargetPool resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_target_pool - task and then set this target field to "{{ name-of-resource }}" Alternatively, you - can set this target to a dictionary with the selfLink key where the value is the - selfLink of your TargetPool.' - required: false - version_added: 2.7 - network_tier: - description: - - 'The networking tier used for configuring this address. This field can take the - following values: PREMIUM or STANDARD. If this field is not specified, it is assumed - to be PREMIUM.' - required: false - version_added: 2.8 - choices: ['PREMIUM', 'STANDARD'] - region: - description: - - A reference to the region where the regional forwarding rule resides. - - This field is not applicable to global forwarding rules. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + ip_address: + description: + - The IP address that this forwarding rule is serving on behalf of. + - Addresses are restricted based on the forwarding rule's load balancing scheme + (EXTERNAL or INTERNAL) and scope (global or regional). + - When the load balancing scheme is EXTERNAL, for global forwarding rules, the + address must be a global IP, and for regional forwarding rules, the address + must live in the same region as the forwarding rule. If this field is empty, + an ephemeral IPv4 address from the same scope (global or regional) will be assigned. + A regional forwarding rule supports IPv4 only. A global forwarding rule supports + either IPv4 or IPv6. + - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP + address belonging to the network/subnet configured for the forwarding rule. + By default, if this field is empty, an ephemeral internal IP address will be + automatically allocated from the IP range of the subnet or network configured + for this forwarding rule. + - 'An address can be specified either by a literal IP address or a URL reference + to an existing Address resource. The following examples are all valid: * 100.1.2.3 + * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) + * projects/project/regions/region/addresses/address * regions/region/addresses/address + * global/addresses/address * address .' + required: false + ip_protocol: + description: + - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, + AH, SCTP or ICMP. + - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. + required: false + choices: + - TCP + - UDP + - ESP + - AH + - SCTP + - ICMP + backend_service: + description: + - A reference to a BackendService to receive the matched traffic. + - This is used for internal load balancing. + - "(not used for external load balancing) ." + - 'This field represents a link to a BackendService resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service + task and then set this backend_service field to "{{ name-of-resource }}" Alternatively, + you can set this backend_service to a dictionary with the selfLink key where + the value is the selfLink of your BackendService' + required: false + ip_version: + description: + - The IP Version that will be used by this forwarding rule. Valid options are + IPV4 or IPV6. This can only be specified for a global forwarding rule. + required: false + choices: + - IPV4 + - IPV6 + load_balancing_scheme: + description: + - 'This signifies what the ForwardingRule will be used for and can only take the + following values: INTERNAL, EXTERNAL The value of INTERNAL means that this will + be used for Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL + means that this will be used for External Load Balancing (HTTP(S) LB, External + TCP/UDP LB, SSL Proxy) .' + required: false + choices: + - INTERNAL + - EXTERNAL + name: + description: + - Name of the resource; provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + network: + description: + - For internal load balancing, this field identifies the network that the load + balanced IP should belong to for this Forwarding Rule. If this field is not + specified, the default network will be used. + - This field is not used for external load balancing. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: false + port_range: + description: + - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, + TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. + - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed + to ports in the specified range will be forwarded to target. + - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint + port ranges. + - 'Some types of forwarding target have constraints on the acceptable ports: * + TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, + 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, + 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: + 500, 4500 .' + required: false + ports: + description: + - This field is used along with the backend_service field for internal load balancing. + - When the load balancing scheme is INTERNAL, a single port or a comma separated + list of ports can be configured. Only packets addressed to these ports will + be forwarded to the backends configured with this forwarding rule. + - You may specify a maximum of up to 5 ports. + required: false + subnetwork: + description: + - A reference to a subnetwork. + - For internal load balancing, this field identifies the subnetwork that the load + balanced IP should belong to for this Forwarding Rule. + - If the network specified is in auto subnet mode, this field is optional. However, + if the network is in custom subnet mode, a subnetwork must be specified. + - This field is not used for external load balancing. + - 'This field represents a link to a Subnetwork resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork + task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, + you can set this subnetwork to a dictionary with the selfLink key where the + value is the selfLink of your Subnetwork' + required: false + target: + description: + - A reference to a TargetPool resource to receive the matched traffic. + - For regional forwarding rules, this target must live in the same region as the + forwarding rule. For global forwarding rules, this target must be a global load + balancing resource. The forwarded traffic must be of a type appropriate to the + target object. + - This field is not used for internal load balancing. + - 'This field represents a link to a TargetPool resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_target_pool + task and then set this target field to "{{ name-of-resource }}" Alternatively, + you can set this target to a dictionary with the selfLink key where the value + is the selfLink of your TargetPool' + required: false + version_added: 2.7 + network_tier: + description: + - 'The networking tier used for configuring this address. This field can take + the following values: PREMIUM or STANDARD. If this field is not specified, it + is assumed to be PREMIUM.' + required: false + version_added: 2.8 + choices: + - PREMIUM + - STANDARD + region: + description: + - A reference to the region where the regional forwarding rule resides. + - This field is not applicable to global forwarding rules. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/forwardingRule)" - - "Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/forwardingRule)' +- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules)' ''' EXAMPLES = ''' @@ -232,152 +249,148 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - IPAddress: - description: - - The IP address that this forwarding rule is serving on behalf of. - - Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL - or INTERNAL) and scope (global or regional). - - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address - must be a global IP, and for regional forwarding rules, the address must live in - the same region as the forwarding rule. If this field is empty, an ephemeral IPv4 - address from the same scope (global or regional) will be assigned. A regional forwarding - rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6. - - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address - belonging to the network/subnet configured for the forwarding rule. By default, - if this field is empty, an ephemeral internal IP address will be automatically allocated - from the IP range of the subnet or network configured for this forwarding rule. - - 'An address can be specified either by a literal IP address or a URL reference to - an existing Address resource. The following examples are all valid: * 100.1.2.3 - * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) - * projects/project/regions/region/addresses/address * regions/region/addresses/address - * global/addresses/address * address .' - returned: success - type: str - IPProtocol: - description: - - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, - SCTP or ICMP. - - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. - returned: success - type: str - backendService: - description: - - A reference to a BackendService to receive the matched traffic. - - This is used for internal load balancing. - - "(not used for external load balancing) ." - returned: success - type: dict - ipVersion: - description: - - The IP Version that will be used by this forwarding rule. Valid options are IPV4 - or IPV6. This can only be specified for a global forwarding rule. - returned: success - type: str - loadBalancingScheme: - description: - - 'This signifies what the ForwardingRule will be used for and can only take the following - values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for - Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this - will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) - .' - returned: success - type: str - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - For internal load balancing, this field identifies the network that the load balanced - IP should belong to for this Forwarding Rule. If this field is not specified, the - default network will be used. - - This field is not used for external load balancing. - returned: success - type: dict - portRange: - description: - - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. - - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to - ports in the specified range will be forwarded to target. - - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port - ranges. - - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: - 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, - 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, - 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: - 500, 4500 .' - returned: success - type: str - ports: - description: - - This field is used along with the backend_service field for internal load balancing. - - When the load balancing scheme is INTERNAL, a single port or a comma separated list - of ports can be configured. Only packets addressed to these ports will be forwarded - to the backends configured with this forwarding rule. - - You may specify a maximum of up to 5 ports. - returned: success - type: list - subnetwork: - description: - - A reference to a subnetwork. - - For internal load balancing, this field identifies the subnetwork that the load - balanced IP should belong to for this Forwarding Rule. - - If the network specified is in auto subnet mode, this field is optional. However, - if the network is in custom subnet mode, a subnetwork must be specified. - - This field is not used for external load balancing. - returned: success - type: dict - target: - description: - - A reference to a TargetPool resource to receive the matched traffic. - - For regional forwarding rules, this target must live in the same region as the forwarding - rule. For global forwarding rules, this target must be a global load balancing resource. - The forwarded traffic must be of a type appropriate to the target object. - - This field is not used for internal load balancing. - returned: success - type: dict - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - networkTier: - description: - - 'The networking tier used for configuring this address. This field can take the - following values: PREMIUM or STANDARD. If this field is not specified, it is assumed - to be PREMIUM.' - returned: success - type: str - region: - description: - - A reference to the region where the regional forwarding rule resides. - - This field is not applicable to global forwarding rules. - returned: success - type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +IPAddress: + description: + - The IP address that this forwarding rule is serving on behalf of. + - Addresses are restricted based on the forwarding rule's load balancing scheme + (EXTERNAL or INTERNAL) and scope (global or regional). + - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address + must be a global IP, and for regional forwarding rules, the address must live + in the same region as the forwarding rule. If this field is empty, an ephemeral + IPv4 address from the same scope (global or regional) will be assigned. A regional + forwarding rule supports IPv4 only. A global forwarding rule supports either IPv4 + or IPv6. + - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address + belonging to the network/subnet configured for the forwarding rule. By default, + if this field is empty, an ephemeral internal IP address will be automatically + allocated from the IP range of the subnet or network configured for this forwarding + rule. + - 'An address can be specified either by a literal IP address or a URL reference + to an existing Address resource. The following examples are all valid: * 100.1.2.3 + * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) + * projects/project/regions/region/addresses/address * regions/region/addresses/address + * global/addresses/address * address .' + returned: success + type: str +IPProtocol: + description: + - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, + SCTP or ICMP. + - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. + returned: success + type: str +backendService: + description: + - A reference to a BackendService to receive the matched traffic. + - This is used for internal load balancing. + - "(not used for external load balancing) ." + returned: success + type: dict +ipVersion: + description: + - The IP Version that will be used by this forwarding rule. Valid options are IPV4 + or IPV6. This can only be specified for a global forwarding rule. + returned: success + type: str +loadBalancingScheme: + description: + - 'This signifies what the ForwardingRule will be used for and can only take the + following values: INTERNAL, EXTERNAL The value of INTERNAL means that this will + be used for Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL + means that this will be used for External Load Balancing (HTTP(S) LB, External + TCP/UDP LB, SSL Proxy) .' + returned: success + type: str +name: + description: + - Name of the resource; provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +network: + description: + - For internal load balancing, this field identifies the network that the load balanced + IP should belong to for this Forwarding Rule. If this field is not specified, + the default network will be used. + - This field is not used for external load balancing. + returned: success + type: dict +portRange: + description: + - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, + TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. + - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to + ports in the specified range will be forwarded to target. + - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint + port ranges. + - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: + 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, + 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, 143, 195, 443, + 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500 .' + returned: success + type: str +ports: + description: + - This field is used along with the backend_service field for internal load balancing. + - When the load balancing scheme is INTERNAL, a single port or a comma separated + list of ports can be configured. Only packets addressed to these ports will be + forwarded to the backends configured with this forwarding rule. + - You may specify a maximum of up to 5 ports. + returned: success + type: list +subnetwork: + description: + - A reference to a subnetwork. + - For internal load balancing, this field identifies the subnetwork that the load + balanced IP should belong to for this Forwarding Rule. + - If the network specified is in auto subnet mode, this field is optional. However, + if the network is in custom subnet mode, a subnetwork must be specified. + - This field is not used for external load balancing. + returned: success + type: dict +target: + description: + - A reference to a TargetPool resource to receive the matched traffic. + - For regional forwarding rules, this target must live in the same region as the + forwarding rule. For global forwarding rules, this target must be a global load + balancing resource. The forwarded traffic must be of a type appropriate to the + target object. + - This field is not used for internal load balancing. + returned: success + type: dict +networkTier: + description: + - 'The networking tier used for configuring this address. This field can take the + following values: PREMIUM or STANDARD. If this field is not specified, it is assumed + to be PREMIUM.' + returned: success + type: str +region: + description: + - A reference to the region where the regional forwarding rule resides. + - This field is not applicable to global forwarding rules. + returned: success + type: str ''' ################################################################################ @@ -476,19 +489,6 @@ def target_update(module, request, response): ) -def label_fingerprint_update(module, request, response): - auth = GcpSession(module, 'compute') - auth.post( - ''.join([ - "https://www.googleapis.com/compute/v1/", - "projects/{project}/regions/{region}/forwardingRules/{name}/setLabels" - ]).format(**module.params), - { - u'labelFingerprint': response.get('labelFingerprint') - } - ) - - def delete(module, link, kind): auth = GcpSession(module, 'compute') return wait_for_operation(module, auth.delete(link)) @@ -589,7 +589,6 @@ def response_to_hash(module, response): u'ports': response.get(u'ports'), u'subnetwork': response.get(u'subnetwork'), u'target': response.get(u'target'), - u'labelFingerprint': response.get(u'labelFingerprint'), u'networkTier': module.params.get('network_tier') } @@ -618,8 +617,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_facts.py index a56710298a..e5bd5fd37e 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_facts.py @@ -32,26 +32,25 @@ DOCUMENTATION = ''' --- module: gcp_compute_forwarding_rule_facts description: - - Gather facts for GCP ForwardingRule +- Gather facts for GCP ForwardingRule short_description: Gather facts for GCP ForwardingRule version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - A reference to the region where the regional forwarding rule resides. - - This field is not applicable to global forwarding rules. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - A reference to the region where the regional forwarding rule resides. + - This field is not applicable to global forwarding rules. + required: true extends_documentation_fragment: gcp ''' @@ -68,156 +67,154 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - IPAddress: - description: - - The IP address that this forwarding rule is serving on behalf of. - - Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL - or INTERNAL) and scope (global or regional). - - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address - must be a global IP, and for regional forwarding rules, the address must live in - the same region as the forwarding rule. If this field is empty, an ephemeral IPv4 - address from the same scope (global or regional) will be assigned. A regional forwarding - rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6. - - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address - belonging to the network/subnet configured for the forwarding rule. By default, - if this field is empty, an ephemeral internal IP address will be automatically allocated - from the IP range of the subnet or network configured for this forwarding rule. - - 'An address can be specified either by a literal IP address or a URL reference to - an existing Address resource. The following examples are all valid: * 100.1.2.3 - * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) - * projects/project/regions/region/addresses/address * regions/region/addresses/address - * global/addresses/address * address .' - returned: success - type: str - IPProtocol: - description: - - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, - SCTP or ICMP. - - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. - returned: success - type: str - backendService: - description: - - A reference to a BackendService to receive the matched traffic. - - This is used for internal load balancing. - - "(not used for external load balancing) ." - returned: success - type: dict - ipVersion: - description: - - The IP Version that will be used by this forwarding rule. Valid options are IPV4 - or IPV6. This can only be specified for a global forwarding rule. - returned: success - type: str - loadBalancingScheme: - description: - - 'This signifies what the ForwardingRule will be used for and can only take the following - values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for - Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this - will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) - .' - returned: success - type: str - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - For internal load balancing, this field identifies the network that the load balanced - IP should belong to for this Forwarding Rule. If this field is not specified, the - default network will be used. - - This field is not used for external load balancing. - returned: success - type: dict - portRange: - description: - - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. - - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to - ports in the specified range will be forwarded to target. - - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port - ranges. - - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: - 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, - 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, - 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: - 500, 4500 .' - returned: success - type: str - ports: - description: - - This field is used along with the backend_service field for internal load balancing. - - When the load balancing scheme is INTERNAL, a single port or a comma separated list - of ports can be configured. Only packets addressed to these ports will be forwarded - to the backends configured with this forwarding rule. - - You may specify a maximum of up to 5 ports. - returned: success - type: list - subnetwork: - description: - - A reference to a subnetwork. - - For internal load balancing, this field identifies the subnetwork that the load - balanced IP should belong to for this Forwarding Rule. - - If the network specified is in auto subnet mode, this field is optional. However, - if the network is in custom subnet mode, a subnetwork must be specified. - - This field is not used for external load balancing. - returned: success - type: dict - target: - description: - - A reference to a TargetPool resource to receive the matched traffic. - - For regional forwarding rules, this target must live in the same region as the forwarding - rule. For global forwarding rules, this target must be a global load balancing resource. - The forwarded traffic must be of a type appropriate to the target object. - - This field is not used for internal load balancing. - returned: success - type: dict - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - networkTier: - description: - - 'The networking tier used for configuring this address. This field can take the - following values: PREMIUM or STANDARD. If this field is not specified, it is assumed - to be PREMIUM.' - returned: success - type: str - region: - description: - - A reference to the region where the regional forwarding rule resides. - - This field is not applicable to global forwarding rules. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + IPAddress: + description: + - The IP address that this forwarding rule is serving on behalf of. + - Addresses are restricted based on the forwarding rule's load balancing scheme + (EXTERNAL or INTERNAL) and scope (global or regional). + - When the load balancing scheme is EXTERNAL, for global forwarding rules, the + address must be a global IP, and for regional forwarding rules, the address + must live in the same region as the forwarding rule. If this field is empty, + an ephemeral IPv4 address from the same scope (global or regional) will be + assigned. A regional forwarding rule supports IPv4 only. A global forwarding + rule supports either IPv4 or IPv6. + - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP + address belonging to the network/subnet configured for the forwarding rule. + By default, if this field is empty, an ephemeral internal IP address will + be automatically allocated from the IP range of the subnet or network configured + for this forwarding rule. + - 'An address can be specified either by a literal IP address or a URL reference + to an existing Address resource. The following examples are all valid: * 100.1.2.3 + * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) + * projects/project/regions/region/addresses/address * regions/region/addresses/address + * global/addresses/address * address .' + returned: success + type: str + IPProtocol: + description: + - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, + AH, SCTP or ICMP. + - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. + returned: success + type: str + backendService: + description: + - A reference to a BackendService to receive the matched traffic. + - This is used for internal load balancing. + - "(not used for external load balancing) ." + returned: success + type: dict + ipVersion: + description: + - The IP Version that will be used by this forwarding rule. Valid options are + IPV4 or IPV6. This can only be specified for a global forwarding rule. + returned: success + type: str + loadBalancingScheme: + description: + - 'This signifies what the ForwardingRule will be used for and can only take + the following values: INTERNAL, EXTERNAL The value of INTERNAL means that + this will be used for Internal Network Load Balancing (TCP, UDP). The value + of EXTERNAL means that this will be used for External Load Balancing (HTTP(S) + LB, External TCP/UDP LB, SSL Proxy) .' + returned: success + type: str + name: + description: + - Name of the resource; provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + network: + description: + - For internal load balancing, this field identifies the network that the load + balanced IP should belong to for this Forwarding Rule. If this field is not + specified, the default network will be used. + - This field is not used for external load balancing. + returned: success + type: dict + portRange: + description: + - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, + TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. + - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed + to ports in the specified range will be forwarded to target. + - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint + port ranges. + - 'Some types of forwarding target have constraints on the acceptable ports: + * TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, + 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: + 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: + 500, 4500 .' + returned: success + type: str + ports: + description: + - This field is used along with the backend_service field for internal load + balancing. + - When the load balancing scheme is INTERNAL, a single port or a comma separated + list of ports can be configured. Only packets addressed to these ports will + be forwarded to the backends configured with this forwarding rule. + - You may specify a maximum of up to 5 ports. + returned: success + type: list + subnetwork: + description: + - A reference to a subnetwork. + - For internal load balancing, this field identifies the subnetwork that the + load balanced IP should belong to for this Forwarding Rule. + - If the network specified is in auto subnet mode, this field is optional. However, + if the network is in custom subnet mode, a subnetwork must be specified. + - This field is not used for external load balancing. + returned: success + type: dict + target: + description: + - A reference to a TargetPool resource to receive the matched traffic. + - For regional forwarding rules, this target must live in the same region as + the forwarding rule. For global forwarding rules, this target must be a global + load balancing resource. The forwarded traffic must be of a type appropriate + to the target object. + - This field is not used for internal load balancing. + returned: success + type: dict + networkTier: + description: + - 'The networking tier used for configuring this address. This field can take + the following values: PREMIUM or STANDARD. If this field is not specified, + it is assumed to be PREMIUM.' + returned: success + type: str + region: + description: + - A reference to the region where the regional forwarding rule resides. + - This field is not applicable to global forwarding rules. + returned: success + type: str ''' ################################################################################ @@ -239,7 +236,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_address.py b/lib/ansible/modules/cloud/google/gcp_compute_global_address.py index f8cc7eaea9..8828379738 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_global_address.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_global_address.py @@ -32,54 +32,60 @@ DOCUMENTATION = ''' --- module: gcp_compute_global_address description: - - Represents a Global Address resource. Global addresses are used for HTTP(S) load - balancing. +- Represents a Global Address resource. Global addresses are used for HTTP(S) load + balancing. short_description: Creates a GCP GlobalAddress version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. - - Provide this property when you create the resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - ip_version: - description: - - The IP Version that will be used by this address. Valid options are IPV4 or IPV6. - The default value is IPV4. - required: false - choices: ['IPV4', 'IPV6'] - address_type: - description: - - The type of the address to reserve, default is EXTERNAL. - - "* EXTERNAL indicates public/external single IP address." - - "* INTERNAL indicates internal IP ranges belonging to some network." - required: false - default: EXTERNAL - version_added: 2.8 - choices: ['EXTERNAL', 'INTERNAL'] + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. + - Provide this property when you create the resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + ip_version: + description: + - The IP Version that will be used by this address. Valid options are IPV4 or + IPV6. The default value is IPV4. + required: false + choices: + - IPV4 + - IPV6 + address_type: + description: + - The type of the address to reserve, default is EXTERNAL. + - "* EXTERNAL indicates public/external single IP address." + - "* INTERNAL indicates internal IP ranges belonging to some network." + required: false + default: EXTERNAL + version_added: 2.8 + choices: + - EXTERNAL + - INTERNAL extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/globalAddresses)" - - "Reserving a Static External IP Address: U(https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/globalAddresses)' +- 'Reserving a Static External IP Address: U(https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address)' ''' EXAMPLES = ''' @@ -93,61 +99,55 @@ EXAMPLES = ''' ''' RETURN = ''' - address: - description: - - The static external IP address represented by this resource. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - - Provide this property when you create the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - ipVersion: - description: - - The IP Version that will be used by this address. Valid options are IPV4 or IPV6. - The default value is IPV4. - returned: success - type: str - region: - description: - - A reference to the region where the regional address resides. - returned: success - type: str - addressType: - description: - - The type of the address to reserve, default is EXTERNAL. - - "* EXTERNAL indicates public/external single IP address." - - "* INTERNAL indicates internal IP ranges belonging to some network." - returned: success - type: str +address: + description: + - The static external IP address represented by this resource. + returned: success + type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + - Provide this property when you create the resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. This identifier is defined by the server. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +ipVersion: + description: + - The IP Version that will be used by this address. Valid options are IPV4 or IPV6. + The default value is IPV4. + returned: success + type: str +region: + description: + - A reference to the region where the regional address resides. + returned: success + type: str +addressType: + description: + - The type of the address to reserve, default is EXTERNAL. + - "* EXTERNAL indicates public/external single IP address." + - "* INTERNAL indicates internal IP ranges belonging to some network." + returned: success + type: str ''' ################################################################################ @@ -189,7 +189,7 @@ def main(): if fetch: if state == 'present': if is_different(module, fetch): - update(module, self_link(module), kind, fetch) + update(module, self_link(module), kind) fetch = fetch_resource(module, self_link(module), kind) changed = True else: @@ -213,27 +213,8 @@ def create(module, link, kind): return wait_for_operation(module, auth.post(link, resource_to_request(module))) -def update(module, link, kind, fetch): - update_fields(module, resource_to_request(module), - response_to_hash(module, fetch)) - return fetch_resource(module, self_link(module), kind) - - -def update_fields(module, request, response): - pass - - -def label_fingerprint_update(module, request, response): - auth = GcpSession(module, 'compute') - auth.post( - ''.join([ - "https://www.googleapis.com/compute/v1/", - "projects/{project}/global/addresses/{name}/setLabels" - ]).format(**module.params), - { - u'labelFingerprint': response.get('labelFingerprint') - } - ) +def update(module, link, kind): + module.fail_json(msg="GlobalAddress cannot be edited") def delete(module, link, kind): @@ -318,7 +299,6 @@ def response_to_hash(module, response): u'description': response.get(u'description'), u'id': response.get(u'id'), u'name': response.get(u'name'), - u'labelFingerprint': response.get(u'labelFingerprint'), u'ipVersion': response.get(u'ipVersion'), u'region': response.get(u'region'), u'addressType': response.get(u'addressType') @@ -358,8 +338,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_address_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_global_address_facts.py index cd91bc0a27..2fb5e2e7e9 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_global_address_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_global_address_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_global_address_facts description: - - Gather facts for GCP GlobalAddress +- Gather facts for GCP GlobalAddress short_description: Gather facts for GCP GlobalAddress version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,65 +61,60 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - address: - description: - - The static external IP address represented by this resource. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - - Provide this property when you create the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - ipVersion: - description: - - The IP Version that will be used by this address. Valid options are IPV4 or IPV6. - The default value is IPV4. - returned: success - type: str - region: - description: - - A reference to the region where the regional address resides. - returned: success - type: str - addressType: - description: - - The type of the address to reserve, default is EXTERNAL. - - "* EXTERNAL indicates public/external single IP address." - - "* INTERNAL indicates internal IP ranges belonging to some network." - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + address: + description: + - The static external IP address represented by this resource. + returned: success + type: str + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + - Provide this property when you create the resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. This identifier is defined by the + server. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + ipVersion: + description: + - The IP Version that will be used by this address. Valid options are IPV4 or + IPV6. The default value is IPV4. + returned: success + type: str + region: + description: + - A reference to the region where the regional address resides. + returned: success + type: str + addressType: + description: + - The type of the address to reserve, default is EXTERNAL. + - "* EXTERNAL indicates public/external single IP address." + - "* INTERNAL indicates internal IP ranges belonging to some network." + returned: success + type: str ''' ################################################################################ @@ -141,7 +135,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py index 09e563396c..bf43943e43 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py @@ -32,145 +32,159 @@ DOCUMENTATION = ''' --- module: gcp_compute_global_forwarding_rule description: - - Represents a GlobalForwardingRule resource. Global forwarding rules are used to - forward traffic to the correct load balancer for HTTP load balancing. Global forwarding - rules can only be used for HTTP load balancing. - - For more information, see U(https://cloud.google.com/compute/docs/load-balancing/http/) - . +- Represents a GlobalForwardingRule resource. Global forwarding rules are used to + forward traffic to the correct load balancer for HTTP load balancing. Global forwarding + rules can only be used for HTTP load balancing. +- For more information, see U(https://cloud.google.com/compute/docs/load-balancing/http/) + . short_description: Creates a GCP GlobalForwardingRule version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - ip_address: - description: - - The IP address that this forwarding rule is serving on behalf of. - - Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL - or INTERNAL) and scope (global or regional). - - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address - must be a global IP, and for regional forwarding rules, the address must live in - the same region as the forwarding rule. If this field is empty, an ephemeral IPv4 - address from the same scope (global or regional) will be assigned. A regional forwarding - rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6. - - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address - belonging to the network/subnet configured for the forwarding rule. By default, - if this field is empty, an ephemeral internal IP address will be automatically allocated - from the IP range of the subnet or network configured for this forwarding rule. - - 'An address can be specified either by a literal IP address or a URL reference to - an existing Address resource. The following examples are all valid: * 100.1.2.3 - * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) - * projects/project/regions/region/addresses/address * regions/region/addresses/address - * global/addresses/address * address .' - required: false - ip_protocol: - description: - - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, - SCTP or ICMP. - - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. - required: false - choices: ['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP'] - backend_service: - description: - - A reference to a BackendService to receive the matched traffic. - - This is used for internal load balancing. - - "(not used for external load balancing) ." - - 'This field represents a link to a BackendService resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service - task and then set this backend_service field to "{{ name-of-resource }}" Alternatively, - you can set this backend_service to a dictionary with the selfLink key where the - value is the selfLink of your BackendService.' - required: false - ip_version: - description: - - The IP Version that will be used by this forwarding rule. Valid options are IPV4 - or IPV6. This can only be specified for a global forwarding rule. - required: false - choices: ['IPV4', 'IPV6'] - load_balancing_scheme: - description: - - 'This signifies what the ForwardingRule will be used for and can only take the following - values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for - Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this - will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) - .' - required: false - choices: ['INTERNAL', 'EXTERNAL'] - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - network: - description: - - For internal load balancing, this field identifies the network that the load balanced - IP should belong to for this Forwarding Rule. If this field is not specified, the - default network will be used. - - This field is not used for external load balancing. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: false - port_range: - description: - - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. - - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to - ports in the specified range will be forwarded to target. - - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port - ranges. - - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: - 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, - 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, - 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: - 500, 4500 .' - required: false - ports: - description: - - This field is used along with the backend_service field for internal load balancing. - - When the load balancing scheme is INTERNAL, a single port or a comma separated list - of ports can be configured. Only packets addressed to these ports will be forwarded - to the backends configured with this forwarding rule. - - You may specify a maximum of up to 5 ports. - required: false - subnetwork: - description: - - A reference to a subnetwork. - - For internal load balancing, this field identifies the subnetwork that the load - balanced IP should belong to for this Forwarding Rule. - - If the network specified is in auto subnet mode, this field is optional. However, - if the network is in custom subnet mode, a subnetwork must be specified. - - This field is not used for external load balancing. - - 'This field represents a link to a Subnetwork resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork - task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, - you can set this subnetwork to a dictionary with the selfLink key where the value - is the selfLink of your Subnetwork.' - required: false - target: - description: - - This target must be a global load balancing resource. The forwarded traffic must - be of a type appropriate to the target object. - - 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .' - required: false + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + ip_address: + description: + - The IP address that this forwarding rule is serving on behalf of. + - Addresses are restricted based on the forwarding rule's load balancing scheme + (EXTERNAL or INTERNAL) and scope (global or regional). + - When the load balancing scheme is EXTERNAL, for global forwarding rules, the + address must be a global IP, and for regional forwarding rules, the address + must live in the same region as the forwarding rule. If this field is empty, + an ephemeral IPv4 address from the same scope (global or regional) will be assigned. + A regional forwarding rule supports IPv4 only. A global forwarding rule supports + either IPv4 or IPv6. + - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP + address belonging to the network/subnet configured for the forwarding rule. + By default, if this field is empty, an ephemeral internal IP address will be + automatically allocated from the IP range of the subnet or network configured + for this forwarding rule. + - 'An address can be specified either by a literal IP address or a URL reference + to an existing Address resource. The following examples are all valid: * 100.1.2.3 + * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) + * projects/project/regions/region/addresses/address * regions/region/addresses/address + * global/addresses/address * address .' + required: false + ip_protocol: + description: + - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, + AH, SCTP or ICMP. + - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. + required: false + choices: + - TCP + - UDP + - ESP + - AH + - SCTP + - ICMP + backend_service: + description: + - A reference to a BackendService to receive the matched traffic. + - This is used for internal load balancing. + - "(not used for external load balancing) ." + - 'This field represents a link to a BackendService resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service + task and then set this backend_service field to "{{ name-of-resource }}" Alternatively, + you can set this backend_service to a dictionary with the selfLink key where + the value is the selfLink of your BackendService' + required: false + ip_version: + description: + - The IP Version that will be used by this forwarding rule. Valid options are + IPV4 or IPV6. This can only be specified for a global forwarding rule. + required: false + choices: + - IPV4 + - IPV6 + load_balancing_scheme: + description: + - 'This signifies what the ForwardingRule will be used for and can only take the + following values: INTERNAL, EXTERNAL The value of INTERNAL means that this will + be used for Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL + means that this will be used for External Load Balancing (HTTP(S) LB, External + TCP/UDP LB, SSL Proxy) .' + required: false + choices: + - INTERNAL + - EXTERNAL + name: + description: + - Name of the resource; provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + network: + description: + - For internal load balancing, this field identifies the network that the load + balanced IP should belong to for this Forwarding Rule. If this field is not + specified, the default network will be used. + - This field is not used for external load balancing. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: false + port_range: + description: + - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, + TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. + - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed + to ports in the specified range will be forwarded to target. + - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint + port ranges. + - 'Some types of forwarding target have constraints on the acceptable ports: * + TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, + 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, + 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: + 500, 4500 .' + required: false + ports: + description: + - This field is used along with the backend_service field for internal load balancing. + - When the load balancing scheme is INTERNAL, a single port or a comma separated + list of ports can be configured. Only packets addressed to these ports will + be forwarded to the backends configured with this forwarding rule. + - You may specify a maximum of up to 5 ports. + required: false + subnetwork: + description: + - A reference to a subnetwork. + - For internal load balancing, this field identifies the subnetwork that the load + balanced IP should belong to for this Forwarding Rule. + - If the network specified is in auto subnet mode, this field is optional. However, + if the network is in custom subnet mode, a subnetwork must be specified. + - This field is not used for external load balancing. + - 'This field represents a link to a Subnetwork resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork + task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, + you can set this subnetwork to a dictionary with the selfLink key where the + value is the selfLink of your Subnetwork' + required: false + target: + description: + - This target must be a global load balancing resource. The forwarded traffic + must be of a type appropriate to the target object. + - 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .' + required: false extends_documentation_fragment: gcp ''' @@ -255,137 +269,138 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - IPAddress: - description: - - The IP address that this forwarding rule is serving on behalf of. - - Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL - or INTERNAL) and scope (global or regional). - - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address - must be a global IP, and for regional forwarding rules, the address must live in - the same region as the forwarding rule. If this field is empty, an ephemeral IPv4 - address from the same scope (global or regional) will be assigned. A regional forwarding - rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6. - - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address - belonging to the network/subnet configured for the forwarding rule. By default, - if this field is empty, an ephemeral internal IP address will be automatically allocated - from the IP range of the subnet or network configured for this forwarding rule. - - 'An address can be specified either by a literal IP address or a URL reference to - an existing Address resource. The following examples are all valid: * 100.1.2.3 - * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) - * projects/project/regions/region/addresses/address * regions/region/addresses/address - * global/addresses/address * address .' - returned: success - type: str - IPProtocol: - description: - - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, - SCTP or ICMP. - - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. - returned: success - type: str - backendService: - description: - - A reference to a BackendService to receive the matched traffic. - - This is used for internal load balancing. - - "(not used for external load balancing) ." - returned: success - type: dict - ipVersion: - description: - - The IP Version that will be used by this forwarding rule. Valid options are IPV4 - or IPV6. This can only be specified for a global forwarding rule. - returned: success - type: str - loadBalancingScheme: - description: - - 'This signifies what the ForwardingRule will be used for and can only take the following - values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for - Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this - will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) - .' - returned: success - type: str - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - For internal load balancing, this field identifies the network that the load balanced - IP should belong to for this Forwarding Rule. If this field is not specified, the - default network will be used. - - This field is not used for external load balancing. - returned: success - type: dict - portRange: - description: - - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. - - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to - ports in the specified range will be forwarded to target. - - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port - ranges. - - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: - 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, - 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, - 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: - 500, 4500 .' - returned: success - type: str - ports: - description: - - This field is used along with the backend_service field for internal load balancing. - - When the load balancing scheme is INTERNAL, a single port or a comma separated list - of ports can be configured. Only packets addressed to these ports will be forwarded - to the backends configured with this forwarding rule. - - You may specify a maximum of up to 5 ports. - returned: success - type: list - subnetwork: - description: - - A reference to a subnetwork. - - For internal load balancing, this field identifies the subnetwork that the load - balanced IP should belong to for this Forwarding Rule. - - If the network specified is in auto subnet mode, this field is optional. However, - if the network is in custom subnet mode, a subnetwork must be specified. - - This field is not used for external load balancing. - returned: success - type: dict - region: - description: - - A reference to the region where the regional forwarding rule resides. - - This field is not applicable to global forwarding rules. - returned: success - type: str - target: - description: - - This target must be a global load balancing resource. The forwarded traffic must - be of a type appropriate to the target object. - - 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .' - returned: success - type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +IPAddress: + description: + - The IP address that this forwarding rule is serving on behalf of. + - Addresses are restricted based on the forwarding rule's load balancing scheme + (EXTERNAL or INTERNAL) and scope (global or regional). + - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address + must be a global IP, and for regional forwarding rules, the address must live + in the same region as the forwarding rule. If this field is empty, an ephemeral + IPv4 address from the same scope (global or regional) will be assigned. A regional + forwarding rule supports IPv4 only. A global forwarding rule supports either IPv4 + or IPv6. + - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address + belonging to the network/subnet configured for the forwarding rule. By default, + if this field is empty, an ephemeral internal IP address will be automatically + allocated from the IP range of the subnet or network configured for this forwarding + rule. + - 'An address can be specified either by a literal IP address or a URL reference + to an existing Address resource. The following examples are all valid: * 100.1.2.3 + * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) + * projects/project/regions/region/addresses/address * regions/region/addresses/address + * global/addresses/address * address .' + returned: success + type: str +IPProtocol: + description: + - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, + SCTP or ICMP. + - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. + returned: success + type: str +backendService: + description: + - A reference to a BackendService to receive the matched traffic. + - This is used for internal load balancing. + - "(not used for external load balancing) ." + returned: success + type: dict +ipVersion: + description: + - The IP Version that will be used by this forwarding rule. Valid options are IPV4 + or IPV6. This can only be specified for a global forwarding rule. + returned: success + type: str +loadBalancingScheme: + description: + - 'This signifies what the ForwardingRule will be used for and can only take the + following values: INTERNAL, EXTERNAL The value of INTERNAL means that this will + be used for Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL + means that this will be used for External Load Balancing (HTTP(S) LB, External + TCP/UDP LB, SSL Proxy) .' + returned: success + type: str +name: + description: + - Name of the resource; provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +network: + description: + - For internal load balancing, this field identifies the network that the load balanced + IP should belong to for this Forwarding Rule. If this field is not specified, + the default network will be used. + - This field is not used for external load balancing. + returned: success + type: dict +portRange: + description: + - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, + TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. + - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to + ports in the specified range will be forwarded to target. + - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint + port ranges. + - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: + 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, + 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, 143, 195, 443, + 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500 .' + returned: success + type: str +ports: + description: + - This field is used along with the backend_service field for internal load balancing. + - When the load balancing scheme is INTERNAL, a single port or a comma separated + list of ports can be configured. Only packets addressed to these ports will be + forwarded to the backends configured with this forwarding rule. + - You may specify a maximum of up to 5 ports. + returned: success + type: list +subnetwork: + description: + - A reference to a subnetwork. + - For internal load balancing, this field identifies the subnetwork that the load + balanced IP should belong to for this Forwarding Rule. + - If the network specified is in auto subnet mode, this field is optional. However, + if the network is in custom subnet mode, a subnetwork must be specified. + - This field is not used for external load balancing. + returned: success + type: dict +region: + description: + - A reference to the region where the regional forwarding rule resides. + - This field is not applicable to global forwarding rules. + returned: success + type: str +target: + description: + - This target must be a global load balancing resource. The forwarded traffic must + be of a type appropriate to the target object. + - 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .' + returned: success + type: str ''' ################################################################################ @@ -590,8 +605,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_facts.py index 3c25d67d00..3e2a134007 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_global_forwarding_rule_facts description: - - Gather facts for GCP GlobalForwardingRule +- Gather facts for GCP GlobalForwardingRule short_description: Gather facts for GCP GlobalForwardingRule version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,141 +61,144 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - IPAddress: - description: - - The IP address that this forwarding rule is serving on behalf of. - - Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL - or INTERNAL) and scope (global or regional). - - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address - must be a global IP, and for regional forwarding rules, the address must live in - the same region as the forwarding rule. If this field is empty, an ephemeral IPv4 - address from the same scope (global or regional) will be assigned. A regional forwarding - rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6. - - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address - belonging to the network/subnet configured for the forwarding rule. By default, - if this field is empty, an ephemeral internal IP address will be automatically allocated - from the IP range of the subnet or network configured for this forwarding rule. - - 'An address can be specified either by a literal IP address or a URL reference to - an existing Address resource. The following examples are all valid: * 100.1.2.3 - * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) - * projects/project/regions/region/addresses/address * regions/region/addresses/address - * global/addresses/address * address .' - returned: success - type: str - IPProtocol: - description: - - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, - SCTP or ICMP. - - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. - returned: success - type: str - backendService: - description: - - A reference to a BackendService to receive the matched traffic. - - This is used for internal load balancing. - - "(not used for external load balancing) ." - returned: success - type: dict - ipVersion: - description: - - The IP Version that will be used by this forwarding rule. Valid options are IPV4 - or IPV6. This can only be specified for a global forwarding rule. - returned: success - type: str - loadBalancingScheme: - description: - - 'This signifies what the ForwardingRule will be used for and can only take the following - values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for - Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this - will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) - .' - returned: success - type: str - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - For internal load balancing, this field identifies the network that the load balanced - IP should belong to for this Forwarding Rule. If this field is not specified, the - default network will be used. - - This field is not used for external load balancing. - returned: success - type: dict - portRange: - description: - - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. - - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to - ports in the specified range will be forwarded to target. - - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port - ranges. - - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy: - 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465, - 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, - 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: - 500, 4500 .' - returned: success - type: str - ports: - description: - - This field is used along with the backend_service field for internal load balancing. - - When the load balancing scheme is INTERNAL, a single port or a comma separated list - of ports can be configured. Only packets addressed to these ports will be forwarded - to the backends configured with this forwarding rule. - - You may specify a maximum of up to 5 ports. - returned: success - type: list - subnetwork: - description: - - A reference to a subnetwork. - - For internal load balancing, this field identifies the subnetwork that the load - balanced IP should belong to for this Forwarding Rule. - - If the network specified is in auto subnet mode, this field is optional. However, - if the network is in custom subnet mode, a subnetwork must be specified. - - This field is not used for external load balancing. - returned: success - type: dict - region: - description: - - A reference to the region where the regional forwarding rule resides. - - This field is not applicable to global forwarding rules. - returned: success - type: str - target: - description: - - This target must be a global load balancing resource. The forwarded traffic must - be of a type appropriate to the target object. - - 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .' - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + IPAddress: + description: + - The IP address that this forwarding rule is serving on behalf of. + - Addresses are restricted based on the forwarding rule's load balancing scheme + (EXTERNAL or INTERNAL) and scope (global or regional). + - When the load balancing scheme is EXTERNAL, for global forwarding rules, the + address must be a global IP, and for regional forwarding rules, the address + must live in the same region as the forwarding rule. If this field is empty, + an ephemeral IPv4 address from the same scope (global or regional) will be + assigned. A regional forwarding rule supports IPv4 only. A global forwarding + rule supports either IPv4 or IPv6. + - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP + address belonging to the network/subnet configured for the forwarding rule. + By default, if this field is empty, an ephemeral internal IP address will + be automatically allocated from the IP range of the subnet or network configured + for this forwarding rule. + - 'An address can be specified either by a literal IP address or a URL reference + to an existing Address resource. The following examples are all valid: * 100.1.2.3 + * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address) + * projects/project/regions/region/addresses/address * regions/region/addresses/address + * global/addresses/address * address .' + returned: success + type: str + IPProtocol: + description: + - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, + AH, SCTP or ICMP. + - When the load balancing scheme is INTERNAL, only TCP and UDP are valid. + returned: success + type: str + backendService: + description: + - A reference to a BackendService to receive the matched traffic. + - This is used for internal load balancing. + - "(not used for external load balancing) ." + returned: success + type: dict + ipVersion: + description: + - The IP Version that will be used by this forwarding rule. Valid options are + IPV4 or IPV6. This can only be specified for a global forwarding rule. + returned: success + type: str + loadBalancingScheme: + description: + - 'This signifies what the ForwardingRule will be used for and can only take + the following values: INTERNAL, EXTERNAL The value of INTERNAL means that + this will be used for Internal Network Load Balancing (TCP, UDP). The value + of EXTERNAL means that this will be used for External Load Balancing (HTTP(S) + LB, External TCP/UDP LB, SSL Proxy) .' + returned: success + type: str + name: + description: + - Name of the resource; provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + network: + description: + - For internal load balancing, this field identifies the network that the load + balanced IP should belong to for this Forwarding Rule. If this field is not + specified, the default network will be used. + - This field is not used for external load balancing. + returned: success + type: dict + portRange: + description: + - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, + TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance. + - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed + to ports in the specified range will be forwarded to target. + - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint + port ranges. + - 'Some types of forwarding target have constraints on the acceptable ports: + * TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, + 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: + 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: + 500, 4500 .' + returned: success + type: str + ports: + description: + - This field is used along with the backend_service field for internal load + balancing. + - When the load balancing scheme is INTERNAL, a single port or a comma separated + list of ports can be configured. Only packets addressed to these ports will + be forwarded to the backends configured with this forwarding rule. + - You may specify a maximum of up to 5 ports. + returned: success + type: list + subnetwork: + description: + - A reference to a subnetwork. + - For internal load balancing, this field identifies the subnetwork that the + load balanced IP should belong to for this Forwarding Rule. + - If the network specified is in auto subnet mode, this field is optional. However, + if the network is in custom subnet mode, a subnetwork must be specified. + - This field is not used for external load balancing. + returned: success + type: dict + region: + description: + - A reference to the region where the regional forwarding rule resides. + - This field is not applicable to global forwarding rules. + returned: success + type: str + target: + description: + - This target must be a global load balancing resource. The forwarded traffic + must be of a type appropriate to the target object. + - 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .' + returned: success + type: str ''' ################################################################################ @@ -217,7 +219,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_health_check.py b/lib/ansible/modules/cloud/google/gcp_compute_health_check.py index a7c2f4a330..232dc92f78 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_health_check.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_health_check.py @@ -32,214 +32,229 @@ DOCUMENTATION = ''' --- module: gcp_compute_health_check description: - - Health Checks determine whether instances are responsive and able to do work. - - They are an important part of a comprehensive load balancing configuration, as they - enable monitoring instances behind load balancers. - - Health Checks poll instances at a specified interval. Instances that do not respond - successfully to some number of probes in a row are marked as unhealthy. No new connections - are sent to unhealthy instances, though existing connections will continue. The - health check will continue to poll unhealthy instances. If an instance later responds - successfully to some number of consecutive probes, it is marked healthy again and - can receive new connections. +- Health Checks determine whether instances are responsive and able to do work. +- They are an important part of a comprehensive load balancing configuration, as they + enable monitoring instances behind load balancers. +- Health Checks poll instances at a specified interval. Instances that do not respond + successfully to some number of probes in a row are marked as unhealthy. No new connections + are sent to unhealthy instances, though existing connections will continue. The + health check will continue to poll unhealthy instances. If an instance later responds + successfully to some number of consecutive probes, it is marked healthy again and + can receive new connections. short_description: Creates a GCP HealthCheck version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - check_interval_sec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - required: false - default: 5 + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + check_interval_sec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + required: false + default: '5' + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + healthy_threshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + required: false + default: '2' + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + timeout_sec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater + value than checkIntervalSec. + required: false + default: '5' + aliases: + - timeout_seconds + unhealthy_threshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + required: false + default: '2' + type: + description: + - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not + specified, the default is TCP. Exactly one of the protocol-specific health check + field must be specified, which must match type field. + required: false + choices: + - TCP + - SSL + - HTTP + - HTTPS + http_health_check: + description: + - A nested object resource. + required: false + suboptions: + host: description: - - An optional description of this resource. Provide this property when you create - the resource. + - The value of the host header in the HTTP health check request. + - If left empty (default value), the public IP on behalf of which this health + check is performed will be used. required: false - healthy_threshold: + request_path: description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. + - The request path of the HTTP health check request. + - The default value is /. required: false - default: 2 - name: + default: "/" + port: description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - timeout_sec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. + - The TCP port number for the HTTP health check request. + - The default value is 80. required: false - default: 5 - aliases: [timeout_seconds] - unhealthy_threshold: + port_name: description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. required: false - default: 2 - type: + proxy_header: description: - - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not specified, - the default is TCP. Exactly one of the protocol-specific health check field must - be specified, which must match type field. + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. required: false - choices: ['TCP', 'SSL', 'HTTP', 'HTTPS'] - http_health_check: + default: NONE + choices: + - NONE + - PROXY_V1 + https_health_check: + description: + - A nested object resource. + required: false + suboptions: + host: description: - - A nested object resource. + - The value of the host header in the HTTPS health check request. + - If left empty (default value), the public IP on behalf of which this health + check is performed will be used. required: false - suboptions: - host: - description: - - The value of the host header in the HTTP health check request. - - If left empty (default value), the public IP on behalf of which this health check - is performed will be used. - required: false - request_path: - description: - - The request path of the HTTP health check request. - - The default value is /. - required: false - default: / - port: - description: - - The TCP port number for the HTTP health check request. - - The default value is 80. - required: false - port_name: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - required: false - proxy_header: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - required: false - default: NONE - choices: ['NONE', 'PROXY_V1'] - https_health_check: + request_path: description: - - A nested object resource. + - The request path of the HTTPS health check request. + - The default value is /. required: false - suboptions: - host: - description: - - The value of the host header in the HTTPS health check request. - - If left empty (default value), the public IP on behalf of which this health check - is performed will be used. - required: false - request_path: - description: - - The request path of the HTTPS health check request. - - The default value is /. - required: false - default: / - port: - description: - - The TCP port number for the HTTPS health check request. - - The default value is 443. - required: false - port_name: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - required: false - proxy_header: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - required: false - default: NONE - choices: ['NONE', 'PROXY_V1'] - tcp_health_check: + default: "/" + port: description: - - A nested object resource. + - The TCP port number for the HTTPS health check request. + - The default value is 443. required: false - suboptions: - request: - description: - - The application data to send once the TCP connection has been established (default - value is empty). If both request and response are empty, the connection establishment - alone will indicate health. The request data can only be ASCII. - required: false - response: - description: - - The bytes to match against the beginning of the response data. If left empty (the - default value), any response will indicate health. The response data can only be - ASCII. - required: false - port: - description: - - The TCP port number for the TCP health check request. - - The default value is 443. - required: false - port_name: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - required: false - proxy_header: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - required: false - default: NONE - choices: ['NONE', 'PROXY_V1'] - ssl_health_check: + port_name: description: - - A nested object resource. + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. required: false - suboptions: - request: - description: - - The application data to send once the SSL connection has been established (default - value is empty). If both request and response are empty, the connection establishment - alone will indicate health. The request data can only be ASCII. - required: false - response: - description: - - The bytes to match against the beginning of the response data. If left empty (the - default value), any response will indicate health. The response data can only be - ASCII. - required: false - port: - description: - - The TCP port number for the SSL health check request. - - The default value is 443. - required: false - port_name: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - required: false - proxy_header: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - required: false - default: NONE - choices: ['NONE', 'PROXY_V1'] + proxy_header: + description: + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. + required: false + default: NONE + choices: + - NONE + - PROXY_V1 + tcp_health_check: + description: + - A nested object resource. + required: false + suboptions: + request: + description: + - The application data to send once the TCP connection has been established + (default value is empty). If both request and response are empty, the connection + establishment alone will indicate health. The request data can only be ASCII. + required: false + response: + description: + - The bytes to match against the beginning of the response data. If left empty + (the default value), any response will indicate health. The response data + can only be ASCII. + required: false + port: + description: + - The TCP port number for the TCP health check request. + - The default value is 443. + required: false + port_name: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. + required: false + proxy_header: + description: + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. + required: false + default: NONE + choices: + - NONE + - PROXY_V1 + ssl_health_check: + description: + - A nested object resource. + required: false + suboptions: + request: + description: + - The application data to send once the SSL connection has been established + (default value is empty). If both request and response are empty, the connection + establishment alone will indicate health. The request data can only be ASCII. + required: false + response: + description: + - The bytes to match against the beginning of the response data. If left empty + (the default value), any response will indicate health. The response data + can only be ASCII. + required: false + port: + description: + - The TCP port number for the SSL health check request. + - The default value is 443. + required: false + port_name: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. + required: false + proxy_header: + description: + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. + required: false + default: NONE + choices: + - NONE + - PROXY_V1 extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/latest/healthChecks)" - - "Official Documentation: U(https://cloud.google.com/load-balancing/docs/health-checks)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/latest/healthChecks)' +- 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/health-checks)' ''' EXAMPLES = ''' @@ -261,213 +276,213 @@ EXAMPLES = ''' ''' RETURN = ''' - checkIntervalSec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - healthyThreshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - returned: success - type: int - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - timeoutSec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - returned: success - type: int - unhealthyThreshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - returned: success - type: int - type: - description: - - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not specified, - the default is TCP. Exactly one of the protocol-specific health check field must - be specified, which must match type field. - returned: success - type: str - httpHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - host: - description: - - The value of the host header in the HTTP health check request. - - If left empty (default value), the public IP on behalf of which this health check - is performed will be used. - returned: success - type: str - requestPath: - description: - - The request path of the HTTP health check request. - - The default value is /. - returned: success - type: str - port: - description: - - The TCP port number for the HTTP health check request. - - The default value is 80. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - httpsHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - host: - description: - - The value of the host header in the HTTPS health check request. - - If left empty (default value), the public IP on behalf of which this health check - is performed will be used. - returned: success - type: str - requestPath: - description: - - The request path of the HTTPS health check request. - - The default value is /. - returned: success - type: str - port: - description: - - The TCP port number for the HTTPS health check request. - - The default value is 443. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - tcpHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - request: - description: - - The application data to send once the TCP connection has been established (default - value is empty). If both request and response are empty, the connection establishment - alone will indicate health. The request data can only be ASCII. - returned: success - type: str - response: - description: - - The bytes to match against the beginning of the response data. If left empty (the - default value), any response will indicate health. The response data can only be - ASCII. - returned: success - type: str - port: - description: - - The TCP port number for the TCP health check request. - - The default value is 443. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - sslHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - request: - description: - - The application data to send once the SSL connection has been established (default - value is empty). If both request and response are empty, the connection establishment - alone will indicate health. The request data can only be ASCII. - returned: success - type: str - response: - description: - - The bytes to match against the beginning of the response data. If left empty (the - default value), any response will indicate health. The response data can only be - ASCII. - returned: success - type: str - port: - description: - - The TCP port number for the SSL health check request. - - The default value is 443. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str +checkIntervalSec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + returned: success + type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +healthyThreshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + returned: success + type: int +id: + description: + - The unique identifier for the resource. This identifier is defined by the server. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +timeoutSec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater value + than checkIntervalSec. + returned: success + type: int +unhealthyThreshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + returned: success + type: int +type: + description: + - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not + specified, the default is TCP. Exactly one of the protocol-specific health check + field must be specified, which must match type field. + returned: success + type: str +httpHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + host: + description: + - The value of the host header in the HTTP health check request. + - If left empty (default value), the public IP on behalf of which this health + check is performed will be used. + returned: success + type: str + requestPath: + description: + - The request path of the HTTP health check request. + - The default value is /. + returned: success + type: str + port: + description: + - The TCP port number for the HTTP health check request. + - The default value is 80. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str +httpsHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + host: + description: + - The value of the host header in the HTTPS health check request. + - If left empty (default value), the public IP on behalf of which this health + check is performed will be used. + returned: success + type: str + requestPath: + description: + - The request path of the HTTPS health check request. + - The default value is /. + returned: success + type: str + port: + description: + - The TCP port number for the HTTPS health check request. + - The default value is 443. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str +tcpHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + request: + description: + - The application data to send once the TCP connection has been established + (default value is empty). If both request and response are empty, the connection + establishment alone will indicate health. The request data can only be ASCII. + returned: success + type: str + response: + description: + - The bytes to match against the beginning of the response data. If left empty + (the default value), any response will indicate health. The response data + can only be ASCII. + returned: success + type: str + port: + description: + - The TCP port number for the TCP health check request. + - The default value is 443. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str +sslHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + request: + description: + - The application data to send once the SSL connection has been established + (default value is empty). If both request and response are empty, the connection + establishment alone will indicate health. The request data can only be ASCII. + returned: success + type: str + response: + description: + - The bytes to match against the beginning of the response data. If left empty + (the default value), any response will indicate health. The response data + can only be ASCII. + returned: success + type: str + port: + description: + - The TCP port number for the SSL health check request. + - The default value is 443. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str ''' ################################################################################ @@ -583,10 +598,10 @@ def resource_to_request(module): u'timeoutSec': module.params.get('timeout_sec'), u'unhealthyThreshold': module.params.get('unhealthy_threshold'), u'type': module.params.get('type'), - u'httpHealthCheck': HealthCheckHttpHealthCheck(module.params.get('http_health_check', {}), module).to_request(), - u'httpsHealthCheck': HealthCheckHttpsHealthCheck(module.params.get('https_health_check', {}), module).to_request(), - u'tcpHealthCheck': HealthCheckTcpHealthCheck(module.params.get('tcp_health_check', {}), module).to_request(), - u'sslHealthCheck': HealthCheckSslHealthCheck(module.params.get('ssl_health_check', {}), module).to_request() + u'httpHealthCheck': HealthCheckHttphealthcheck(module.params.get('http_health_check', {}), module).to_request(), + u'httpsHealthCheck': HealthCheckHttpshealthcheck(module.params.get('https_health_check', {}), module).to_request(), + u'tcpHealthCheck': HealthCheckTcphealthcheck(module.params.get('tcp_health_check', {}), module).to_request(), + u'sslHealthCheck': HealthCheckSslhealthcheck(module.params.get('ssl_health_check', {}), module).to_request() } return_vals = {} for k, v in request.items(): @@ -661,10 +676,10 @@ def response_to_hash(module, response): u'timeoutSec': response.get(u'timeoutSec'), u'unhealthyThreshold': response.get(u'unhealthyThreshold'), u'type': response.get(u'type'), - u'httpHealthCheck': HealthCheckHttpHealthCheck(response.get(u'httpHealthCheck', {}), module).from_response(), - u'httpsHealthCheck': HealthCheckHttpsHealthCheck(response.get(u'httpsHealthCheck', {}), module).from_response(), - u'tcpHealthCheck': HealthCheckTcpHealthCheck(response.get(u'tcpHealthCheck', {}), module).from_response(), - u'sslHealthCheck': HealthCheckSslHealthCheck(response.get(u'sslHealthCheck', {}), module).from_response() + u'httpHealthCheck': HealthCheckHttphealthcheck(response.get(u'httpHealthCheck', {}), module).from_response(), + u'httpsHealthCheck': HealthCheckHttpshealthcheck(response.get(u'httpsHealthCheck', {}), module).from_response(), + u'tcpHealthCheck': HealthCheckTcphealthcheck(response.get(u'tcpHealthCheck', {}), module).from_response(), + u'sslHealthCheck': HealthCheckSslhealthcheck(response.get(u'sslHealthCheck', {}), module).from_response() } @@ -692,8 +707,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -705,7 +718,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class HealthCheckHttpHealthCheck(object): +class HealthCheckHttphealthcheck(object): def __init__(self, request, module): self.module = module if request: @@ -732,7 +745,7 @@ class HealthCheckHttpHealthCheck(object): }) -class HealthCheckHttpsHealthCheck(object): +class HealthCheckHttpshealthcheck(object): def __init__(self, request, module): self.module = module if request: @@ -759,7 +772,7 @@ class HealthCheckHttpsHealthCheck(object): }) -class HealthCheckTcpHealthCheck(object): +class HealthCheckTcphealthcheck(object): def __init__(self, request, module): self.module = module if request: @@ -786,7 +799,7 @@ class HealthCheckTcpHealthCheck(object): }) -class HealthCheckSslHealthCheck(object): +class HealthCheckSslhealthcheck(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_health_check_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_health_check_facts.py index 4fb8fc5e43..a35592f7a8 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_health_check_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_health_check_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_health_check_facts description: - - Gather facts for GCP HealthCheck +- Gather facts for GCP HealthCheck short_description: Gather facts for GCP HealthCheck version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,217 +61,220 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - checkIntervalSec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - healthyThreshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - returned: success - type: int - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - timeoutSec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - returned: success - type: int - unhealthyThreshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - returned: success - type: int - type: - description: - - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not specified, - the default is TCP. Exactly one of the protocol-specific health check field must - be specified, which must match type field. - returned: success - type: str - httpHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - host: - description: - - The value of the host header in the HTTP health check request. - - If left empty (default value), the public IP on behalf of which this health check - is performed will be used. - returned: success - type: str - requestPath: - description: - - The request path of the HTTP health check request. - - The default value is /. - returned: success - type: str - port: - description: - - The TCP port number for the HTTP health check request. - - The default value is 80. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - httpsHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - host: - description: - - The value of the host header in the HTTPS health check request. - - If left empty (default value), the public IP on behalf of which this health check - is performed will be used. - returned: success - type: str - requestPath: - description: - - The request path of the HTTPS health check request. - - The default value is /. - returned: success - type: str - port: - description: - - The TCP port number for the HTTPS health check request. - - The default value is 443. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - tcpHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - request: - description: - - The application data to send once the TCP connection has been established (default - value is empty). If both request and response are empty, the connection establishment - alone will indicate health. The request data can only be ASCII. - returned: success - type: str - response: - description: - - The bytes to match against the beginning of the response data. If left empty (the - default value), any response will indicate health. The response data can only be - ASCII. - returned: success - type: str - port: - description: - - The TCP port number for the TCP health check request. - - The default value is 443. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - sslHealthCheck: - description: - - A nested object resource. - returned: success - type: complex - contains: - request: - description: - - The application data to send once the SSL connection has been established (default - value is empty). If both request and response are empty, the connection establishment - alone will indicate health. The request data can only be ASCII. - returned: success - type: str - response: - description: - - The bytes to match against the beginning of the response data. If left empty (the - default value), any response will indicate health. The response data can only be - ASCII. - returned: success - type: str - port: - description: - - The TCP port number for the SSL health check request. - - The default value is 443. - returned: success - type: int - portName: - description: - - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name - are defined, port takes precedence. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + checkIntervalSec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + returned: success + type: int + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + healthyThreshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + returned: success + type: int + id: + description: + - The unique identifier for the resource. This identifier is defined by the + server. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + timeoutSec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater + value than checkIntervalSec. + returned: success + type: int + unhealthyThreshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + returned: success + type: int + type: + description: + - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If + not specified, the default is TCP. Exactly one of the protocol-specific health + check field must be specified, which must match type field. + returned: success + type: str + httpHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + host: + description: + - The value of the host header in the HTTP health check request. + - If left empty (default value), the public IP on behalf of which this health + check is performed will be used. + returned: success + type: str + requestPath: + description: + - The request path of the HTTP health check request. + - The default value is /. + returned: success + type: str + port: + description: + - The TCP port number for the HTTP health check request. + - The default value is 80. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and + port_name are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. + returned: success + type: str + httpsHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + host: + description: + - The value of the host header in the HTTPS health check request. + - If left empty (default value), the public IP on behalf of which this health + check is performed will be used. + returned: success + type: str + requestPath: + description: + - The request path of the HTTPS health check request. + - The default value is /. + returned: success + type: str + port: + description: + - The TCP port number for the HTTPS health check request. + - The default value is 443. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and + port_name are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. + returned: success + type: str + tcpHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + request: + description: + - The application data to send once the TCP connection has been established + (default value is empty). If both request and response are empty, the + connection establishment alone will indicate health. The request data + can only be ASCII. + returned: success + type: str + response: + description: + - The bytes to match against the beginning of the response data. If left + empty (the default value), any response will indicate health. The response + data can only be ASCII. + returned: success + type: str + port: + description: + - The TCP port number for the TCP health check request. + - The default value is 443. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and + port_name are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. + returned: success + type: str + sslHealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + request: + description: + - The application data to send once the SSL connection has been established + (default value is empty). If both request and response are empty, the + connection establishment alone will indicate health. The request data + can only be ASCII. + returned: success + type: str + response: + description: + - The bytes to match against the beginning of the response data. If left + empty (the default value), any response will indicate health. The response + data can only be ASCII. + returned: success + type: str + port: + description: + - The TCP port number for the SSL health check request. + - The default value is 443. + returned: success + type: int + portName: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and + port_name are defined, port takes precedence. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the + backend, either NONE or PROXY_V1. The default is NONE. + returned: success + type: str ''' ################################################################################ @@ -293,7 +295,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py index df8c7f6758..75d259ef92 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py @@ -32,78 +32,82 @@ DOCUMENTATION = ''' --- module: gcp_compute_http_health_check description: - - An HttpHealthCheck resource. This resource defines a template for how individual - VMs should be checked for health, via HTTP. +- An HttpHealthCheck resource. This resource defines a template for how individual + VMs should be checked for health, via HTTP. short_description: Creates a GCP HttpHealthCheck version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - check_interval_sec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - required: false - default: 5 - aliases: [check_interval_seconds] + state: description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - healthy_threshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - required: false - host: - description: - - The value of the host header in the HTTP health check request. If left empty (default - value), the public IP on behalf of which this health check is performed will be - used. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - port: - description: - - The TCP port number for the HTTP health check request. - - The default value is 80. - required: false - request_path: - description: - - The request path of the HTTP health check request. - - The default value is /. - required: false - timeout_sec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - required: false - aliases: [timeout_seconds] - unhealthy_threshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - required: false + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + check_interval_sec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + required: false + default: '5' + aliases: + - check_interval_seconds + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + healthy_threshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + required: false + host: + description: + - The value of the host header in the HTTP health check request. If left empty + (default value), the public IP on behalf of which this health check is performed + will be used. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + port: + description: + - The TCP port number for the HTTP health check request. + - The default value is 80. + required: false + request_path: + description: + - The request path of the HTTP health check request. + - The default value is /. + required: false + timeout_sec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater + value than checkIntervalSec. + required: false + aliases: + - timeout_seconds + unhealthy_threshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + required: false extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks)" - - "Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks)' +- 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)' ''' EXAMPLES = ''' @@ -121,75 +125,75 @@ EXAMPLES = ''' ''' RETURN = ''' - checkIntervalSec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - healthyThreshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - returned: success - type: int - host: - description: - - The value of the host header in the HTTP health check request. If left empty (default - value), the public IP on behalf of which this health check is performed will be - used. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - port: - description: - - The TCP port number for the HTTP health check request. - - The default value is 80. - returned: success - type: int - requestPath: - description: - - The request path of the HTTP health check request. - - The default value is /. - returned: success - type: str - timeoutSec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - returned: success - type: int - unhealthyThreshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - returned: success - type: int +checkIntervalSec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + returned: success + type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +healthyThreshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + returned: success + type: int +host: + description: + - The value of the host header in the HTTP health check request. If left empty (default + value), the public IP on behalf of which this health check is performed will be + used. + returned: success + type: str +id: + description: + - The unique identifier for the resource. This identifier is defined by the server. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +port: + description: + - The TCP port number for the HTTP health check request. + - The default value is 80. + returned: success + type: int +requestPath: + description: + - The request path of the HTTP health check request. + - The default value is /. + returned: success + type: str +timeoutSec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater value + than checkIntervalSec. + returned: success + type: int +unhealthyThreshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + returned: success + type: int ''' ################################################################################ @@ -384,8 +388,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_facts.py index 6fc063d023..bb78b4b947 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_http_health_check_facts description: - - Gather facts for GCP HttpHealthCheck +- Gather facts for GCP HttpHealthCheck short_description: Gather facts for GCP HttpHealthCheck version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,79 +61,80 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - checkIntervalSec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - healthyThreshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - returned: success - type: int - host: - description: - - The value of the host header in the HTTP health check request. If left empty (default - value), the public IP on behalf of which this health check is performed will be - used. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - port: - description: - - The TCP port number for the HTTP health check request. - - The default value is 80. - returned: success - type: int - requestPath: - description: - - The request path of the HTTP health check request. - - The default value is /. - returned: success - type: str - timeoutSec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - returned: success - type: int - unhealthyThreshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - returned: success - type: int + description: List of items + returned: always + type: complex + contains: + checkIntervalSec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + returned: success + type: int + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + healthyThreshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + returned: success + type: int + host: + description: + - The value of the host header in the HTTP health check request. If left empty + (default value), the public IP on behalf of which this health check is performed + will be used. + returned: success + type: str + id: + description: + - The unique identifier for the resource. This identifier is defined by the + server. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + port: + description: + - The TCP port number for the HTTP health check request. + - The default value is 80. + returned: success + type: int + requestPath: + description: + - The request path of the HTTP health check request. + - The default value is /. + returned: success + type: str + timeoutSec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater + value than checkIntervalSec. + returned: success + type: int + unhealthyThreshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + returned: success + type: int ''' ################################################################################ @@ -155,7 +155,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py index 96e0101bab..be515ce034 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py @@ -32,76 +32,79 @@ DOCUMENTATION = ''' --- module: gcp_compute_https_health_check description: - - An HttpsHealthCheck resource. This resource defines a template for how individual - VMs should be checked for health, via HTTPS. +- An HttpsHealthCheck resource. This resource defines a template for how individual + VMs should be checked for health, via HTTPS. short_description: Creates a GCP HttpsHealthCheck version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - check_interval_sec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - required: false + state: description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - healthy_threshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - required: false - host: - description: - - The value of the host header in the HTTPS health check request. If left empty (default - value), the public IP on behalf of which this health check is performed will be - used. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - port: - description: - - The TCP port number for the HTTPS health check request. - - The default value is 80. - required: false - request_path: - description: - - The request path of the HTTPS health check request. - - The default value is /. - required: false - timeout_sec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - required: false - aliases: [timeout_seconds] - unhealthy_threshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - required: false + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + check_interval_sec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + required: false + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + healthy_threshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + required: false + host: + description: + - The value of the host header in the HTTPS health check request. If left empty + (default value), the public IP on behalf of which this health check is performed + will be used. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + port: + description: + - The TCP port number for the HTTPS health check request. + - The default value is 80. + required: false + request_path: + description: + - The request path of the HTTPS health check request. + - The default value is /. + required: false + timeout_sec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater + value than checkIntervalSec. + required: false + aliases: + - timeout_seconds + unhealthy_threshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + required: false extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpsHealthChecks)" - - "Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpsHealthChecks)' +- 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)' ''' EXAMPLES = ''' @@ -119,75 +122,75 @@ EXAMPLES = ''' ''' RETURN = ''' - checkIntervalSec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - healthyThreshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - returned: success - type: int - host: - description: - - The value of the host header in the HTTPS health check request. If left empty (default - value), the public IP on behalf of which this health check is performed will be - used. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - port: - description: - - The TCP port number for the HTTPS health check request. - - The default value is 80. - returned: success - type: int - requestPath: - description: - - The request path of the HTTPS health check request. - - The default value is /. - returned: success - type: str - timeoutSec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - returned: success - type: int - unhealthyThreshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - returned: success - type: int +checkIntervalSec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + returned: success + type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +healthyThreshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + returned: success + type: int +host: + description: + - The value of the host header in the HTTPS health check request. If left empty + (default value), the public IP on behalf of which this health check is performed + will be used. + returned: success + type: str +id: + description: + - The unique identifier for the resource. This identifier is defined by the server. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +port: + description: + - The TCP port number for the HTTPS health check request. + - The default value is 80. + returned: success + type: int +requestPath: + description: + - The request path of the HTTPS health check request. + - The default value is /. + returned: success + type: str +timeoutSec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater value + than checkIntervalSec. + returned: success + type: int +unhealthyThreshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + returned: success + type: int ''' ################################################################################ @@ -382,8 +385,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_facts.py index 5a599f764d..ca015c068b 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_https_health_check_facts description: - - Gather facts for GCP HttpsHealthCheck +- Gather facts for GCP HttpsHealthCheck short_description: Gather facts for GCP HttpsHealthCheck version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,79 +61,80 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - checkIntervalSec: - description: - - How often (in seconds) to send a health check. The default value is 5 seconds. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - healthyThreshold: - description: - - A so-far unhealthy instance will be marked healthy after this many consecutive successes. - The default value is 2. - returned: success - type: int - host: - description: - - The value of the host header in the HTTPS health check request. If left empty (default - value), the public IP on behalf of which this health check is performed will be - used. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - port: - description: - - The TCP port number for the HTTPS health check request. - - The default value is 80. - returned: success - type: int - requestPath: - description: - - The request path of the HTTPS health check request. - - The default value is /. - returned: success - type: str - timeoutSec: - description: - - How long (in seconds) to wait before claiming failure. - - The default value is 5 seconds. It is invalid for timeoutSec to have greater value - than checkIntervalSec. - returned: success - type: int - unhealthyThreshold: - description: - - A so-far healthy instance will be marked unhealthy after this many consecutive failures. - The default value is 2. - returned: success - type: int + description: List of items + returned: always + type: complex + contains: + checkIntervalSec: + description: + - How often (in seconds) to send a health check. The default value is 5 seconds. + returned: success + type: int + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + healthyThreshold: + description: + - A so-far unhealthy instance will be marked healthy after this many consecutive + successes. The default value is 2. + returned: success + type: int + host: + description: + - The value of the host header in the HTTPS health check request. If left empty + (default value), the public IP on behalf of which this health check is performed + will be used. + returned: success + type: str + id: + description: + - The unique identifier for the resource. This identifier is defined by the + server. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + port: + description: + - The TCP port number for the HTTPS health check request. + - The default value is 80. + returned: success + type: int + requestPath: + description: + - The request path of the HTTPS health check request. + - The default value is /. + returned: success + type: str + timeoutSec: + description: + - How long (in seconds) to wait before claiming failure. + - The default value is 5 seconds. It is invalid for timeoutSec to have greater + value than checkIntervalSec. + returned: success + type: int + unhealthyThreshold: + description: + - A so-far healthy instance will be marked unhealthy after this many consecutive + failures. The default value is 2. + returned: success + type: int ''' ################################################################################ @@ -155,7 +155,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_image.py b/lib/ansible/modules/cloud/google/gcp_compute_image.py index bf3307b985..80356c9b26 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_image.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_image.py @@ -32,156 +32,161 @@ DOCUMENTATION = ''' --- module: gcp_compute_image description: - - Represents an Image resource. - - Google Compute Engine uses operating system images to create the root persistent - disks for your instances. You specify an image when you create an instance. Images - contain a boot loader, an operating system, and a root file system. Linux operating - system images are also capable of running containers on Compute Engine. - - Images can be either public or custom. - - Public images are provided and maintained by Google, open-source communities, and - third-party vendors. By default, all projects have access to these images and can - use them to create instances. Custom images are available only to your project. - You can create a custom image from root persistent disks and other images. Then, - use the custom image to create an instance. +- Represents an Image resource. +- Google Compute Engine uses operating system images to create the root persistent + disks for your instances. You specify an image when you create an instance. Images + contain a boot loader, an operating system, and a root file system. Linux operating + system images are also capable of running containers on Compute Engine. +- Images can be either public or custom. +- Public images are provided and maintained by Google, open-source communities, and + third-party vendors. By default, all projects have access to these images and can + use them to create instances. Custom images are available only to your project. + You can create a custom image from root persistent disks and other images. Then, + use the custom image to create an instance. short_description: Creates a GCP Image version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + disk_size_gb: + description: + - Size of the image when restored onto a persistent disk (in GB). + required: false + family: + description: + - The name of the image family to which this image belongs. You can create disks + by specifying an image family instead of a specific image name. The image family + always returns its latest image that is not deprecated. The name of the image + family must comply with RFC1035. + required: false + guest_os_features: + description: + - A list of features to enable on the guest OS. Applicable for bootable images + only. Currently, only one feature can be enabled, VIRTIO_SCSI_MULTIQUEUE, which + allows each virtual CPU to have its own queue. For Windows images, you can only + enable VIRTIO_SCSI_MULTIQUEUE on images with driver version 1.2.0.1621 or higher. + Linux images with kernel versions 3.17 and higher will support VIRTIO_SCSI_MULTIQUEUE. + - For new Windows images, the server might also populate this field with the value + WINDOWS, to indicate that this is a Windows image. + - This value is purely informational and does not enable or disable any features. + required: false + suboptions: + type: description: - - An optional description of this resource. Provide this property when you create - the resource. + - The type of supported feature. Currenty only VIRTIO_SCSI_MULTIQUEUE is supported. + For newer Windows images, the server might also populate this property with + the value WINDOWS to indicate that this is a Windows image. This value is + purely informational and does not enable or disable any features. required: false - disk_size_gb: + choices: + - VIRTIO_SCSI_MULTIQUEUE + image_encryption_key: + description: + - Encrypts the image using a customer-supplied encryption key. + - After you encrypt an image with a customer-supplied key, you must provide the + same key if you use the image later (e.g. to create a disk from the image) . + required: false + suboptions: + raw_key: description: - - Size of the image when restored onto a persistent disk (in GB). + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. required: false - family: + sha256: description: - - The name of the image family to which this image belongs. You can create disks by - specifying an image family instead of a specific image name. The image family always - returns its latest image that is not deprecated. The name of the image family must - comply with RFC1035. + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. required: false - guest_os_features: + licenses: + description: + - Any applicable license URI. + required: false + name: + description: + - Name of the resource; provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + raw_disk: + description: + - The parameters of the raw disk image. + required: false + suboptions: + container_type: description: - - A list of features to enable on the guest OS. Applicable for bootable images only. - Currently, only one feature can be enabled, VIRTIO_SCSI_MULTIQUEUE, which allows - each virtual CPU to have its own queue. For Windows images, you can only enable - VIRTIO_SCSI_MULTIQUEUE on images with driver version 1.2.0.1621 or higher. Linux - images with kernel versions 3.17 and higher will support VIRTIO_SCSI_MULTIQUEUE. - - For new Windows images, the server might also populate this field with the value - WINDOWS, to indicate that this is a Windows image. - - This value is purely informational and does not enable or disable any features. + - The format used to encode and transmit the block device, which should be + TAR. This is just a container and transmission format and not a runtime + format. Provided by the client when the disk image is created. required: false - suboptions: - type: - description: - - The type of supported feature. Currenty only VIRTIO_SCSI_MULTIQUEUE is supported. - For newer Windows images, the server might also populate this property with the - value WINDOWS to indicate that this is a Windows image. This value is purely informational - and does not enable or disable any features. - required: false - choices: ['VIRTIO_SCSI_MULTIQUEUE'] - image_encryption_key: + choices: + - TAR + sha1_checksum: description: - - Encrypts the image using a customer-supplied encryption key. - - After you encrypt an image with a customer-supplied key, you must provide the same - key if you use the image later (e.g. to create a disk from the image) . + - An optional SHA1 checksum of the disk image before unpackaging. + - This is provided by the client when the disk image is created. required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - licenses: + source: description: - - Any applicable license URI. + - The full Google Cloud Storage URL where disk storage is stored You must + provide either this property or the sourceDisk property but not both. required: false - name: + source_disk: + description: + - Refers to a gcompute_disk object You must provide either this property or the + rawDisk.source property but not both to create an image. + - 'This field represents a link to a Disk resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_disk + task and then set this source_disk field to "{{ name-of-resource }}" Alternatively, + you can set this source_disk to a dictionary with the selfLink key where the + value is the selfLink of your Disk' + required: false + source_disk_encryption_key: + description: + - The customer-supplied encryption key of the source disk. Required if the source + disk is protected by a customer-supplied encryption key. + required: false + suboptions: + raw_key: description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - raw_disk: - description: - - The parameters of the raw disk image. + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. required: false - suboptions: - container_type: - description: - - The format used to encode and transmit the block device, which should be TAR. This - is just a container and transmission format and not a runtime format. Provided by - the client when the disk image is created. - required: false - choices: ['TAR'] - sha1_checksum: - description: - - An optional SHA1 checksum of the disk image before unpackaging. - - This is provided by the client when the disk image is created. - required: false - source: - description: - - The full Google Cloud Storage URL where disk storage is stored You must provide - either this property or the sourceDisk property but not both. - required: false - source_disk: + sha256: description: - - Refers to a gcompute_disk object You must provide either this property or the rawDisk.source - property but not both to create an image. - - 'This field represents a link to a Disk resource in GCP. It can be specified in - two ways. You can add `register: name-of-resource` to a gcp_compute_disk task and - then set this source_disk field to "{{ name-of-resource }}" Alternatively, you can - set this source_disk to a dictionary with the selfLink key where the value is the - selfLink of your Disk.' + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. required: false - source_disk_encryption_key: - description: - - The customer-supplied encryption key of the source disk. Required if the source - disk is protected by a customer-supplied encryption key. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - source_disk_id: - description: - - The ID value of the disk used to create this image. This value may be used to determine - whether the image was taken from the current or a previous instance of a given disk - name. - required: false - source_type: - description: - - The type of the image used to create this disk. The default and only value is RAW - . - required: false - choices: ['RAW'] + source_disk_id: + description: + - The ID value of the disk used to create this image. This value may be used to + determine whether the image was taken from the current or a previous instance + of a given disk name. + required: false + source_type: + description: + - The type of the image used to create this disk. The default and only value is + RAW . + required: false + choices: + - RAW extends_documentation_fragment: gcp ''' @@ -207,202 +212,202 @@ EXAMPLES = ''' ''' RETURN = ''' - archiveSizeBytes: - description: - - Size of the image tar.gz archive stored in Google Cloud Storage (in bytes). - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str +archiveSizeBytes: + description: + - Size of the image tar.gz archive stored in Google Cloud Storage (in bytes). + returned: success + type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +deprecated: + description: + - The deprecation status associated with this image. + returned: success + type: complex + contains: + deleted: + description: + - An optional RFC3339 timestamp on or after which the state of this resource + is intended to change to DELETED. This is only informational and the status + will not change unless the client explicitly changes it. + returned: success + type: str deprecated: - description: - - The deprecation status associated with this image. - returned: success - type: complex - contains: - deleted: - description: - - An optional RFC3339 timestamp on or after which the state of this resource is intended - to change to DELETED. This is only informational and the status will not change - unless the client explicitly changes it. - returned: success - type: str - deprecated: - description: - - An optional RFC3339 timestamp on or after which the state of this resource is intended - to change to DEPRECATED. This is only informational and the status will not change - unless the client explicitly changes it. - returned: success - type: str - obsolete: - description: - - An optional RFC3339 timestamp on or after which the state of this resource is intended - to change to OBSOLETE. This is only informational and the status will not change - unless the client explicitly changes it. - returned: success - type: str - replacement: - description: - - The URL of the suggested replacement for a deprecated resource. - - The suggested replacement resource must be the same kind of resource as the deprecated - resource. - returned: success - type: str - state: - description: - - The deprecation state of this resource. This can be DEPRECATED, OBSOLETE, or DELETED. - Operations which create a new resource using a DEPRECATED resource will return successfully, - but with a warning indicating the deprecated resource and recommending its replacement. - Operations which use OBSOLETE or DELETED resources will be rejected and result in - an error. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - diskSizeGb: - description: - - Size of the image when restored onto a persistent disk (in GB). - returned: success - type: int - family: - description: - - The name of the image family to which this image belongs. You can create disks by - specifying an image family instead of a specific image name. The image family always - returns its latest image that is not deprecated. The name of the image family must - comply with RFC1035. - returned: success - type: str - guestOsFeatures: - description: - - A list of features to enable on the guest OS. Applicable for bootable images only. - Currently, only one feature can be enabled, VIRTIO_SCSI_MULTIQUEUE, which allows - each virtual CPU to have its own queue. For Windows images, you can only enable - VIRTIO_SCSI_MULTIQUEUE on images with driver version 1.2.0.1621 or higher. Linux - images with kernel versions 3.17 and higher will support VIRTIO_SCSI_MULTIQUEUE. - - For new Windows images, the server might also populate this field with the value - WINDOWS, to indicate that this is a Windows image. - - This value is purely informational and does not enable or disable any features. - returned: success - type: complex - contains: - type: - description: - - The type of supported feature. Currenty only VIRTIO_SCSI_MULTIQUEUE is supported. - For newer Windows images, the server might also populate this property with the - value WINDOWS to indicate that this is a Windows image. This value is purely informational - and does not enable or disable any features. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - imageEncryptionKey: - description: - - Encrypts the image using a customer-supplied encryption key. - - After you encrypt an image with a customer-supplied key, you must provide the same - key if you use the image later (e.g. to create a disk from the image) . - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - licenses: - description: - - Any applicable license URI. - returned: success - type: list - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - rawDisk: - description: - - The parameters of the raw disk image. - returned: success - type: complex - contains: - containerType: - description: - - The format used to encode and transmit the block device, which should be TAR. This - is just a container and transmission format and not a runtime format. Provided by - the client when the disk image is created. - returned: success - type: str - sha1Checksum: - description: - - An optional SHA1 checksum of the disk image before unpackaging. - - This is provided by the client when the disk image is created. - returned: success - type: str - source: - description: - - The full Google Cloud Storage URL where disk storage is stored You must provide - either this property or the sourceDisk property but not both. - returned: success - type: str - sourceDisk: - description: - - Refers to a gcompute_disk object You must provide either this property or the rawDisk.source - property but not both to create an image. - returned: success - type: dict - sourceDiskEncryptionKey: - description: - - The customer-supplied encryption key of the source disk. Required if the source - disk is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceDiskId: - description: - - The ID value of the disk used to create this image. This value may be used to determine - whether the image was taken from the current or a previous instance of a given disk - name. - returned: success - type: str - sourceType: - description: - - The type of the image used to create this disk. The default and only value is RAW - . - returned: success - type: str + description: + - An optional RFC3339 timestamp on or after which the state of this resource + is intended to change to DEPRECATED. This is only informational and the status + will not change unless the client explicitly changes it. + returned: success + type: str + obsolete: + description: + - An optional RFC3339 timestamp on or after which the state of this resource + is intended to change to OBSOLETE. This is only informational and the status + will not change unless the client explicitly changes it. + returned: success + type: str + replacement: + description: + - The URL of the suggested replacement for a deprecated resource. + - The suggested replacement resource must be the same kind of resource as the + deprecated resource. + returned: success + type: str + state: + description: + - The deprecation state of this resource. This can be DEPRECATED, OBSOLETE, + or DELETED. Operations which create a new resource using a DEPRECATED resource + will return successfully, but with a warning indicating the deprecated resource + and recommending its replacement. Operations which use OBSOLETE or DELETED + resources will be rejected and result in an error. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +diskSizeGb: + description: + - Size of the image when restored onto a persistent disk (in GB). + returned: success + type: int +family: + description: + - The name of the image family to which this image belongs. You can create disks + by specifying an image family instead of a specific image name. The image family + always returns its latest image that is not deprecated. The name of the image + family must comply with RFC1035. + returned: success + type: str +guestOsFeatures: + description: + - A list of features to enable on the guest OS. Applicable for bootable images only. + Currently, only one feature can be enabled, VIRTIO_SCSI_MULTIQUEUE, which allows + each virtual CPU to have its own queue. For Windows images, you can only enable + VIRTIO_SCSI_MULTIQUEUE on images with driver version 1.2.0.1621 or higher. Linux + images with kernel versions 3.17 and higher will support VIRTIO_SCSI_MULTIQUEUE. + - For new Windows images, the server might also populate this field with the value + WINDOWS, to indicate that this is a Windows image. + - This value is purely informational and does not enable or disable any features. + returned: success + type: complex + contains: + type: + description: + - The type of supported feature. Currenty only VIRTIO_SCSI_MULTIQUEUE is supported. + For newer Windows images, the server might also populate this property with + the value WINDOWS to indicate that this is a Windows image. This value is + purely informational and does not enable or disable any features. + returned: success + type: str +id: + description: + - The unique identifier for the resource. This identifier is defined by the server. + returned: success + type: int +imageEncryptionKey: + description: + - Encrypts the image using a customer-supplied encryption key. + - After you encrypt an image with a customer-supplied key, you must provide the + same key if you use the image later (e.g. to create a disk from the image) . + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str +licenses: + description: + - Any applicable license URI. + returned: success + type: list +name: + description: + - Name of the resource; provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +rawDisk: + description: + - The parameters of the raw disk image. + returned: success + type: complex + contains: + containerType: + description: + - The format used to encode and transmit the block device, which should be TAR. + This is just a container and transmission format and not a runtime format. + Provided by the client when the disk image is created. + returned: success + type: str + sha1Checksum: + description: + - An optional SHA1 checksum of the disk image before unpackaging. + - This is provided by the client when the disk image is created. + returned: success + type: str + source: + description: + - The full Google Cloud Storage URL where disk storage is stored You must provide + either this property or the sourceDisk property but not both. + returned: success + type: str +sourceDisk: + description: + - Refers to a gcompute_disk object You must provide either this property or the + rawDisk.source property but not both to create an image. + returned: success + type: dict +sourceDiskEncryptionKey: + description: + - The customer-supplied encryption key of the source disk. Required if the source + disk is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str +sourceDiskId: + description: + - The ID value of the disk used to create this image. This value may be used to + determine whether the image was taken from the current or a previous instance + of a given disk name. + returned: success + type: str +sourceType: + description: + - The type of the image used to create this disk. The default and only value is + RAW . + returned: success + type: str ''' ################################################################################ @@ -503,13 +508,13 @@ def resource_to_request(module): u'description': module.params.get('description'), u'diskSizeGb': module.params.get('disk_size_gb'), u'family': module.params.get('family'), - u'guestOsFeatures': ImageGuestOsFeaturesArray(module.params.get('guest_os_features', []), module).to_request(), - u'imageEncryptionKey': ImageImageEncryptionKey(module.params.get('image_encryption_key', {}), module).to_request(), + u'guestOsFeatures': ImageGuestosfeaturesArray(module.params.get('guest_os_features', []), module).to_request(), + u'imageEncryptionKey': ImageImageencryptionkey(module.params.get('image_encryption_key', {}), module).to_request(), u'licenses': module.params.get('licenses'), u'name': module.params.get('name'), - u'rawDisk': ImageRawDisk(module.params.get('raw_disk', {}), module).to_request(), + u'rawDisk': ImageRawdisk(module.params.get('raw_disk', {}), module).to_request(), u'sourceDisk': replace_resource_dict(module.params.get(u'source_disk', {}), 'selfLink'), - u'sourceDiskEncryptionKey': ImageSourceDiskEncryptionKey(module.params.get('source_disk_encryption_key', {}), module).to_request(), + u'sourceDiskEncryptionKey': ImageSourcediskencryptionkey(module.params.get('source_disk_encryption_key', {}), module).to_request(), u'sourceDiskId': module.params.get('source_disk_id'), u'sourceType': module.params.get('source_type') } @@ -583,14 +588,14 @@ def response_to_hash(module, response): u'description': response.get(u'description'), u'diskSizeGb': response.get(u'diskSizeGb'), u'family': response.get(u'family'), - u'guestOsFeatures': ImageGuestOsFeaturesArray(response.get(u'guestOsFeatures', []), module).from_response(), + u'guestOsFeatures': ImageGuestosfeaturesArray(response.get(u'guestOsFeatures', []), module).from_response(), u'id': response.get(u'id'), - u'imageEncryptionKey': ImageImageEncryptionKey(response.get(u'imageEncryptionKey', {}), module).from_response(), + u'imageEncryptionKey': ImageImageencryptionkey(response.get(u'imageEncryptionKey', {}), module).from_response(), u'licenses': response.get(u'licenses'), u'name': response.get(u'name'), - u'rawDisk': ImageRawDisk(response.get(u'rawDisk', {}), module).from_response(), + u'rawDisk': ImageRawdisk(response.get(u'rawDisk', {}), module).from_response(), u'sourceDisk': response.get(u'sourceDisk'), - u'sourceDiskEncryptionKey': ImageSourceDiskEncryptionKey(response.get(u'sourceDiskEncryptionKey', {}), module).from_response(), + u'sourceDiskEncryptionKey': ImageSourcediskencryptionkey(response.get(u'sourceDiskEncryptionKey', {}), module).from_response(), u'sourceDiskId': response.get(u'sourceDiskId'), u'sourceType': response.get(u'sourceType') } @@ -620,8 +625,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -660,7 +663,7 @@ class ImageDeprecated(object): }) -class ImageGuestOsFeaturesArray(object): +class ImageGuestosfeaturesArray(object): def __init__(self, request, module): self.module = module if request: @@ -691,7 +694,7 @@ class ImageGuestOsFeaturesArray(object): }) -class ImageImageEncryptionKey(object): +class ImageImageencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -712,7 +715,7 @@ class ImageImageEncryptionKey(object): }) -class ImageRawDisk(object): +class ImageRawdisk(object): def __init__(self, request, module): self.module = module if request: @@ -735,7 +738,7 @@ class ImageRawDisk(object): }) -class ImageSourceDiskEncryptionKey(object): +class ImageSourcediskencryptionkey(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_image_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_image_facts.py index 17ecd7a8d0..22eede9405 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_image_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_image_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_image_facts description: - - Gather facts for GCP Image +- Gather facts for GCP Image short_description: Gather facts for GCP Image version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,206 +61,210 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - archiveSizeBytes: - description: - - Size of the image tar.gz archive stored in Google Cloud Storage (in bytes). - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + archiveSizeBytes: + description: + - Size of the image tar.gz archive stored in Google Cloud Storage (in bytes). + returned: success + type: int + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + deprecated: + description: + - The deprecation status associated with this image. + returned: success + type: complex + contains: + deleted: + description: + - An optional RFC3339 timestamp on or after which the state of this resource + is intended to change to DELETED. This is only informational and the status + will not change unless the client explicitly changes it. + returned: success + type: str deprecated: - description: - - The deprecation status associated with this image. - returned: success - type: complex - contains: - deleted: - description: - - An optional RFC3339 timestamp on or after which the state of this resource is intended - to change to DELETED. This is only informational and the status will not change - unless the client explicitly changes it. - returned: success - type: str - deprecated: - description: - - An optional RFC3339 timestamp on or after which the state of this resource is intended - to change to DEPRECATED. This is only informational and the status will not change - unless the client explicitly changes it. - returned: success - type: str - obsolete: - description: - - An optional RFC3339 timestamp on or after which the state of this resource is intended - to change to OBSOLETE. This is only informational and the status will not change - unless the client explicitly changes it. - returned: success - type: str - replacement: - description: - - The URL of the suggested replacement for a deprecated resource. - - The suggested replacement resource must be the same kind of resource as the deprecated - resource. - returned: success - type: str - state: - description: - - The deprecation state of this resource. This can be DEPRECATED, OBSOLETE, or DELETED. - Operations which create a new resource using a DEPRECATED resource will return successfully, - but with a warning indicating the deprecated resource and recommending its replacement. - Operations which use OBSOLETE or DELETED resources will be rejected and result in - an error. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - diskSizeGb: - description: - - Size of the image when restored onto a persistent disk (in GB). - returned: success - type: int - family: - description: - - The name of the image family to which this image belongs. You can create disks by - specifying an image family instead of a specific image name. The image family always - returns its latest image that is not deprecated. The name of the image family must - comply with RFC1035. - returned: success - type: str - guestOsFeatures: - description: - - A list of features to enable on the guest OS. Applicable for bootable images only. - Currently, only one feature can be enabled, VIRTIO_SCSI_MULTIQUEUE, which allows - each virtual CPU to have its own queue. For Windows images, you can only enable - VIRTIO_SCSI_MULTIQUEUE on images with driver version 1.2.0.1621 or higher. Linux - images with kernel versions 3.17 and higher will support VIRTIO_SCSI_MULTIQUEUE. - - For new Windows images, the server might also populate this field with the value - WINDOWS, to indicate that this is a Windows image. - - This value is purely informational and does not enable or disable any features. - returned: success - type: complex - contains: - type: - description: - - The type of supported feature. Currenty only VIRTIO_SCSI_MULTIQUEUE is supported. - For newer Windows images, the server might also populate this property with the - value WINDOWS to indicate that this is a Windows image. This value is purely informational - and does not enable or disable any features. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - imageEncryptionKey: - description: - - Encrypts the image using a customer-supplied encryption key. - - After you encrypt an image with a customer-supplied key, you must provide the same - key if you use the image later (e.g. to create a disk from the image) . - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - licenses: - description: - - Any applicable license URI. - returned: success - type: list - name: - description: - - Name of the resource; provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - rawDisk: - description: - - The parameters of the raw disk image. - returned: success - type: complex - contains: - containerType: - description: - - The format used to encode and transmit the block device, which should be TAR. This - is just a container and transmission format and not a runtime format. Provided by - the client when the disk image is created. - returned: success - type: str - sha1Checksum: - description: - - An optional SHA1 checksum of the disk image before unpackaging. - - This is provided by the client when the disk image is created. - returned: success - type: str - source: - description: - - The full Google Cloud Storage URL where disk storage is stored You must provide - either this property or the sourceDisk property but not both. - returned: success - type: str - sourceDisk: - description: - - Refers to a gcompute_disk object You must provide either this property or the rawDisk.source - property but not both to create an image. - returned: success - type: dict - sourceDiskEncryptionKey: - description: - - The customer-supplied encryption key of the source disk. Required if the source - disk is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceDiskId: - description: - - The ID value of the disk used to create this image. This value may be used to determine - whether the image was taken from the current or a previous instance of a given disk - name. - returned: success - type: str - sourceType: - description: - - The type of the image used to create this disk. The default and only value is RAW - . - returned: success - type: str + description: + - An optional RFC3339 timestamp on or after which the state of this resource + is intended to change to DEPRECATED. This is only informational and the + status will not change unless the client explicitly changes it. + returned: success + type: str + obsolete: + description: + - An optional RFC3339 timestamp on or after which the state of this resource + is intended to change to OBSOLETE. This is only informational and the + status will not change unless the client explicitly changes it. + returned: success + type: str + replacement: + description: + - The URL of the suggested replacement for a deprecated resource. + - The suggested replacement resource must be the same kind of resource as + the deprecated resource. + returned: success + type: str + state: + description: + - The deprecation state of this resource. This can be DEPRECATED, OBSOLETE, + or DELETED. Operations which create a new resource using a DEPRECATED + resource will return successfully, but with a warning indicating the deprecated + resource and recommending its replacement. Operations which use OBSOLETE + or DELETED resources will be rejected and result in an error. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + diskSizeGb: + description: + - Size of the image when restored onto a persistent disk (in GB). + returned: success + type: int + family: + description: + - The name of the image family to which this image belongs. You can create disks + by specifying an image family instead of a specific image name. The image + family always returns its latest image that is not deprecated. The name of + the image family must comply with RFC1035. + returned: success + type: str + guestOsFeatures: + description: + - A list of features to enable on the guest OS. Applicable for bootable images + only. Currently, only one feature can be enabled, VIRTIO_SCSI_MULTIQUEUE, + which allows each virtual CPU to have its own queue. For Windows images, you + can only enable VIRTIO_SCSI_MULTIQUEUE on images with driver version 1.2.0.1621 + or higher. Linux images with kernel versions 3.17 and higher will support + VIRTIO_SCSI_MULTIQUEUE. + - For new Windows images, the server might also populate this field with the + value WINDOWS, to indicate that this is a Windows image. + - This value is purely informational and does not enable or disable any features. + returned: success + type: complex + contains: + type: + description: + - The type of supported feature. Currenty only VIRTIO_SCSI_MULTIQUEUE is + supported. For newer Windows images, the server might also populate this + property with the value WINDOWS to indicate that this is a Windows image. + This value is purely informational and does not enable or disable any + features. + returned: success + type: str + id: + description: + - The unique identifier for the resource. This identifier is defined by the + server. + returned: success + type: int + imageEncryptionKey: + description: + - Encrypts the image using a customer-supplied encryption key. + - After you encrypt an image with a customer-supplied key, you must provide + the same key if you use the image later (e.g. to create a disk from the image) + . + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + licenses: + description: + - Any applicable license URI. + returned: success + type: list + name: + description: + - Name of the resource; provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + rawDisk: + description: + - The parameters of the raw disk image. + returned: success + type: complex + contains: + containerType: + description: + - The format used to encode and transmit the block device, which should + be TAR. This is just a container and transmission format and not a runtime + format. Provided by the client when the disk image is created. + returned: success + type: str + sha1Checksum: + description: + - An optional SHA1 checksum of the disk image before unpackaging. + - This is provided by the client when the disk image is created. + returned: success + type: str + source: + description: + - The full Google Cloud Storage URL where disk storage is stored You must + provide either this property or the sourceDisk property but not both. + returned: success + type: str + sourceDisk: + description: + - Refers to a gcompute_disk object You must provide either this property or + the rawDisk.source property but not both to create an image. + returned: success + type: dict + sourceDiskEncryptionKey: + description: + - The customer-supplied encryption key of the source disk. Required if the source + disk is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + sourceDiskId: + description: + - The ID value of the disk used to create this image. This value may be used + to determine whether the image was taken from the current or a previous instance + of a given disk name. + returned: success + type: str + sourceType: + description: + - The type of the image used to create this disk. The default and only value + is RAW . + returned: success + type: str ''' ################################################################################ @@ -282,7 +285,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance.py b/lib/ansible/modules/cloud/google/gcp_compute_instance.py index 4c52273d07..b71b0d7173 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance.py @@ -32,357 +32,374 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance description: - - An instance is a virtual machine (VM) hosted on Google's infrastructure. +- An instance is a virtual machine (VM) hosted on Google's infrastructure. short_description: Creates a GCP Instance version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + can_ip_forward: + description: + - Allows this instance to send and receive packets with non-matching destination + or source IPs. This is required if you plan to use this instance to forward + routes. + required: false + type: bool + disks: + description: + - An array of disks that are associated with the instances that are created from + this template. + required: false + suboptions: + auto_delete: description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - can_ip_forward: - description: - - Allows this instance to send and receive packets with non-matching destination or - source IPs. This is required if you plan to use this instance to forward routes. + - Specifies whether the disk will be auto-deleted when the instance is deleted + (but not when the disk is detached from the instance). + - 'Tip: Disks should be set to autoDelete=true so that leftover disks are + not left behind on machine deletion.' required: false type: bool - disks: + boot: description: - - An array of disks that are associated with the instances that are created from this - template. + - Indicates that this is a boot disk. The virtual machine will use the first + partition of the disk for its root filesystem. + required: false + type: bool + device_name: + description: + - Specifies a unique device name of your choice that is reflected into the + /dev/disk/by-id/google-* tree of a Linux operating system running within + the instance. This name can be used to reference the device for mounting, + resizing, and so on, from within the instance. + required: false + disk_encryption_key: + description: + - Encrypts or decrypts a disk using a customer-supplied encryption key. required: false suboptions: - auto_delete: - description: - - Specifies whether the disk will be auto-deleted when the instance is deleted (but - not when the disk is detached from the instance). - - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left - behind on machine deletion.' - required: false - type: bool - boot: - description: - - Indicates that this is a boot disk. The virtual machine will use the first partition - of the disk for its root filesystem. - required: false - type: bool - device_name: - description: - - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* - tree of a Linux operating system running within the instance. This name can be used - to reference the device for mounting, resizing, and so on, from within the instance. - required: false - disk_encryption_key: - description: - - Encrypts or decrypts a disk using a customer-supplied encryption key. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - rsa_encrypted_key: - description: - - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption - key to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - index: - description: - - Assigns a zero-based index to this disk, where 0 is reserved for the boot disk. - For example, if you have many disks attached to an instance, each disk would have - a unique index number. If not specified, the server will choose an appropriate value. - required: false - initialize_params: - description: - - Specifies the parameters for a new disk that will be created alongside the new instance. - Use initialization parameters to create boot disks or local SSDs attached to the - new instance. - required: false - suboptions: - disk_name: - description: - - Specifies the disk name. If not specified, the default is to use the name of the - instance. - required: false - disk_size_gb: - description: - - Specifies the size of the disk in base-2 GB. - required: false - disk_type: - description: - - Reference to a gcompute_disk_type resource. - - Specifies the disk type to use to create the instance. - - If not specified, the default is pd-standard. - required: false - source_image: - description: - - The source image to create this disk. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. To create a disk with one of the public operating - system images, specify the image by its family name. - required: false - source_image_encryption_key: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - - Instance templates do not store customer-supplied encryption keys, so you cannot - create disks for instances in a managed instance group if the source images are - encrypted with your own keys. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - interface: - description: - - Specifies the disk interface to use for attaching this disk, which is either SCSI - or NVME. The default is SCSI. - - Persistent disks must always use SCSI and the request will fail if you attempt to - attach a persistent disk in any other format than SCSI. - required: false - choices: ['SCSI', 'NVME'] - mode: - description: - - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, - the default is to attach the disk in READ_WRITE mode. - required: false - choices: ['READ_WRITE', 'READ_ONLY'] - source: - description: - - Reference to a gcompute_disk resource. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. - - If desired, you can also attach existing non-root persistent disks using this property. - This field is only applicable for persistent disks. - - 'This field represents a link to a Disk resource in GCP. It can be specified in - two ways. You can add `register: name-of-resource` to a gcp_compute_disk task and - then set this source field to "{{ name-of-resource }}" Alternatively, you can set - this source to a dictionary with the selfLink key where the value is the selfLink - of your Disk.' - required: false - type: - description: - - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - the default is PERSISTENT. - required: false - choices: ['SCRATCH', 'PERSISTENT'] - guest_accelerators: + raw_key: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC + 4648 base64 to either encrypt or decrypt this resource. + required: false + rsa_encrypted_key: + description: + - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied + encryption key to either encrypt or decrypt this resource. + required: false + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + required: false + index: description: - - List of the type and count of accelerator cards attached to the instance . + - Assigns a zero-based index to this disk, where 0 is reserved for the boot + disk. For example, if you have many disks attached to an instance, each + disk would have a unique index number. If not specified, the server will + choose an appropriate value. + required: false + initialize_params: + description: + - Specifies the parameters for a new disk that will be created alongside the + new instance. Use initialization parameters to create boot disks or local + SSDs attached to the new instance. required: false suboptions: - accelerator_count: + disk_name: + description: + - Specifies the disk name. If not specified, the default is to use the + name of the instance. + required: false + disk_size_gb: + description: + - Specifies the size of the disk in base-2 GB. + required: false + disk_type: + description: + - Reference to a gcompute_disk_type resource. + - Specifies the disk type to use to create the instance. + - If not specified, the default is pd-standard. + required: false + source_image: + description: + - The source image to create this disk. When creating a new instance, + one of initializeParams.sourceImage or disks.source is required. To + create a disk with one of the public operating system images, specify + the image by its family name. + required: false + source_image_encryption_key: + description: + - The customer-supplied encryption key of the source image. Required if + the source image is protected by a customer-supplied encryption key. + - Instance templates do not store customer-supplied encryption keys, so + you cannot create disks for instances in a managed instance group if + the source images are encrypted with your own keys. + required: false + suboptions: + raw_key: description: - - The number of the guest accelerator cards exposed to this instance. + - Specifies a 256-bit customer-supplied encryption key, encoded in + RFC 4648 base64 to either encrypt or decrypt this resource. required: false - accelerator_type: + sha256: description: - - Full or partial URL of the accelerator type resource to expose to this instance. + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. required: false - label_fingerprint: + interface: description: - - A fingerprint for this request, which is essentially a hash of the metadata's contents - and used for optimistic locking. The fingerprint is initially generated by Compute - Engine and changes after every request to modify or update metadata. You must always - provide an up-to-date fingerprint hash in order to update or change metadata. + - Specifies the disk interface to use for attaching this disk, which is either + SCSI or NVME. The default is SCSI. + - Persistent disks must always use SCSI and the request will fail if you attempt + to attach a persistent disk in any other format than SCSI. required: false - metadata: + choices: + - SCSI + - NVME + mode: description: - - The metadata key/value pairs to assign to instances that are created from this template. - These pairs can consist of custom metadata or predefined keys. + - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If + not specified, the default is to attach the disk in READ_WRITE mode. required: false - machine_type: + choices: + - READ_WRITE + - READ_ONLY + source: description: - - A reference to a machine type which defines VM kind. + - Reference to a gcompute_disk resource. When creating a new instance, one + of initializeParams.sourceImage or disks.source is required. + - If desired, you can also attach existing non-root persistent disks using + this property. This field is only applicable for persistent disks. + - 'This field represents a link to a Disk resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_disk + task and then set this source field to "{{ name-of-resource }}" Alternatively, + you can set this source to a dictionary with the selfLink key where the + value is the selfLink of your Disk' required: false - min_cpu_platform: + type: description: - - Specifies a minimum CPU platform for the VM instance. Applicable values are the - friendly names of CPU platforms . + - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, + the default is PERSISTENT. required: false - name: + choices: + - SCRATCH + - PERSISTENT + guest_accelerators: + description: + - List of the type and count of accelerator cards attached to the instance . + required: false + suboptions: + accelerator_count: description: - - The name of the resource, provided by the client when initially creating the resource. - The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, - the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. + - The number of the guest accelerator cards exposed to this instance. required: false - network_interfaces: + accelerator_type: description: - - An array of configurations for this interface. This specifies how this interface - is configured to interact with other network services, such as connecting to the - internet. Only one network interface is supported per instance. + - Full or partial URL of the accelerator type resource to expose to this instance. + required: false + label_fingerprint: + description: + - A fingerprint for this request, which is essentially a hash of the metadata's + contents and used for optimistic locking. The fingerprint is initially generated + by Compute Engine and changes after every request to modify or update metadata. + You must always provide an up-to-date fingerprint hash in order to update or + change metadata. + required: false + metadata: + description: + - The metadata key/value pairs to assign to instances that are created from this + template. These pairs can consist of custom metadata or predefined keys. + required: false + machine_type: + description: + - A reference to a machine type which defines VM kind. + required: false + min_cpu_platform: + description: + - Specifies a minimum CPU platform for the VM instance. Applicable values are + the friendly names of CPU platforms . + required: false + name: + description: + - The name of the resource, provided by the client when initially creating the + resource. The resource name must be 1-63 characters long, and comply with RFC1035. + Specifically, the name must be 1-63 characters long and match the regular expression + `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase + letter, and all following characters must be a dash, lowercase letter, or digit, + except the last character, which cannot be a dash. + required: false + network_interfaces: + description: + - An array of configurations for this interface. This specifies how this interface + is configured to interact with other network services, such as connecting to + the internet. Only one network interface is supported per instance. + required: false + suboptions: + access_configs: + description: + - An array of configurations for this interface. Currently, only one access + config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, + then this instance will have no external internet access. required: false suboptions: - access_configs: - description: - - An array of configurations for this interface. Currently, only one access config, - ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this - instance will have no external internet access. - required: false - suboptions: - name: - description: - - The name of this access configuration. The default and recommended name is External - NAT but you can use any arbitrary string you would like. For example, My external - IP or Network Access. - required: true - nat_ip: - description: - - Specifies the title of a gcompute_address. - - An external IP address associated with this instance. - - Specify an unused static external IP address available to the project or leave this - field undefined to use an IP from a shared ephemeral IP address pool. If you specify - a static external IP address, it must live in the same region as the zone of the - instance. - - 'This field represents a link to a Address resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_address task - and then set this nat_ip field to "{{ name-of-resource }}" Alternatively, you can - set this nat_ip to a dictionary with the address key where the value is the address - of your Address.' - required: false - type: - description: - - The type of configuration. The default and only option is ONE_TO_ONE_NAT. - required: true - choices: ['ONE_TO_ONE_NAT'] - alias_ip_ranges: - description: - - An array of alias IP ranges for this network interface. Can only be specified for - network interfaces on subnet-mode networks. - required: false - suboptions: - ip_cidr_range: - description: - - The IP CIDR range represented by this alias IP range. - - This IP CIDR range must belong to the specified subnetwork and cannot contain IP - addresses reserved by system or used by other network interfaces. This range may - be a single IP address (e.g. 10.2.3.4), a netmask (e.g. /24) or a CIDR format string - (e.g. 10.1.2.0/24). - required: false - subnetwork_range_name: - description: - - Optional subnetwork secondary range name specifying the secondary range from which - to allocate the IP CIDR range for this alias IP range. If left unspecified, the - primary range of the subnetwork will be used. - required: false - name: - description: - - The name of the network interface, generated by the server. For network devices, - these are eth0, eth1, etc . - required: false - network: - description: - - Specifies the title of an existing gcompute_network. When creating an instance, - if neither the network nor the subnetwork is specified, the default network global/networks/default - is used; if the network is not specified but the subnetwork is specified, the network - is inferred. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: false - network_ip: - description: - - An IPv4 internal network address to assign to the instance for this network interface. - If not specified by the user, an unused internal IP is assigned by the system. - required: false - subnetwork: - description: - - Reference to a gcompute_subnetwork resource. - - If the network resource is in legacy mode, do not provide this property. If the - network is in auto subnet mode, providing the subnetwork is optional. If the network - is in custom subnet mode, then this field should be specified. - - 'This field represents a link to a Subnetwork resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork - task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, - you can set this subnetwork to a dictionary with the selfLink key where the value - is the selfLink of your Subnetwork.' - required: false - scheduling: + name: + description: + - The name of this access configuration. The default and recommended name + is External NAT but you can use any arbitrary string you would like. + For example, My external IP or Network Access. + required: true + nat_ip: + description: + - Specifies the title of a gcompute_address. + - An external IP address associated with this instance. + - Specify an unused static external IP address available to the project + or leave this field undefined to use an IP from a shared ephemeral IP + address pool. If you specify a static external IP address, it must live + in the same region as the zone of the instance. + - 'This field represents a link to a Address resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a + gcp_compute_address task and then set this nat_ip field to "{{ name-of-resource + }}" Alternatively, you can set this nat_ip to a dictionary with the + address key where the value is the address of your Address' + required: false + type: + description: + - The type of configuration. The default and only option is ONE_TO_ONE_NAT. + required: true + choices: + - ONE_TO_ONE_NAT + alias_ip_ranges: description: - - Sets the scheduling options for this instance. + - An array of alias IP ranges for this network interface. Can only be specified + for network interfaces on subnet-mode networks. required: false suboptions: - automatic_restart: - description: - - Specifies whether the instance should be automatically restarted if it is terminated - by Compute Engine (not terminated by a user). - - You can only set the automatic restart option for standard instances. Preemptible - instances cannot be automatically restarted. - required: false - type: bool - on_host_maintenance: - description: - - Defines the maintenance behavior for this instance. For standard instances, the - default behavior is MIGRATE. For preemptible instances, the default and only possible - behavior is TERMINATE. - - For more information, see Setting Instance Scheduling Options. - required: false - preemptible: - description: - - Defines whether the instance is preemptible. This can only be set during instance - creation, it cannot be set or changed after the instance has been created. - required: false - type: bool - service_accounts: + ip_cidr_range: + description: + - The IP CIDR range represented by this alias IP range. + - This IP CIDR range must belong to the specified subnetwork and cannot + contain IP addresses reserved by system or used by other network interfaces. + This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g. + /24) or a CIDR format string (e.g. 10.1.2.0/24). + required: false + subnetwork_range_name: + description: + - Optional subnetwork secondary range name specifying the secondary range + from which to allocate the IP CIDR range for this alias IP range. If + left unspecified, the primary range of the subnetwork will be used. + required: false + name: description: - - A list of service accounts, with their specified scopes, authorized for this instance. - Only one service account per VM instance is supported. + - The name of the network interface, generated by the server. For network + devices, these are eth0, eth1, etc . required: false - suboptions: - email: - description: - - Email address of the service account. - required: false - scopes: - description: - - The list of scopes to be made available for this service account. - required: false - tags: + network: description: - - A list of tags to apply to this instance. Tags are used to identify valid sources - or targets for network firewalls and are specified by the client during instance - creation. The tags can be later modified by the setTags method. Each tag within - the list must comply with RFC1035. + - Specifies the title of an existing gcompute_network. When creating an instance, + if neither the network nor the subnetwork is specified, the default network + global/networks/default is used; if the network is not specified but the + subnetwork is specified, the network is inferred. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the + value is the selfLink of your Network' required: false - suboptions: - fingerprint: - description: - - Specifies a fingerprint for this request, which is essentially a hash of the metadata's - contents and used for optimistic locking. - - The fingerprint is initially generated by Compute Engine and changes after every - request to modify or update metadata. You must always provide an up-to-date fingerprint - hash in order to update or change metadata. - required: false - items: - description: - - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. - required: false - zone: + network_ip: description: - - A reference to the zone where the machine resides. - required: true + - An IPv4 internal network address to assign to the instance for this network + interface. If not specified by the user, an unused internal IP is assigned + by the system. + required: false + subnetwork: + description: + - Reference to a gcompute_subnetwork resource. + - If the network resource is in legacy mode, do not provide this property. + If the network is in auto subnet mode, providing the subnetwork is optional. + If the network is in custom subnet mode, then this field should be specified. + - 'This field represents a link to a Subnetwork resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork + task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, + you can set this subnetwork to a dictionary with the selfLink key where + the value is the selfLink of your Subnetwork' + required: false + scheduling: + description: + - Sets the scheduling options for this instance. + required: false + suboptions: + automatic_restart: + description: + - Specifies whether the instance should be automatically restarted if it is + terminated by Compute Engine (not terminated by a user). + - You can only set the automatic restart option for standard instances. Preemptible + instances cannot be automatically restarted. + required: false + type: bool + on_host_maintenance: + description: + - Defines the maintenance behavior for this instance. For standard instances, + the default behavior is MIGRATE. For preemptible instances, the default + and only possible behavior is TERMINATE. + - For more information, see Setting Instance Scheduling Options. + required: false + preemptible: + description: + - Defines whether the instance is preemptible. This can only be set during + instance creation, it cannot be set or changed after the instance has been + created. + required: false + type: bool + service_accounts: + description: + - A list of service accounts, with their specified scopes, authorized for this + instance. Only one service account per VM instance is supported. + required: false + suboptions: + email: + description: + - Email address of the service account. + required: false + scopes: + description: + - The list of scopes to be made available for this service account. + required: false + tags: + description: + - A list of tags to apply to this instance. Tags are used to identify valid sources + or targets for network firewalls and are specified by the client during instance + creation. The tags can be later modified by the setTags method. Each tag within + the list must comply with RFC1035. + required: false + suboptions: + fingerprint: + description: + - Specifies a fingerprint for this request, which is essentially a hash of + the metadata's contents and used for optimistic locking. + - The fingerprint is initially generated by Compute Engine and changes after + every request to modify or update metadata. You must always provide an up-to-date + fingerprint hash in order to update or change metadata. + required: false + items: + description: + - An array of tags. Each tag must be 1-63 characters long, and comply with + RFC1035. + required: false + zone: + description: + - A reference to the zone where the machine resides. + required: true extends_documentation_fragment: gcp ''' @@ -443,393 +460,398 @@ EXAMPLES = ''' ''' RETURN = ''' - canIpForward: - description: - - Allows this instance to send and receive packets with non-matching destination or - source IPs. This is required if you plan to use this instance to forward routes. - returned: success - type: bool - cpuPlatform: - description: - - The CPU platform used by this instance. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - disks: - description: - - An array of disks that are associated with the instances that are created from this - template. - returned: success - type: complex - contains: - autoDelete: - description: - - Specifies whether the disk will be auto-deleted when the instance is deleted (but - not when the disk is detached from the instance). - - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left - behind on machine deletion.' - returned: success - type: bool - boot: - description: - - Indicates that this is a boot disk. The virtual machine will use the first partition - of the disk for its root filesystem. - returned: success - type: bool - deviceName: - description: - - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* - tree of a Linux operating system running within the instance. This name can be used - to reference the device for mounting, resizing, and so on, from within the instance. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts or decrypts a disk using a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - rsaEncryptedKey: - description: - - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption - key to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - index: - description: - - Assigns a zero-based index to this disk, where 0 is reserved for the boot disk. - For example, if you have many disks attached to an instance, each disk would have - a unique index number. If not specified, the server will choose an appropriate value. - returned: success - type: int - initializeParams: - description: - - Specifies the parameters for a new disk that will be created alongside the new instance. - Use initialization parameters to create boot disks or local SSDs attached to the - new instance. - returned: success - type: complex - contains: - diskName: - description: - - Specifies the disk name. If not specified, the default is to use the name of the - instance. - returned: success - type: str - diskSizeGb: - description: - - Specifies the size of the disk in base-2 GB. - returned: success - type: int - diskType: - description: - - Reference to a gcompute_disk_type resource. - - Specifies the disk type to use to create the instance. - - If not specified, the default is pd-standard. - returned: success - type: str - sourceImage: - description: - - The source image to create this disk. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. To create a disk with one of the public operating - system images, specify the image by its family name. - returned: success - type: str - sourceImageEncryptionKey: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - - Instance templates do not store customer-supplied encryption keys, so you cannot - create disks for instances in a managed instance group if the source images are - encrypted with your own keys. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - interface: - description: - - Specifies the disk interface to use for attaching this disk, which is either SCSI - or NVME. The default is SCSI. - - Persistent disks must always use SCSI and the request will fail if you attempt to - attach a persistent disk in any other format than SCSI. - returned: success - type: str - mode: - description: - - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, - the default is to attach the disk in READ_WRITE mode. - returned: success - type: str - source: - description: - - Reference to a gcompute_disk resource. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. - - If desired, you can also attach existing non-root persistent disks using this property. - This field is only applicable for persistent disks. - returned: success - type: dict - type: - description: - - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - the default is PERSISTENT. - returned: success - type: str - guestAccelerators: - description: - - List of the type and count of accelerator cards attached to the instance . - returned: success - type: complex - contains: - acceleratorCount: - description: - - The number of the guest accelerator cards exposed to this instance. - returned: success - type: int - acceleratorType: - description: - - Full or partial URL of the accelerator type resource to expose to this instance. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - labelFingerprint: - description: - - A fingerprint for this request, which is essentially a hash of the metadata's contents - and used for optimistic locking. The fingerprint is initially generated by Compute - Engine and changes after every request to modify or update metadata. You must always - provide an up-to-date fingerprint hash in order to update or change metadata. - returned: success - type: str - metadata: - description: - - The metadata key/value pairs to assign to instances that are created from this template. - These pairs can consist of custom metadata or predefined keys. - returned: success - type: dict - machineType: - description: - - A reference to a machine type which defines VM kind. - returned: success - type: str - minCpuPlatform: - description: - - Specifies a minimum CPU platform for the VM instance. Applicable values are the - friendly names of CPU platforms . - returned: success - type: str +canIpForward: + description: + - Allows this instance to send and receive packets with non-matching destination + or source IPs. This is required if you plan to use this instance to forward routes. + returned: success + type: bool +cpuPlatform: + description: + - The CPU platform used by this instance. + returned: success + type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +disks: + description: + - An array of disks that are associated with the instances that are created from + this template. + returned: success + type: complex + contains: + autoDelete: + description: + - Specifies whether the disk will be auto-deleted when the instance is deleted + (but not when the disk is detached from the instance). + - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not + left behind on machine deletion.' + returned: success + type: bool + boot: + description: + - Indicates that this is a boot disk. The virtual machine will use the first + partition of the disk for its root filesystem. + returned: success + type: bool + deviceName: + description: + - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* + tree of a Linux operating system running within the instance. This name can + be used to reference the device for mounting, resizing, and so on, from within + the instance. + returned: success + type: str + diskEncryptionKey: + description: + - Encrypts or decrypts a disk using a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + rsaEncryptedKey: + description: + - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied + encryption key to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + index: + description: + - Assigns a zero-based index to this disk, where 0 is reserved for the boot + disk. For example, if you have many disks attached to an instance, each disk + would have a unique index number. If not specified, the server will choose + an appropriate value. + returned: success + type: int + initializeParams: + description: + - Specifies the parameters for a new disk that will be created alongside the + new instance. Use initialization parameters to create boot disks or local + SSDs attached to the new instance. + returned: success + type: complex + contains: + diskName: + description: + - Specifies the disk name. If not specified, the default is to use the name + of the instance. + returned: success + type: str + diskSizeGb: + description: + - Specifies the size of the disk in base-2 GB. + returned: success + type: int + diskType: + description: + - Reference to a gcompute_disk_type resource. + - Specifies the disk type to use to create the instance. + - If not specified, the default is pd-standard. + returned: success + type: str + sourceImage: + description: + - The source image to create this disk. When creating a new instance, one + of initializeParams.sourceImage or disks.source is required. To create + a disk with one of the public operating system images, specify the image + by its family name. + returned: success + type: str + sourceImageEncryptionKey: + description: + - The customer-supplied encryption key of the source image. Required if + the source image is protected by a customer-supplied encryption key. + - Instance templates do not store customer-supplied encryption keys, so + you cannot create disks for instances in a managed instance group if the + source images are encrypted with your own keys. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC + 4648 base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + returned: success + type: str + interface: + description: + - Specifies the disk interface to use for attaching this disk, which is either + SCSI or NVME. The default is SCSI. + - Persistent disks must always use SCSI and the request will fail if you attempt + to attach a persistent disk in any other format than SCSI. + returned: success + type: str + mode: + description: + - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If + not specified, the default is to attach the disk in READ_WRITE mode. + returned: success + type: str + source: + description: + - Reference to a gcompute_disk resource. When creating a new instance, one of + initializeParams.sourceImage or disks.source is required. + - If desired, you can also attach existing non-root persistent disks using this + property. This field is only applicable for persistent disks. + returned: success + type: dict + type: + description: + - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, + the default is PERSISTENT. + returned: success + type: str +guestAccelerators: + description: + - List of the type and count of accelerator cards attached to the instance . + returned: success + type: complex + contains: + acceleratorCount: + description: + - The number of the guest accelerator cards exposed to this instance. + returned: success + type: int + acceleratorType: + description: + - Full or partial URL of the accelerator type resource to expose to this instance. + returned: success + type: str +id: + description: + - The unique identifier for the resource. This identifier is defined by the server. + returned: success + type: int +labelFingerprint: + description: + - A fingerprint for this request, which is essentially a hash of the metadata's + contents and used for optimistic locking. The fingerprint is initially generated + by Compute Engine and changes after every request to modify or update metadata. + You must always provide an up-to-date fingerprint hash in order to update or change + metadata. + returned: success + type: str +metadata: + description: + - The metadata key/value pairs to assign to instances that are created from this + template. These pairs can consist of custom metadata or predefined keys. + returned: success + type: dict +machineType: + description: + - A reference to a machine type which defines VM kind. + returned: success + type: str +minCpuPlatform: + description: + - Specifies a minimum CPU platform for the VM instance. Applicable values are the + friendly names of CPU platforms . + returned: success + type: str +name: + description: + - The name of the resource, provided by the client when initially creating the resource. + The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +networkInterfaces: + description: + - An array of configurations for this interface. This specifies how this interface + is configured to interact with other network services, such as connecting to the + internet. Only one network interface is supported per instance. + returned: success + type: complex + contains: + accessConfigs: + description: + - An array of configurations for this interface. Currently, only one access + config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, + then this instance will have no external internet access. + returned: success + type: complex + contains: + name: + description: + - The name of this access configuration. The default and recommended name + is External NAT but you can use any arbitrary string you would like. For + example, My external IP or Network Access. + returned: success + type: str + natIP: + description: + - Specifies the title of a gcompute_address. + - An external IP address associated with this instance. + - Specify an unused static external IP address available to the project + or leave this field undefined to use an IP from a shared ephemeral IP + address pool. If you specify a static external IP address, it must live + in the same region as the zone of the instance. + returned: success + type: dict + type: + description: + - The type of configuration. The default and only option is ONE_TO_ONE_NAT. + returned: success + type: str + aliasIpRanges: + description: + - An array of alias IP ranges for this network interface. Can only be specified + for network interfaces on subnet-mode networks. + returned: success + type: complex + contains: + ipCidrRange: + description: + - The IP CIDR range represented by this alias IP range. + - This IP CIDR range must belong to the specified subnetwork and cannot + contain IP addresses reserved by system or used by other network interfaces. + This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g. + /24) or a CIDR format string (e.g. 10.1.2.0/24). + returned: success + type: str + subnetworkRangeName: + description: + - Optional subnetwork secondary range name specifying the secondary range + from which to allocate the IP CIDR range for this alias IP range. If left + unspecified, the primary range of the subnetwork will be used. + returned: success + type: str name: - description: - - The name of the resource, provided by the client when initially creating the resource. - The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, - the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - networkInterfaces: - description: - - An array of configurations for this interface. This specifies how this interface - is configured to interact with other network services, such as connecting to the - internet. Only one network interface is supported per instance. - returned: success - type: complex - contains: - accessConfigs: - description: - - An array of configurations for this interface. Currently, only one access config, - ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this - instance will have no external internet access. - returned: success - type: complex - contains: - name: - description: - - The name of this access configuration. The default and recommended name is External - NAT but you can use any arbitrary string you would like. For example, My external - IP or Network Access. - returned: success - type: str - natIP: - description: - - Specifies the title of a gcompute_address. - - An external IP address associated with this instance. - - Specify an unused static external IP address available to the project or leave this - field undefined to use an IP from a shared ephemeral IP address pool. If you specify - a static external IP address, it must live in the same region as the zone of the - instance. - returned: success - type: dict - type: - description: - - The type of configuration. The default and only option is ONE_TO_ONE_NAT. - returned: success - type: str - aliasIpRanges: - description: - - An array of alias IP ranges for this network interface. Can only be specified for - network interfaces on subnet-mode networks. - returned: success - type: complex - contains: - ipCidrRange: - description: - - The IP CIDR range represented by this alias IP range. - - This IP CIDR range must belong to the specified subnetwork and cannot contain IP - addresses reserved by system or used by other network interfaces. This range may - be a single IP address (e.g. 10.2.3.4), a netmask (e.g. /24) or a CIDR format string - (e.g. 10.1.2.0/24). - returned: success - type: str - subnetworkRangeName: - description: - - Optional subnetwork secondary range name specifying the secondary range from which - to allocate the IP CIDR range for this alias IP range. If left unspecified, the - primary range of the subnetwork will be used. - returned: success - type: str - name: - description: - - The name of the network interface, generated by the server. For network devices, - these are eth0, eth1, etc . - returned: success - type: str - network: - description: - - Specifies the title of an existing gcompute_network. When creating an instance, - if neither the network nor the subnetwork is specified, the default network global/networks/default - is used; if the network is not specified but the subnetwork is specified, the network - is inferred. - returned: success - type: dict - networkIP: - description: - - An IPv4 internal network address to assign to the instance for this network interface. - If not specified by the user, an unused internal IP is assigned by the system. - returned: success - type: str - subnetwork: - description: - - Reference to a gcompute_subnetwork resource. - - If the network resource is in legacy mode, do not provide this property. If the - network is in auto subnet mode, providing the subnetwork is optional. If the network - is in custom subnet mode, then this field should be specified. - returned: success - type: dict - scheduling: - description: - - Sets the scheduling options for this instance. - returned: success - type: complex - contains: - automaticRestart: - description: - - Specifies whether the instance should be automatically restarted if it is terminated - by Compute Engine (not terminated by a user). - - You can only set the automatic restart option for standard instances. Preemptible - instances cannot be automatically restarted. - returned: success - type: bool - onHostMaintenance: - description: - - Defines the maintenance behavior for this instance. For standard instances, the - default behavior is MIGRATE. For preemptible instances, the default and only possible - behavior is TERMINATE. - - For more information, see Setting Instance Scheduling Options. - returned: success - type: str - preemptible: - description: - - Defines whether the instance is preemptible. This can only be set during instance - creation, it cannot be set or changed after the instance has been created. - returned: success - type: bool - serviceAccounts: - description: - - A list of service accounts, with their specified scopes, authorized for this instance. - Only one service account per VM instance is supported. - returned: success - type: complex - contains: - email: - description: - - Email address of the service account. - returned: success - type: str - scopes: - description: - - The list of scopes to be made available for this service account. - returned: success - type: list - status: - description: - - 'The status of the instance. One of the following values: PROVISIONING, STAGING, - RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.' - returned: success - type: str - statusMessage: - description: - - An optional, human-readable explanation of the status. - returned: success - type: str - tags: - description: - - A list of tags to apply to this instance. Tags are used to identify valid sources - or targets for network firewalls and are specified by the client during instance - creation. The tags can be later modified by the setTags method. Each tag within - the list must comply with RFC1035. - returned: success - type: complex - contains: - fingerprint: - description: - - Specifies a fingerprint for this request, which is essentially a hash of the metadata's - contents and used for optimistic locking. - - The fingerprint is initially generated by Compute Engine and changes after every - request to modify or update metadata. You must always provide an up-to-date fingerprint - hash in order to update or change metadata. - returned: success - type: str - items: - description: - - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. - returned: success - type: list - zone: - description: - - A reference to the zone where the machine resides. - returned: success - type: str + description: + - The name of the network interface, generated by the server. For network devices, + these are eth0, eth1, etc . + returned: success + type: str + network: + description: + - Specifies the title of an existing gcompute_network. When creating an instance, + if neither the network nor the subnetwork is specified, the default network + global/networks/default is used; if the network is not specified but the subnetwork + is specified, the network is inferred. + returned: success + type: dict + networkIP: + description: + - An IPv4 internal network address to assign to the instance for this network + interface. If not specified by the user, an unused internal IP is assigned + by the system. + returned: success + type: str + subnetwork: + description: + - Reference to a gcompute_subnetwork resource. + - If the network resource is in legacy mode, do not provide this property. If + the network is in auto subnet mode, providing the subnetwork is optional. + If the network is in custom subnet mode, then this field should be specified. + returned: success + type: dict +scheduling: + description: + - Sets the scheduling options for this instance. + returned: success + type: complex + contains: + automaticRestart: + description: + - Specifies whether the instance should be automatically restarted if it is + terminated by Compute Engine (not terminated by a user). + - You can only set the automatic restart option for standard instances. Preemptible + instances cannot be automatically restarted. + returned: success + type: bool + onHostMaintenance: + description: + - Defines the maintenance behavior for this instance. For standard instances, + the default behavior is MIGRATE. For preemptible instances, the default and + only possible behavior is TERMINATE. + - For more information, see Setting Instance Scheduling Options. + returned: success + type: str + preemptible: + description: + - Defines whether the instance is preemptible. This can only be set during instance + creation, it cannot be set or changed after the instance has been created. + returned: success + type: bool +serviceAccounts: + description: + - A list of service accounts, with their specified scopes, authorized for this instance. + Only one service account per VM instance is supported. + returned: success + type: complex + contains: + email: + description: + - Email address of the service account. + returned: success + type: str + scopes: + description: + - The list of scopes to be made available for this service account. + returned: success + type: list +status: + description: + - 'The status of the instance. One of the following values: PROVISIONING, STAGING, + RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.' + returned: success + type: str +statusMessage: + description: + - An optional, human-readable explanation of the status. + returned: success + type: str +tags: + description: + - A list of tags to apply to this instance. Tags are used to identify valid sources + or targets for network firewalls and are specified by the client during instance + creation. The tags can be later modified by the setTags method. Each tag within + the list must comply with RFC1035. + returned: success + type: complex + contains: + fingerprint: + description: + - Specifies a fingerprint for this request, which is essentially a hash of the + metadata's contents and used for optimistic locking. + - The fingerprint is initially generated by Compute Engine and changes after + every request to modify or update metadata. You must always provide an up-to-date + fingerprint hash in order to update or change metadata. + returned: success + type: str + items: + description: + - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. + returned: success + type: list +zone: + description: + - A reference to the zone where the machine resides. + returned: success + type: str ''' ################################################################################ @@ -989,15 +1011,15 @@ def resource_to_request(module): u'kind': 'compute#instance', u'canIpForward': module.params.get('can_ip_forward'), u'disks': InstanceDisksArray(module.params.get('disks', []), module).to_request(), - u'guestAccelerators': InstanceGuestAcceleratorsArray(module.params.get('guest_accelerators', []), module).to_request(), + u'guestAccelerators': InstanceGuestacceleratorsArray(module.params.get('guest_accelerators', []), module).to_request(), u'labelFingerprint': module.params.get('label_fingerprint'), u'metadata': module.params.get('metadata'), u'machineType': machine_type_selflink(module.params.get('machine_type'), module.params), u'minCpuPlatform': module.params.get('min_cpu_platform'), u'name': module.params.get('name'), - u'networkInterfaces': InstanceNetworkInterfacesArray(module.params.get('network_interfaces', []), module).to_request(), + u'networkInterfaces': InstanceNetworkinterfacesArray(module.params.get('network_interfaces', []), module).to_request(), u'scheduling': InstanceScheduling(module.params.get('scheduling', {}), module).to_request(), - u'serviceAccounts': InstanceServiceAccountsArray(module.params.get('service_accounts', []), module).to_request(), + u'serviceAccounts': InstanceServiceaccountsArray(module.params.get('service_accounts', []), module).to_request(), u'tags': InstanceTags(module.params.get('tags', {}), module).to_request() } request = encode_request(request, module) @@ -1072,16 +1094,16 @@ def response_to_hash(module, response): u'cpuPlatform': response.get(u'cpuPlatform'), u'creationTimestamp': response.get(u'creationTimestamp'), u'disks': InstanceDisksArray(module.params.get('disks', []), module).to_request(), - u'guestAccelerators': InstanceGuestAcceleratorsArray(response.get(u'guestAccelerators', []), module).from_response(), + u'guestAccelerators': InstanceGuestacceleratorsArray(response.get(u'guestAccelerators', []), module).from_response(), u'id': response.get(u'id'), u'labelFingerprint': response.get(u'labelFingerprint'), u'metadata': response.get(u'metadata'), u'machineType': response.get(u'machineType'), u'minCpuPlatform': response.get(u'minCpuPlatform'), u'name': response.get(u'name'), - u'networkInterfaces': InstanceNetworkInterfacesArray(response.get(u'networkInterfaces', []), module).from_response(), + u'networkInterfaces': InstanceNetworkinterfacesArray(response.get(u'networkInterfaces', []), module).from_response(), u'scheduling': InstanceScheduling(response.get(u'scheduling', {}), module).from_response(), - u'serviceAccounts': InstanceServiceAccountsArray(response.get(u'serviceAccounts', []), module).from_response(), + u'serviceAccounts': InstanceServiceaccountsArray(response.get(u'serviceAccounts', []), module).from_response(), u'status': response.get(u'status'), u'statusMessage': response.get(u'statusMessage'), u'tags': InstanceTags(response.get(u'tags', {}), module).from_response() @@ -1130,8 +1152,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -1219,9 +1239,9 @@ class InstanceDisksArray(object): u'autoDelete': item.get('auto_delete'), u'boot': item.get('boot'), u'deviceName': item.get('device_name'), - u'diskEncryptionKey': InstanceDiskEncryptionKey(item.get('disk_encryption_key', {}), self.module).to_request(), + u'diskEncryptionKey': InstanceDiskencryptionkey(item.get('disk_encryption_key', {}), self.module).to_request(), u'index': item.get('index'), - u'initializeParams': InstanceInitializeParams(item.get('initialize_params', {}), self.module).to_request(), + u'initializeParams': InstanceInitializeparams(item.get('initialize_params', {}), self.module).to_request(), u'interface': item.get('interface'), u'mode': item.get('mode'), u'source': replace_resource_dict(item.get(u'source', {}), 'selfLink'), @@ -1233,9 +1253,9 @@ class InstanceDisksArray(object): u'autoDelete': item.get(u'autoDelete'), u'boot': item.get(u'boot'), u'deviceName': item.get(u'deviceName'), - u'diskEncryptionKey': InstanceDiskEncryptionKey(item.get(u'diskEncryptionKey', {}), self.module).from_response(), + u'diskEncryptionKey': InstanceDiskencryptionkey(item.get(u'diskEncryptionKey', {}), self.module).from_response(), u'index': item.get(u'index'), - u'initializeParams': InstanceInitializeParams(self.module.params.get('initialize_params', {}), self.module).to_request(), + u'initializeParams': InstanceInitializeparams(self.module.params.get('initialize_params', {}), self.module).to_request(), u'interface': item.get(u'interface'), u'mode': item.get(u'mode'), u'source': item.get(u'source'), @@ -1243,7 +1263,7 @@ class InstanceDisksArray(object): }) -class InstanceDiskEncryptionKey(object): +class InstanceDiskencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -1266,7 +1286,7 @@ class InstanceDiskEncryptionKey(object): }) -class InstanceInitializeParams(object): +class InstanceInitializeparams(object): def __init__(self, request, module): self.module = module if request: @@ -1280,7 +1300,7 @@ class InstanceInitializeParams(object): u'diskSizeGb': self.request.get('disk_size_gb'), u'diskType': disk_type_selflink(self.request.get('disk_type'), self.module.params), u'sourceImage': self.request.get('source_image'), - u'sourceImageEncryptionKey': InstanceSourceImageEncryptionKey(self.request.get('source_image_encryption_key', {}), self.module).to_request() + u'sourceImageEncryptionKey': InstanceSourceimageencryptionkey(self.request.get('source_image_encryption_key', {}), self.module).to_request() }) def from_response(self): @@ -1289,11 +1309,11 @@ class InstanceInitializeParams(object): u'diskSizeGb': self.request.get(u'diskSizeGb'), u'diskType': self.request.get(u'diskType'), u'sourceImage': self.request.get(u'sourceImage'), - u'sourceImageEncryptionKey': InstanceSourceImageEncryptionKey(self.request.get(u'sourceImageEncryptionKey', {}), self.module).from_response() + u'sourceImageEncryptionKey': InstanceSourceimageencryptionkey(self.request.get(u'sourceImageEncryptionKey', {}), self.module).from_response() }) -class InstanceSourceImageEncryptionKey(object): +class InstanceSourceimageencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -1314,7 +1334,7 @@ class InstanceSourceImageEncryptionKey(object): }) -class InstanceGuestAcceleratorsArray(object): +class InstanceGuestacceleratorsArray(object): def __init__(self, request, module): self.module = module if request: @@ -1347,7 +1367,7 @@ class InstanceGuestAcceleratorsArray(object): }) -class InstanceNetworkInterfacesArray(object): +class InstanceNetworkinterfacesArray(object): def __init__(self, request, module): self.module = module if request: @@ -1369,8 +1389,8 @@ class InstanceNetworkInterfacesArray(object): def _request_for_item(self, item): return remove_nones_from_dict({ - u'accessConfigs': InstanceAccessConfigsArray(item.get('access_configs', []), self.module).to_request(), - u'aliasIpRanges': InstanceAliasIpRangesArray(item.get('alias_ip_ranges', []), self.module).to_request(), + u'accessConfigs': InstanceAccessconfigsArray(item.get('access_configs', []), self.module).to_request(), + u'aliasIpRanges': InstanceAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(), u'name': item.get('name'), u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'), u'networkIP': item.get('network_ip'), @@ -1379,8 +1399,8 @@ class InstanceNetworkInterfacesArray(object): def _response_from_item(self, item): return remove_nones_from_dict({ - u'accessConfigs': InstanceAccessConfigsArray(item.get(u'accessConfigs', []), self.module).from_response(), - u'aliasIpRanges': InstanceAliasIpRangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(), + u'accessConfigs': InstanceAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(), + u'aliasIpRanges': InstanceAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(), u'name': item.get(u'name'), u'network': item.get(u'network'), u'networkIP': item.get(u'networkIP'), @@ -1388,7 +1408,7 @@ class InstanceNetworkInterfacesArray(object): }) -class InstanceAccessConfigsArray(object): +class InstanceAccessconfigsArray(object): def __init__(self, request, module): self.module = module if request: @@ -1423,7 +1443,7 @@ class InstanceAccessConfigsArray(object): }) -class InstanceAliasIpRangesArray(object): +class InstanceAliasiprangesArray(object): def __init__(self, request, module): self.module = module if request: @@ -1479,7 +1499,7 @@ class InstanceScheduling(object): }) -class InstanceServiceAccountsArray(object): +class InstanceServiceaccountsArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_facts.py index 1d1096b8c3..6c029571a8 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance_facts description: - - Gather facts for GCP Instance +- Gather facts for GCP Instance short_description: Gather facts for GCP Instance version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - zone: - description: - - A reference to the zone where the machine resides. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + zone: + description: + - A reference to the zone where the machine resides. + required: true extends_documentation_fragment: gcp ''' @@ -67,397 +66,408 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - canIpForward: - description: - - Allows this instance to send and receive packets with non-matching destination or - source IPs. This is required if you plan to use this instance to forward routes. - returned: success - type: bool - cpuPlatform: - description: - - The CPU platform used by this instance. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - disks: - description: - - An array of disks that are associated with the instances that are created from this - template. - returned: success - type: complex - contains: - autoDelete: - description: - - Specifies whether the disk will be auto-deleted when the instance is deleted (but - not when the disk is detached from the instance). - - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left - behind on machine deletion.' - returned: success - type: bool - boot: - description: - - Indicates that this is a boot disk. The virtual machine will use the first partition - of the disk for its root filesystem. - returned: success - type: bool - deviceName: - description: - - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* - tree of a Linux operating system running within the instance. This name can be used - to reference the device for mounting, resizing, and so on, from within the instance. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts or decrypts a disk using a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - rsaEncryptedKey: - description: - - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption - key to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - index: - description: - - Assigns a zero-based index to this disk, where 0 is reserved for the boot disk. - For example, if you have many disks attached to an instance, each disk would have - a unique index number. If not specified, the server will choose an appropriate value. - returned: success - type: int - initializeParams: - description: - - Specifies the parameters for a new disk that will be created alongside the new instance. - Use initialization parameters to create boot disks or local SSDs attached to the - new instance. - returned: success - type: complex - contains: - diskName: - description: - - Specifies the disk name. If not specified, the default is to use the name of the - instance. - returned: success - type: str - diskSizeGb: - description: - - Specifies the size of the disk in base-2 GB. - returned: success - type: int - diskType: - description: - - Reference to a gcompute_disk_type resource. - - Specifies the disk type to use to create the instance. - - If not specified, the default is pd-standard. - returned: success - type: str - sourceImage: - description: - - The source image to create this disk. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. To create a disk with one of the public operating - system images, specify the image by its family name. - returned: success - type: str - sourceImageEncryptionKey: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - - Instance templates do not store customer-supplied encryption keys, so you cannot - create disks for instances in a managed instance group if the source images are - encrypted with your own keys. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - interface: - description: - - Specifies the disk interface to use for attaching this disk, which is either SCSI - or NVME. The default is SCSI. - - Persistent disks must always use SCSI and the request will fail if you attempt to - attach a persistent disk in any other format than SCSI. - returned: success - type: str - mode: - description: - - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, - the default is to attach the disk in READ_WRITE mode. - returned: success - type: str - source: - description: - - Reference to a gcompute_disk resource. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. - - If desired, you can also attach existing non-root persistent disks using this property. - This field is only applicable for persistent disks. - returned: success - type: dict - type: - description: - - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - the default is PERSISTENT. - returned: success - type: str - guestAccelerators: - description: - - List of the type and count of accelerator cards attached to the instance . - returned: success - type: complex - contains: - acceleratorCount: - description: - - The number of the guest accelerator cards exposed to this instance. - returned: success - type: int - acceleratorType: - description: - - Full or partial URL of the accelerator type resource to expose to this instance. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - labelFingerprint: - description: - - A fingerprint for this request, which is essentially a hash of the metadata's contents - and used for optimistic locking. The fingerprint is initially generated by Compute - Engine and changes after every request to modify or update metadata. You must always - provide an up-to-date fingerprint hash in order to update or change metadata. - returned: success - type: str - metadata: - description: - - The metadata key/value pairs to assign to instances that are created from this template. - These pairs can consist of custom metadata or predefined keys. - returned: success - type: dict - machineType: - description: - - A reference to a machine type which defines VM kind. - returned: success - type: str - minCpuPlatform: - description: - - Specifies a minimum CPU platform for the VM instance. Applicable values are the - friendly names of CPU platforms . - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + canIpForward: + description: + - Allows this instance to send and receive packets with non-matching destination + or source IPs. This is required if you plan to use this instance to forward + routes. + returned: success + type: bool + cpuPlatform: + description: + - The CPU platform used by this instance. + returned: success + type: str + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + disks: + description: + - An array of disks that are associated with the instances that are created + from this template. + returned: success + type: complex + contains: + autoDelete: + description: + - Specifies whether the disk will be auto-deleted when the instance is deleted + (but not when the disk is detached from the instance). + - 'Tip: Disks should be set to autoDelete=true so that leftover disks are + not left behind on machine deletion.' + returned: success + type: bool + boot: + description: + - Indicates that this is a boot disk. The virtual machine will use the first + partition of the disk for its root filesystem. + returned: success + type: bool + deviceName: + description: + - Specifies a unique device name of your choice that is reflected into the + /dev/disk/by-id/google-* tree of a Linux operating system running within + the instance. This name can be used to reference the device for mounting, + resizing, and so on, from within the instance. + returned: success + type: str + diskEncryptionKey: + description: + - Encrypts or decrypts a disk using a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC + 4648 base64 to either encrypt or decrypt this resource. + returned: success + type: str + rsaEncryptedKey: + description: + - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied + encryption key to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + returned: success + type: str + index: + description: + - Assigns a zero-based index to this disk, where 0 is reserved for the boot + disk. For example, if you have many disks attached to an instance, each + disk would have a unique index number. If not specified, the server will + choose an appropriate value. + returned: success + type: int + initializeParams: + description: + - Specifies the parameters for a new disk that will be created alongside + the new instance. Use initialization parameters to create boot disks or + local SSDs attached to the new instance. + returned: success + type: complex + contains: + diskName: + description: + - Specifies the disk name. If not specified, the default is to use the + name of the instance. + returned: success + type: str + diskSizeGb: + description: + - Specifies the size of the disk in base-2 GB. + returned: success + type: int + diskType: + description: + - Reference to a gcompute_disk_type resource. + - Specifies the disk type to use to create the instance. + - If not specified, the default is pd-standard. + returned: success + type: str + sourceImage: + description: + - The source image to create this disk. When creating a new instance, + one of initializeParams.sourceImage or disks.source is required. To + create a disk with one of the public operating system images, specify + the image by its family name. + returned: success + type: str + sourceImageEncryptionKey: + description: + - The customer-supplied encryption key of the source image. Required + if the source image is protected by a customer-supplied encryption + key. + - Instance templates do not store customer-supplied encryption keys, + so you cannot create disks for instances in a managed instance group + if the source images are encrypted with your own keys. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded + in RFC 4648 base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + returned: success + type: str + interface: + description: + - Specifies the disk interface to use for attaching this disk, which is + either SCSI or NVME. The default is SCSI. + - Persistent disks must always use SCSI and the request will fail if you + attempt to attach a persistent disk in any other format than SCSI. + returned: success + type: str + mode: + description: + - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. + If not specified, the default is to attach the disk in READ_WRITE mode. + returned: success + type: str + source: + description: + - Reference to a gcompute_disk resource. When creating a new instance, one + of initializeParams.sourceImage or disks.source is required. + - If desired, you can also attach existing non-root persistent disks using + this property. This field is only applicable for persistent disks. + returned: success + type: dict + type: + description: + - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, + the default is PERSISTENT. + returned: success + type: str + guestAccelerators: + description: + - List of the type and count of accelerator cards attached to the instance . + returned: success + type: complex + contains: + acceleratorCount: + description: + - The number of the guest accelerator cards exposed to this instance. + returned: success + type: int + acceleratorType: + description: + - Full or partial URL of the accelerator type resource to expose to this + instance. + returned: success + type: str + id: + description: + - The unique identifier for the resource. This identifier is defined by the + server. + returned: success + type: int + labelFingerprint: + description: + - A fingerprint for this request, which is essentially a hash of the metadata's + contents and used for optimistic locking. The fingerprint is initially generated + by Compute Engine and changes after every request to modify or update metadata. + You must always provide an up-to-date fingerprint hash in order to update + or change metadata. + returned: success + type: str + metadata: + description: + - The metadata key/value pairs to assign to instances that are created from + this template. These pairs can consist of custom metadata or predefined keys. + returned: success + type: dict + machineType: + description: + - A reference to a machine type which defines VM kind. + returned: success + type: str + minCpuPlatform: + description: + - Specifies a minimum CPU platform for the VM instance. Applicable values are + the friendly names of CPU platforms . + returned: success + type: str + name: + description: + - The name of the resource, provided by the client when initially creating the + resource. The resource name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match the + regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character + must be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + returned: success + type: str + networkInterfaces: + description: + - An array of configurations for this interface. This specifies how this interface + is configured to interact with other network services, such as connecting + to the internet. Only one network interface is supported per instance. + returned: success + type: complex + contains: + accessConfigs: + description: + - An array of configurations for this interface. Currently, only one access + config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, + then this instance will have no external internet access. + returned: success + type: complex + contains: + name: + description: + - The name of this access configuration. The default and recommended + name is External NAT but you can use any arbitrary string you would + like. For example, My external IP or Network Access. + returned: success + type: str + natIP: + description: + - Specifies the title of a gcompute_address. + - An external IP address associated with this instance. + - Specify an unused static external IP address available to the project + or leave this field undefined to use an IP from a shared ephemeral + IP address pool. If you specify a static external IP address, it must + live in the same region as the zone of the instance. + returned: success + type: dict + type: + description: + - The type of configuration. The default and only option is ONE_TO_ONE_NAT. + returned: success + type: str + aliasIpRanges: + description: + - An array of alias IP ranges for this network interface. Can only be specified + for network interfaces on subnet-mode networks. + returned: success + type: complex + contains: + ipCidrRange: + description: + - The IP CIDR range represented by this alias IP range. + - This IP CIDR range must belong to the specified subnetwork and cannot + contain IP addresses reserved by system or used by other network interfaces. + This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g. + /24) or a CIDR format string (e.g. 10.1.2.0/24). + returned: success + type: str + subnetworkRangeName: + description: + - Optional subnetwork secondary range name specifying the secondary + range from which to allocate the IP CIDR range for this alias IP range. + If left unspecified, the primary range of the subnetwork will be used. + returned: success + type: str name: - description: - - The name of the resource, provided by the client when initially creating the resource. - The resource name must be 1-63 characters long, and comply with RFC1035. Specifically, - the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - networkInterfaces: - description: - - An array of configurations for this interface. This specifies how this interface - is configured to interact with other network services, such as connecting to the - internet. Only one network interface is supported per instance. - returned: success - type: complex - contains: - accessConfigs: - description: - - An array of configurations for this interface. Currently, only one access config, - ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this - instance will have no external internet access. - returned: success - type: complex - contains: - name: - description: - - The name of this access configuration. The default and recommended name is External - NAT but you can use any arbitrary string you would like. For example, My external - IP or Network Access. - returned: success - type: str - natIP: - description: - - Specifies the title of a gcompute_address. - - An external IP address associated with this instance. - - Specify an unused static external IP address available to the project or leave this - field undefined to use an IP from a shared ephemeral IP address pool. If you specify - a static external IP address, it must live in the same region as the zone of the - instance. - returned: success - type: dict - type: - description: - - The type of configuration. The default and only option is ONE_TO_ONE_NAT. - returned: success - type: str - aliasIpRanges: - description: - - An array of alias IP ranges for this network interface. Can only be specified for - network interfaces on subnet-mode networks. - returned: success - type: complex - contains: - ipCidrRange: - description: - - The IP CIDR range represented by this alias IP range. - - This IP CIDR range must belong to the specified subnetwork and cannot contain IP - addresses reserved by system or used by other network interfaces. This range may - be a single IP address (e.g. 10.2.3.4), a netmask (e.g. /24) or a CIDR format string - (e.g. 10.1.2.0/24). - returned: success - type: str - subnetworkRangeName: - description: - - Optional subnetwork secondary range name specifying the secondary range from which - to allocate the IP CIDR range for this alias IP range. If left unspecified, the - primary range of the subnetwork will be used. - returned: success - type: str - name: - description: - - The name of the network interface, generated by the server. For network devices, - these are eth0, eth1, etc . - returned: success - type: str - network: - description: - - Specifies the title of an existing gcompute_network. When creating an instance, - if neither the network nor the subnetwork is specified, the default network global/networks/default - is used; if the network is not specified but the subnetwork is specified, the network - is inferred. - returned: success - type: dict - networkIP: - description: - - An IPv4 internal network address to assign to the instance for this network interface. - If not specified by the user, an unused internal IP is assigned by the system. - returned: success - type: str - subnetwork: - description: - - Reference to a gcompute_subnetwork resource. - - If the network resource is in legacy mode, do not provide this property. If the - network is in auto subnet mode, providing the subnetwork is optional. If the network - is in custom subnet mode, then this field should be specified. - returned: success - type: dict - scheduling: - description: - - Sets the scheduling options for this instance. - returned: success - type: complex - contains: - automaticRestart: - description: - - Specifies whether the instance should be automatically restarted if it is terminated - by Compute Engine (not terminated by a user). - - You can only set the automatic restart option for standard instances. Preemptible - instances cannot be automatically restarted. - returned: success - type: bool - onHostMaintenance: - description: - - Defines the maintenance behavior for this instance. For standard instances, the - default behavior is MIGRATE. For preemptible instances, the default and only possible - behavior is TERMINATE. - - For more information, see Setting Instance Scheduling Options. - returned: success - type: str - preemptible: - description: - - Defines whether the instance is preemptible. This can only be set during instance - creation, it cannot be set or changed after the instance has been created. - returned: success - type: bool - serviceAccounts: - description: - - A list of service accounts, with their specified scopes, authorized for this instance. - Only one service account per VM instance is supported. - returned: success - type: complex - contains: - email: - description: - - Email address of the service account. - returned: success - type: str - scopes: - description: - - The list of scopes to be made available for this service account. - returned: success - type: list - status: - description: - - 'The status of the instance. One of the following values: PROVISIONING, STAGING, - RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.' - returned: success - type: str - statusMessage: - description: - - An optional, human-readable explanation of the status. - returned: success - type: str - tags: - description: - - A list of tags to apply to this instance. Tags are used to identify valid sources - or targets for network firewalls and are specified by the client during instance - creation. The tags can be later modified by the setTags method. Each tag within - the list must comply with RFC1035. - returned: success - type: complex - contains: - fingerprint: - description: - - Specifies a fingerprint for this request, which is essentially a hash of the metadata's - contents and used for optimistic locking. - - The fingerprint is initially generated by Compute Engine and changes after every - request to modify or update metadata. You must always provide an up-to-date fingerprint - hash in order to update or change metadata. - returned: success - type: str - items: - description: - - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. - returned: success - type: list - zone: - description: - - A reference to the zone where the machine resides. - returned: success - type: str + description: + - The name of the network interface, generated by the server. For network + devices, these are eth0, eth1, etc . + returned: success + type: str + network: + description: + - Specifies the title of an existing gcompute_network. When creating an + instance, if neither the network nor the subnetwork is specified, the + default network global/networks/default is used; if the network is not + specified but the subnetwork is specified, the network is inferred. + returned: success + type: dict + networkIP: + description: + - An IPv4 internal network address to assign to the instance for this network + interface. If not specified by the user, an unused internal IP is assigned + by the system. + returned: success + type: str + subnetwork: + description: + - Reference to a gcompute_subnetwork resource. + - If the network resource is in legacy mode, do not provide this property. + If the network is in auto subnet mode, providing the subnetwork is optional. + If the network is in custom subnet mode, then this field should be specified. + returned: success + type: dict + scheduling: + description: + - Sets the scheduling options for this instance. + returned: success + type: complex + contains: + automaticRestart: + description: + - Specifies whether the instance should be automatically restarted if it + is terminated by Compute Engine (not terminated by a user). + - You can only set the automatic restart option for standard instances. + Preemptible instances cannot be automatically restarted. + returned: success + type: bool + onHostMaintenance: + description: + - Defines the maintenance behavior for this instance. For standard instances, + the default behavior is MIGRATE. For preemptible instances, the default + and only possible behavior is TERMINATE. + - For more information, see Setting Instance Scheduling Options. + returned: success + type: str + preemptible: + description: + - Defines whether the instance is preemptible. This can only be set during + instance creation, it cannot be set or changed after the instance has + been created. + returned: success + type: bool + serviceAccounts: + description: + - A list of service accounts, with their specified scopes, authorized for this + instance. Only one service account per VM instance is supported. + returned: success + type: complex + contains: + email: + description: + - Email address of the service account. + returned: success + type: str + scopes: + description: + - The list of scopes to be made available for this service account. + returned: success + type: list + status: + description: + - 'The status of the instance. One of the following values: PROVISIONING, STAGING, + RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.' + returned: success + type: str + statusMessage: + description: + - An optional, human-readable explanation of the status. + returned: success + type: str + tags: + description: + - A list of tags to apply to this instance. Tags are used to identify valid + sources or targets for network firewalls and are specified by the client during + instance creation. The tags can be later modified by the setTags method. Each + tag within the list must comply with RFC1035. + returned: success + type: complex + contains: + fingerprint: + description: + - Specifies a fingerprint for this request, which is essentially a hash + of the metadata's contents and used for optimistic locking. + - The fingerprint is initially generated by Compute Engine and changes after + every request to modify or update metadata. You must always provide an + up-to-date fingerprint hash in order to update or change metadata. + returned: success + type: str + items: + description: + - An array of tags. Each tag must be 1-63 characters long, and comply with + RFC1035. + returned: success + type: list + zone: + description: + - A reference to the zone where the machine resides. + returned: success + type: str ''' ################################################################################ @@ -479,7 +489,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py index f1b711e03f..63da353dcc 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py @@ -32,87 +32,89 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance_group description: - - Represents an Instance Group resource. Instance groups are self-managed and can - contain identical or different instances. Instance groups do not use an instance - template. Unlike managed instance groups, you must create and add instances to an - instance group manually. +- Represents an Instance Group resource. Instance groups are self-managed and can + contain identical or different instances. Instance groups do not use an instance + template. Unlike managed instance groups, you must create and add instances to an + instance group manually. short_description: Creates a GCP InstanceGroup version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + name: + description: + - The name of the instance group. + - The name must be 1-63 characters long, and comply with RFC1035. + required: false + named_ports: + description: + - Assigns a name to a port number. + - 'For example: {name: "http", port: 80}.' + - This allows the system to reference ports by the assigned name instead of a + port number. Named ports can also contain multiple ports. + - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named ports + apply to all instances in this instance group.' + required: false + suboptions: + name: description: - - An optional description of this resource. Provide this property when you create - the resource. + - The name for this named port. + - The name must be 1-63 characters long, and comply with RFC1035. required: false - name: + port: description: - - The name of the instance group. - - The name must be 1-63 characters long, and comply with RFC1035. + - The port number, which can be a value between 1 and 65535. required: false - named_ports: - description: - - Assigns a name to a port number. - - 'For example: {name: "http", port: 80}.' - - This allows the system to reference ports by the assigned name instead of a port - number. Named ports can also contain multiple ports. - - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named ports - apply to all instances in this instance group.' - required: false - suboptions: - name: - description: - - The name for this named port. - - The name must be 1-63 characters long, and comply with RFC1035. - required: false - port: - description: - - The port number, which can be a value between 1 and 65535. - required: false - network: - description: - - The network to which all instances in the instance group belong. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: false - region: - description: - - The region where the instance group is located (for regional resources). - required: false - subnetwork: - description: - - The subnetwork to which all instances in the instance group belong. - - 'This field represents a link to a Subnetwork resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork - task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, - you can set this subnetwork to a dictionary with the selfLink key where the value - is the selfLink of your Subnetwork.' - required: false - zone: - description: - - A reference to the zone where the instance group resides. - required: true - instances: - description: - - The list of instances associated with this InstanceGroup. - - All instances must be created before being added to an InstanceGroup. - - All instances not in this list will be removed from the InstanceGroup and will not - be deleted. - - Only the full identifier of the instance will be returned. - required: false - version_added: 2.8 + network: + description: + - The network to which all instances in the instance group belong. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: false + region: + description: + - The region where the instance group is located (for regional resources). + required: false + subnetwork: + description: + - The subnetwork to which all instances in the instance group belong. + - 'This field represents a link to a Subnetwork resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork + task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, + you can set this subnetwork to a dictionary with the selfLink key where the + value is the selfLink of your Subnetwork' + required: false + zone: + description: + - A reference to the zone where the instance group resides. + required: true + instances: + description: + - The list of instances associated with this InstanceGroup. + - All instances must be created before being added to an InstanceGroup. + - All instances not in this list will be removed from the InstanceGroup and will + not be deleted. + - Only the full identifier of the instance will be returned. + required: false + version_added: 2.8 extends_documentation_fragment: gcp ''' @@ -141,79 +143,79 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - A unique identifier for this instance group. - returned: success - type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +id: + description: + - A unique identifier for this instance group. + returned: success + type: int +name: + description: + - The name of the instance group. + - The name must be 1-63 characters long, and comply with RFC1035. + returned: success + type: str +namedPorts: + description: + - Assigns a name to a port number. + - 'For example: {name: "http", port: 80}.' + - This allows the system to reference ports by the assigned name instead of a port + number. Named ports can also contain multiple ports. + - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named ports + apply to all instances in this instance group.' + returned: success + type: complex + contains: name: - description: - - The name of the instance group. - - The name must be 1-63 characters long, and comply with RFC1035. - returned: success - type: str - namedPorts: - description: - - Assigns a name to a port number. - - 'For example: {name: "http", port: 80}.' - - This allows the system to reference ports by the assigned name instead of a port - number. Named ports can also contain multiple ports. - - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named ports - apply to all instances in this instance group.' - returned: success - type: complex - contains: - name: - description: - - The name for this named port. - - The name must be 1-63 characters long, and comply with RFC1035. - returned: success - type: str - port: - description: - - The port number, which can be a value between 1 and 65535. - returned: success - type: int - network: - description: - - The network to which all instances in the instance group belong. - returned: success - type: dict - region: - description: - - The region where the instance group is located (for regional resources). - returned: success - type: str - subnetwork: - description: - - The subnetwork to which all instances in the instance group belong. - returned: success - type: dict - zone: - description: - - A reference to the zone where the instance group resides. - returned: success - type: str - instances: - description: - - The list of instances associated with this InstanceGroup. - - All instances must be created before being added to an InstanceGroup. - - All instances not in this list will be removed from the InstanceGroup and will not - be deleted. - - Only the full identifier of the instance will be returned. - returned: success - type: list + description: + - The name for this named port. + - The name must be 1-63 characters long, and comply with RFC1035. + returned: success + type: str + port: + description: + - The port number, which can be a value between 1 and 65535. + returned: success + type: int +network: + description: + - The network to which all instances in the instance group belong. + returned: success + type: dict +region: + description: + - The region where the instance group is located (for regional resources). + returned: success + type: str +subnetwork: + description: + - The subnetwork to which all instances in the instance group belong. + returned: success + type: dict +zone: + description: + - A reference to the zone where the instance group resides. + returned: success + type: str +instances: + description: + - The list of instances associated with this InstanceGroup. + - All instances must be created before being added to an InstanceGroup. + - All instances not in this list will be removed from the InstanceGroup and will + not be deleted. + - Only the full identifier of the instance will be returned. + returned: success + type: list ''' ################################################################################ @@ -305,7 +307,7 @@ def resource_to_request(module): u'kind': 'compute#instanceGroup', u'description': module.params.get('description'), u'name': module.params.get('name'), - u'namedPorts': InstanceGroupNamedPortsArray(module.params.get('named_ports', []), module).to_request(), + u'namedPorts': InstanceGroupNamedportsArray(module.params.get('named_ports', []), module).to_request(), u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'), u'region': region_selflink(module.params.get('region'), module.params), u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink') @@ -378,7 +380,7 @@ def response_to_hash(module, response): u'description': response.get(u'description'), u'id': response.get(u'id'), u'name': response.get(u'name'), - u'namedPorts': InstanceGroupNamedPortsArray(response.get(u'namedPorts', []), module).from_response(), + u'namedPorts': InstanceGroupNamedportsArray(response.get(u'namedPorts', []), module).from_response(), u'network': response.get(u'network'), u'region': response.get(u'region'), u'subnetwork': response.get(u'subnetwork') @@ -418,8 +420,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -491,7 +491,7 @@ class InstanceLogic(object): return request -class InstanceGroupNamedPortsArray(object): +class InstanceGroupNamedportsArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_facts.py index 952363ec5a..e634572c88 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance_group_facts description: - - Gather facts for GCP InstanceGroup +- Gather facts for GCP InstanceGroup short_description: Gather facts for GCP InstanceGroup version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - zone: - description: - - A reference to the zone where the instance group resides. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + zone: + description: + - A reference to the zone where the instance group resides. + required: true extends_documentation_fragment: gcp ''' @@ -67,83 +66,83 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - A unique identifier for this instance group. - returned: success - type: int + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + id: + description: + - A unique identifier for this instance group. + returned: success + type: int + name: + description: + - The name of the instance group. + - The name must be 1-63 characters long, and comply with RFC1035. + returned: success + type: str + namedPorts: + description: + - Assigns a name to a port number. + - 'For example: {name: "http", port: 80}.' + - This allows the system to reference ports by the assigned name instead of + a port number. Named ports can also contain multiple ports. + - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named + ports apply to all instances in this instance group.' + returned: success + type: complex + contains: name: - description: - - The name of the instance group. - - The name must be 1-63 characters long, and comply with RFC1035. - returned: success - type: str - namedPorts: - description: - - Assigns a name to a port number. - - 'For example: {name: "http", port: 80}.' - - This allows the system to reference ports by the assigned name instead of a port - number. Named ports can also contain multiple ports. - - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named ports - apply to all instances in this instance group.' - returned: success - type: complex - contains: - name: - description: - - The name for this named port. - - The name must be 1-63 characters long, and comply with RFC1035. - returned: success - type: str - port: - description: - - The port number, which can be a value between 1 and 65535. - returned: success - type: int - network: - description: - - The network to which all instances in the instance group belong. - returned: success - type: dict - region: - description: - - The region where the instance group is located (for regional resources). - returned: success - type: str - subnetwork: - description: - - The subnetwork to which all instances in the instance group belong. - returned: success - type: dict - zone: - description: - - A reference to the zone where the instance group resides. - returned: success - type: str - instances: - description: - - The list of instances associated with this InstanceGroup. - - All instances must be created before being added to an InstanceGroup. - - All instances not in this list will be removed from the InstanceGroup and will not - be deleted. - - Only the full identifier of the instance will be returned. - returned: success - type: list + description: + - The name for this named port. + - The name must be 1-63 characters long, and comply with RFC1035. + returned: success + type: str + port: + description: + - The port number, which can be a value between 1 and 65535. + returned: success + type: int + network: + description: + - The network to which all instances in the instance group belong. + returned: success + type: dict + region: + description: + - The region where the instance group is located (for regional resources). + returned: success + type: str + subnetwork: + description: + - The subnetwork to which all instances in the instance group belong. + returned: success + type: dict + zone: + description: + - A reference to the zone where the instance group resides. + returned: success + type: str + instances: + description: + - The list of instances associated with this InstanceGroup. + - All instances must be created before being added to an InstanceGroup. + - All instances not in this list will be removed from the InstanceGroup and + will not be deleted. + - Only the full identifier of the instance will be returned. + returned: success + type: list ''' ################################################################################ @@ -165,7 +164,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py index f48f8c2d69..a84d86aac7 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py @@ -32,82 +32,86 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance_group_manager description: - - Creates a managed instance group using the information that you specify in the request. - After the group is created, it schedules an action to create instances in the group - using the specified instance template. This operation is marked as DONE when the - group is created even if the instances in the group have not yet been created. You - must separately verify the status of the individual instances. - - A managed instance group can have up to 1000 VM instances per group. +- Creates a managed instance group using the information that you specify in the request. + After the group is created, it schedules an action to create instances in the group + using the specified instance template. This operation is marked as DONE when the + group is created even if the instances in the group have not yet been created. You + must separately verify the status of the individual instances. +- A managed instance group can have up to 1000 VM instances per group. short_description: Creates a GCP InstanceGroupManager version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - base_instance_name: - description: - - The base instance name to use for instances in this group. The value must be 1-58 - characters long. Instances are named by appending a hyphen and a random four-character - string to the base instance name. - - The base instance name must comply with RFC1035. - required: true + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + base_instance_name: + description: + - The base instance name to use for instances in this group. The value must be + 1-58 characters long. Instances are named by appending a hyphen and a random + four-character string to the base instance name. + - The base instance name must comply with RFC1035. + required: true + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + instance_template: + description: + - The instance template that is specified for this managed instance group. The + group uses this template to create all new instances in the managed instance + group. + - 'This field represents a link to a InstanceTemplate resource in GCP. It can + be specified in two ways. You can add `register: name-of-resource` to a gcp_compute_instance_template + task and then set this instance_template field to "{{ name-of-resource }}" Alternatively, + you can set this instance_template to a dictionary with the selfLink key where + the value is the selfLink of your InstanceTemplate' + required: true + name: + description: + - The name of the managed instance group. The name must be 1-63 characters long, + and comply with RFC1035. + required: true + named_ports: + description: + - Named ports configured for the Instance Groups complementary to this Instance + Group Manager. + required: false + suboptions: + name: description: - - An optional description of this resource. Provide this property when you create - the resource. + - The name for this named port. The name must be 1-63 characters long, and + comply with RFC1035. required: false - instance_template: + port: description: - - The instance template that is specified for this managed instance group. The group - uses this template to create all new instances in the managed instance group. - - 'This field represents a link to a InstanceTemplate resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_instance_template - task and then set this instance_template field to "{{ name-of-resource }}" Alternatively, - you can set this instance_template to a dictionary with the selfLink key where the - value is the selfLink of your InstanceTemplate.' - required: true - name: - description: - - The name of the managed instance group. The name must be 1-63 characters long, and - comply with RFC1035. - required: true - named_ports: - description: - - Named ports configured for the Instance Groups complementary to this Instance Group - Manager. + - The port number, which can be a value between 1 and 65535. required: false - suboptions: - name: - description: - - The name for this named port. The name must be 1-63 characters long, and comply - with RFC1035. - required: false - port: - description: - - The port number, which can be a value between 1 and 65535. - required: false - target_pools: - description: - - TargetPool resources to which instances in the instanceGroup field are added. The - target pools automatically apply to all of the instances in the managed instance - group. - required: false - target_size: - description: - - The target number of running instances for this managed instance group. Deleting - or abandoning instances reduces this number. Resizing the group changes this number. - required: false - zone: - description: - - The zone the managed instance group resides. - required: true + target_pools: + description: + - TargetPool resources to which instances in the instanceGroup field are added. + The target pools automatically apply to all of the instances in the managed + instance group. + required: false + target_size: + description: + - The target number of running instances for this managed instance group. Deleting + or abandoning instances reduces this number. Resizing the group changes this + number. + required: false + zone: + description: + - The zone the managed instance group resides. + required: true extends_documentation_fragment: gcp ''' @@ -167,151 +171,151 @@ EXAMPLES = ''' ''' RETURN = ''' - baseInstanceName: - description: - - The base instance name to use for instances in this group. The value must be 1-58 - characters long. Instances are named by appending a hyphen and a random four-character - string to the base instance name. - - The base instance name must comply with RFC1035. - returned: success - type: str - creationTimestamp: - description: - - The creation timestamp for this managed instance group in RFC3339 text format. - returned: success - type: str - currentActions: - description: - - The list of instance actions and the number of instances in this managed instance - group that are scheduled for each of those actions. - returned: success - type: complex - contains: - abandoning: - description: - - The total number of instances in the managed instance group that are scheduled to - be abandoned. Abandoning an instance removes it from the managed instance group - without deleting it. - returned: success - type: int - creating: - description: - - The number of instances in the managed instance group that are scheduled to be created - or are currently being created. If the group fails to create any of these instances, - it tries again until it creates the instance successfully. - - If you have disabled creation retries, this field will not be populated; instead, - the creatingWithoutRetries field will be populated. - returned: success - type: int - creatingWithoutRetries: - description: - - The number of instances that the managed instance group will attempt to create. - The group attempts to create each instance only once. If the group fails to create - any of these instances, it decreases the group's targetSize value accordingly. - returned: success - type: int - deleting: - description: - - The number of instances in the managed instance group that are scheduled to be deleted - or are currently being deleted. - returned: success - type: int - none: - description: - - The number of instances in the managed instance group that are running and have - no scheduled actions. - returned: success - type: int - recreating: - description: - - The number of instances in the managed instance group that are scheduled to be recreated - or are currently being being recreated. - - Recreating an instance deletes the existing root persistent disk and creates a new - disk from the image that is defined in the instance template. - returned: success - type: int - refreshing: - description: - - The number of instances in the managed instance group that are being reconfigured - with properties that do not require a restart or a recreate action. For example, - setting or removing target pools for the instance. - returned: success - type: int - restarting: - description: - - The number of instances in the managed instance group that are scheduled to be restarted - or are currently being restarted. - returned: success - type: int - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - A unique identifier for this resource. - returned: success - type: int - instanceGroup: - description: - - The instance group being managed. - returned: success - type: dict - instanceTemplate: - description: - - The instance template that is specified for this managed instance group. The group - uses this template to create all new instances in the managed instance group. - returned: success - type: dict +baseInstanceName: + description: + - The base instance name to use for instances in this group. The value must be 1-58 + characters long. Instances are named by appending a hyphen and a random four-character + string to the base instance name. + - The base instance name must comply with RFC1035. + returned: success + type: str +creationTimestamp: + description: + - The creation timestamp for this managed instance group in RFC3339 text format. + returned: success + type: str +currentActions: + description: + - The list of instance actions and the number of instances in this managed instance + group that are scheduled for each of those actions. + returned: success + type: complex + contains: + abandoning: + description: + - The total number of instances in the managed instance group that are scheduled + to be abandoned. Abandoning an instance removes it from the managed instance + group without deleting it. + returned: success + type: int + creating: + description: + - The number of instances in the managed instance group that are scheduled to + be created or are currently being created. If the group fails to create any + of these instances, it tries again until it creates the instance successfully. + - If you have disabled creation retries, this field will not be populated; instead, + the creatingWithoutRetries field will be populated. + returned: success + type: int + creatingWithoutRetries: + description: + - The number of instances that the managed instance group will attempt to create. + The group attempts to create each instance only once. If the group fails to + create any of these instances, it decreases the group's targetSize value accordingly. + returned: success + type: int + deleting: + description: + - The number of instances in the managed instance group that are scheduled to + be deleted or are currently being deleted. + returned: success + type: int + none: + description: + - The number of instances in the managed instance group that are running and + have no scheduled actions. + returned: success + type: int + recreating: + description: + - The number of instances in the managed instance group that are scheduled to + be recreated or are currently being being recreated. + - Recreating an instance deletes the existing root persistent disk and creates + a new disk from the image that is defined in the instance template. + returned: success + type: int + refreshing: + description: + - The number of instances in the managed instance group that are being reconfigured + with properties that do not require a restart or a recreate action. For example, + setting or removing target pools for the instance. + returned: success + type: int + restarting: + description: + - The number of instances in the managed instance group that are scheduled to + be restarted or are currently being restarted. + returned: success + type: int +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +id: + description: + - A unique identifier for this resource. + returned: success + type: int +instanceGroup: + description: + - The instance group being managed. + returned: success + type: dict +instanceTemplate: + description: + - The instance template that is specified for this managed instance group. The group + uses this template to create all new instances in the managed instance group. + returned: success + type: dict +name: + description: + - The name of the managed instance group. The name must be 1-63 characters long, + and comply with RFC1035. + returned: success + type: str +namedPorts: + description: + - Named ports configured for the Instance Groups complementary to this Instance + Group Manager. + returned: success + type: complex + contains: name: - description: - - The name of the managed instance group. The name must be 1-63 characters long, and - comply with RFC1035. - returned: success - type: str - namedPorts: - description: - - Named ports configured for the Instance Groups complementary to this Instance Group - Manager. - returned: success - type: complex - contains: - name: - description: - - The name for this named port. The name must be 1-63 characters long, and comply - with RFC1035. - returned: success - type: str - port: - description: - - The port number, which can be a value between 1 and 65535. - returned: success - type: int - region: - description: - - The region this managed instance group resides (for regional resources). - returned: success - type: str - targetPools: - description: - - TargetPool resources to which instances in the instanceGroup field are added. The - target pools automatically apply to all of the instances in the managed instance - group. - returned: success - type: list - targetSize: - description: - - The target number of running instances for this managed instance group. Deleting - or abandoning instances reduces this number. Resizing the group changes this number. - returned: success - type: int - zone: - description: - - The zone the managed instance group resides. - returned: success - type: str + description: + - The name for this named port. The name must be 1-63 characters long, and comply + with RFC1035. + returned: success + type: str + port: + description: + - The port number, which can be a value between 1 and 65535. + returned: success + type: int +region: + description: + - The region this managed instance group resides (for regional resources). + returned: success + type: str +targetPools: + description: + - TargetPool resources to which instances in the instanceGroup field are added. + The target pools automatically apply to all of the instances in the managed instance + group. + returned: success + type: list +targetSize: + description: + - The target number of running instances for this managed instance group. Deleting + or abandoning instances reduces this number. Resizing the group changes this number. + returned: success + type: int +zone: + description: + - The zone the managed instance group resides. + returned: success + type: str ''' ################################################################################ @@ -401,7 +405,7 @@ def resource_to_request(module): u'description': module.params.get('description'), u'instanceTemplate': replace_resource_dict(module.params.get(u'instance_template', {}), 'selfLink'), u'name': module.params.get('name'), - u'namedPorts': InstanceGroupManagerNamedPortsArray(module.params.get('named_ports', []), module).to_request(), + u'namedPorts': InstanceGroupManagerNamedportsArray(module.params.get('named_ports', []), module).to_request(), u'targetPools': replace_resource_dict(module.params.get('target_pools', []), 'selfLink'), u'targetSize': module.params.get('target_size') } @@ -471,13 +475,13 @@ def response_to_hash(module, response): return { u'baseInstanceName': response.get(u'baseInstanceName'), u'creationTimestamp': response.get(u'creationTimestamp'), - u'currentActions': InstanceGroupManagerCurrentActions(response.get(u'currentActions', {}), module).from_response(), + u'currentActions': InstanceGroupManagerCurrentactions(response.get(u'currentActions', {}), module).from_response(), u'description': module.params.get('description'), u'id': response.get(u'id'), u'instanceGroup': response.get(u'instanceGroup'), u'instanceTemplate': response.get(u'instanceTemplate'), u'name': response.get(u'name'), - u'namedPorts': InstanceGroupManagerNamedPortsArray(response.get(u'namedPorts', []), module).from_response(), + u'namedPorts': InstanceGroupManagerNamedportsArray(response.get(u'namedPorts', []), module).from_response(), u'region': response.get(u'region'), u'targetPools': response.get(u'targetPools'), u'targetSize': response.get(u'targetSize') @@ -517,8 +521,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -530,7 +532,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class InstanceGroupManagerCurrentActions(object): +class InstanceGroupManagerCurrentactions(object): def __init__(self, request, module): self.module = module if request: @@ -563,7 +565,7 @@ class InstanceGroupManagerCurrentActions(object): }) -class InstanceGroupManagerNamedPortsArray(object): +class InstanceGroupManagerNamedportsArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_facts.py index 5db47bbdb1..243c41335a 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance_group_manager_facts description: - - Gather facts for GCP InstanceGroupManager +- Gather facts for GCP InstanceGroupManager short_description: Gather facts for GCP InstanceGroupManager version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - zone: - description: - - The zone the managed instance group resides. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + zone: + description: + - The zone the managed instance group resides. + required: true extends_documentation_fragment: gcp ''' @@ -67,155 +66,158 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - baseInstanceName: - description: - - The base instance name to use for instances in this group. The value must be 1-58 - characters long. Instances are named by appending a hyphen and a random four-character - string to the base instance name. - - The base instance name must comply with RFC1035. - returned: success - type: str - creationTimestamp: - description: - - The creation timestamp for this managed instance group in RFC3339 text format. - returned: success - type: str - currentActions: - description: - - The list of instance actions and the number of instances in this managed instance - group that are scheduled for each of those actions. - returned: success - type: complex - contains: - abandoning: - description: - - The total number of instances in the managed instance group that are scheduled to - be abandoned. Abandoning an instance removes it from the managed instance group - without deleting it. - returned: success - type: int - creating: - description: - - The number of instances in the managed instance group that are scheduled to be created - or are currently being created. If the group fails to create any of these instances, - it tries again until it creates the instance successfully. - - If you have disabled creation retries, this field will not be populated; instead, - the creatingWithoutRetries field will be populated. - returned: success - type: int - creatingWithoutRetries: - description: - - The number of instances that the managed instance group will attempt to create. - The group attempts to create each instance only once. If the group fails to create - any of these instances, it decreases the group's targetSize value accordingly. - returned: success - type: int - deleting: - description: - - The number of instances in the managed instance group that are scheduled to be deleted - or are currently being deleted. - returned: success - type: int - none: - description: - - The number of instances in the managed instance group that are running and have - no scheduled actions. - returned: success - type: int - recreating: - description: - - The number of instances in the managed instance group that are scheduled to be recreated - or are currently being being recreated. - - Recreating an instance deletes the existing root persistent disk and creates a new - disk from the image that is defined in the instance template. - returned: success - type: int - refreshing: - description: - - The number of instances in the managed instance group that are being reconfigured - with properties that do not require a restart or a recreate action. For example, - setting or removing target pools for the instance. - returned: success - type: int - restarting: - description: - - The number of instances in the managed instance group that are scheduled to be restarted - or are currently being restarted. - returned: success - type: int - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - A unique identifier for this resource. - returned: success - type: int - instanceGroup: - description: - - The instance group being managed. - returned: success - type: dict - instanceTemplate: - description: - - The instance template that is specified for this managed instance group. The group - uses this template to create all new instances in the managed instance group. - returned: success - type: dict + description: List of items + returned: always + type: complex + contains: + baseInstanceName: + description: + - The base instance name to use for instances in this group. The value must + be 1-58 characters long. Instances are named by appending a hyphen and a random + four-character string to the base instance name. + - The base instance name must comply with RFC1035. + returned: success + type: str + creationTimestamp: + description: + - The creation timestamp for this managed instance group in RFC3339 text format. + returned: success + type: str + currentActions: + description: + - The list of instance actions and the number of instances in this managed instance + group that are scheduled for each of those actions. + returned: success + type: complex + contains: + abandoning: + description: + - The total number of instances in the managed instance group that are scheduled + to be abandoned. Abandoning an instance removes it from the managed instance + group without deleting it. + returned: success + type: int + creating: + description: + - The number of instances in the managed instance group that are scheduled + to be created or are currently being created. If the group fails to create + any of these instances, it tries again until it creates the instance successfully. + - If you have disabled creation retries, this field will not be populated; + instead, the creatingWithoutRetries field will be populated. + returned: success + type: int + creatingWithoutRetries: + description: + - The number of instances that the managed instance group will attempt to + create. The group attempts to create each instance only once. If the group + fails to create any of these instances, it decreases the group's targetSize + value accordingly. + returned: success + type: int + deleting: + description: + - The number of instances in the managed instance group that are scheduled + to be deleted or are currently being deleted. + returned: success + type: int + none: + description: + - The number of instances in the managed instance group that are running + and have no scheduled actions. + returned: success + type: int + recreating: + description: + - The number of instances in the managed instance group that are scheduled + to be recreated or are currently being being recreated. + - Recreating an instance deletes the existing root persistent disk and creates + a new disk from the image that is defined in the instance template. + returned: success + type: int + refreshing: + description: + - The number of instances in the managed instance group that are being reconfigured + with properties that do not require a restart or a recreate action. For + example, setting or removing target pools for the instance. + returned: success + type: int + restarting: + description: + - The number of instances in the managed instance group that are scheduled + to be restarted or are currently being restarted. + returned: success + type: int + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + id: + description: + - A unique identifier for this resource. + returned: success + type: int + instanceGroup: + description: + - The instance group being managed. + returned: success + type: dict + instanceTemplate: + description: + - The instance template that is specified for this managed instance group. The + group uses this template to create all new instances in the managed instance + group. + returned: success + type: dict + name: + description: + - The name of the managed instance group. The name must be 1-63 characters long, + and comply with RFC1035. + returned: success + type: str + namedPorts: + description: + - Named ports configured for the Instance Groups complementary to this Instance + Group Manager. + returned: success + type: complex + contains: name: - description: - - The name of the managed instance group. The name must be 1-63 characters long, and - comply with RFC1035. - returned: success - type: str - namedPorts: - description: - - Named ports configured for the Instance Groups complementary to this Instance Group - Manager. - returned: success - type: complex - contains: - name: - description: - - The name for this named port. The name must be 1-63 characters long, and comply - with RFC1035. - returned: success - type: str - port: - description: - - The port number, which can be a value between 1 and 65535. - returned: success - type: int - region: - description: - - The region this managed instance group resides (for regional resources). - returned: success - type: str - targetPools: - description: - - TargetPool resources to which instances in the instanceGroup field are added. The - target pools automatically apply to all of the instances in the managed instance - group. - returned: success - type: list - targetSize: - description: - - The target number of running instances for this managed instance group. Deleting - or abandoning instances reduces this number. Resizing the group changes this number. - returned: success - type: int - zone: - description: - - The zone the managed instance group resides. - returned: success - type: str + description: + - The name for this named port. The name must be 1-63 characters long, and + comply with RFC1035. + returned: success + type: str + port: + description: + - The port number, which can be a value between 1 and 65535. + returned: success + type: int + region: + description: + - The region this managed instance group resides (for regional resources). + returned: success + type: str + targetPools: + description: + - TargetPool resources to which instances in the instanceGroup field are added. + The target pools automatically apply to all of the instances in the managed + instance group. + returned: success + type: list + targetSize: + description: + - The target number of running instances for this managed instance group. Deleting + or abandoning instances reduces this number. Resizing the group changes this + number. + returned: success + type: int + zone: + description: + - The zone the managed instance group resides. + returned: success + type: str ''' ################################################################################ @@ -237,7 +239,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py index 519f965f15..2a7ac854fc 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py @@ -32,361 +32,389 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance_template description: - - Defines an Instance Template resource that provides configuration settings for your - virtual machine instances. Instance templates are not tied to the lifetime of an - instance and can be used and reused as to deploy virtual machines. You can also - use different templates to create different virtual machine configurations. Instance - templates are required when you create a managed instance group. - - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left - behind on machine deletion.' +- Defines an Instance Template resource that provides configuration settings for your + virtual machine instances. Instance templates are not tied to the lifetime of an + instance and can be used and reused as to deploy virtual machines. You can also + use different templates to create different virtual machine configurations. Instance + templates are required when you create a managed instance group. +- 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left + behind on machine deletion.' short_description: Creates a GCP InstanceTemplate version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + name: + description: + - Name of the resource. The name is 1-63 characters long and complies with RFC1035. + required: true + properties: + description: + - The instance properties for this instance template. + required: false + suboptions: + can_ip_forward: description: - - An optional description of this resource. Provide this property when you create - the resource. + - Enables instances created based on this template to send packets with source + IP addresses other than their own and receive packets with destination IP + addresses other than their own. If these instances will be used as an IP + gateway or it will be set as the next-hop in a Route resource, specify true. + If unsure, leave this set to false. required: false - name: + type: bool + description: description: - - Name of the resource. The name is 1-63 characters long and complies with RFC1035. - required: true - properties: + - An optional text description for the instances that are created from this + instance template. + required: false + disks: description: - - The instance properties for this instance template. + - An array of disks that are associated with the instances that are created + from this template. required: false suboptions: - can_ip_forward: - description: - - Enables instances created based on this template to send packets with source IP - addresses other than their own and receive packets with destination IP addresses - other than their own. If these instances will be used as an IP gateway or it will - be set as the next-hop in a Route resource, specify true. If unsure, leave this - set to false. - required: false - type: bool + auto_delete: description: + - Specifies whether the disk will be auto-deleted when the instance is + deleted (but not when the disk is detached from the instance). + - 'Tip: Disks should be set to autoDelete=true so that leftover disks + are not left behind on machine deletion.' + required: false + type: bool + boot: + description: + - Indicates that this is a boot disk. The virtual machine will use the + first partition of the disk for its root filesystem. + required: false + type: bool + device_name: + description: + - Specifies a unique device name of your choice that is reflected into + the /dev/disk/by-id/google-* tree of a Linux operating system running + within the instance. This name can be used to reference the device for + mounting, resizing, and so on, from within the instance. + required: false + disk_encryption_key: + description: + - Encrypts or decrypts a disk using a customer-supplied encryption key. + required: false + suboptions: + raw_key: description: - - An optional text description for the instances that are created from this instance - template. + - Specifies a 256-bit customer-supplied encryption key, encoded in + RFC 4648 base64 to either encrypt or decrypt this resource. required: false - disks: + rsa_encrypted_key: description: - - An array of disks that are associated with the instances that are created from this - template. + - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied + encryption key to either encrypt or decrypt this resource. + required: false + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + required: false + index: + description: + - Assigns a zero-based index to this disk, where 0 is reserved for the + boot disk. For example, if you have many disks attached to an instance, + each disk would have a unique index number. If not specified, the server + will choose an appropriate value. + required: false + initialize_params: + description: + - Specifies the parameters for a new disk that will be created alongside + the new instance. Use initialization parameters to create boot disks + or local SSDs attached to the new instance. + required: false + suboptions: + disk_name: + description: + - Specifies the disk name. If not specified, the default is to use + the name of the instance. + required: false + disk_size_gb: + description: + - Specifies the size of the disk in base-2 GB. + required: false + disk_type: + description: + - Reference to a gcompute_disk_type resource. + - Specifies the disk type to use to create the instance. + - If not specified, the default is pd-standard. + required: false + source_image: + description: + - The source image to create this disk. When creating a new instance, + one of initializeParams.sourceImage or disks.source is required. + To create a disk with one of the public operating system images, + specify the image by its family name. + required: false + source_image_encryption_key: + description: + - The customer-supplied encryption key of the source image. Required + if the source image is protected by a customer-supplied encryption + key. + - Instance templates do not store customer-supplied encryption keys, + so you cannot create disks for instances in a managed instance group + if the source images are encrypted with your own keys. required: false suboptions: - auto_delete: - description: - - Specifies whether the disk will be auto-deleted when the instance is deleted (but - not when the disk is detached from the instance). - - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left - behind on machine deletion.' - required: false - type: bool - boot: - description: - - Indicates that this is a boot disk. The virtual machine will use the first partition - of the disk for its root filesystem. - required: false - type: bool - device_name: - description: - - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* - tree of a Linux operating system running within the instance. This name can be used - to reference the device for mounting, resizing, and so on, from within the instance. - required: false - disk_encryption_key: - description: - - Encrypts or decrypts a disk using a customer-supplied encryption key. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - rsa_encrypted_key: - description: - - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption - key to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - index: - description: - - Assigns a zero-based index to this disk, where 0 is reserved for the boot disk. - For example, if you have many disks attached to an instance, each disk would have - a unique index number. If not specified, the server will choose an appropriate value. - required: false - initialize_params: - description: - - Specifies the parameters for a new disk that will be created alongside the new instance. - Use initialization parameters to create boot disks or local SSDs attached to the - new instance. - required: false - suboptions: - disk_name: - description: - - Specifies the disk name. If not specified, the default is to use the name of the - instance. - required: false - disk_size_gb: - description: - - Specifies the size of the disk in base-2 GB. - required: false - disk_type: - description: - - Reference to a gcompute_disk_type resource. - - Specifies the disk type to use to create the instance. - - If not specified, the default is pd-standard. - required: false - source_image: - description: - - The source image to create this disk. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. To create a disk with one of the public operating - system images, specify the image by its family name. - required: false - source_image_encryption_key: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - - Instance templates do not store customer-supplied encryption keys, so you cannot - create disks for instances in a managed instance group if the source images are - encrypted with your own keys. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - interface: - description: - - Specifies the disk interface to use for attaching this disk, which is either SCSI - or NVME. The default is SCSI. - - Persistent disks must always use SCSI and the request will fail if you attempt to - attach a persistent disk in any other format than SCSI. - required: false - choices: ['SCSI', 'NVME'] - mode: - description: - - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, - the default is to attach the disk in READ_WRITE mode. - required: false - choices: ['READ_WRITE', 'READ_ONLY'] - source: - description: - - Reference to a gcompute_disk resource. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. - - If desired, you can also attach existing non-root persistent disks using this property. - This field is only applicable for persistent disks. - - Note that for InstanceTemplate, specify the disk name, not the URL for the disk. - - 'This field represents a link to a Disk resource in GCP. It can be specified in - two ways. You can add `register: name-of-resource` to a gcp_compute_disk task and - then set this source field to "{{ name-of-resource }}" Alternatively, you can set - this source to a dictionary with the name key where the value is the name of your - Disk.' - required: false - type: - description: - - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - the default is PERSISTENT. - required: false - choices: ['SCRATCH', 'PERSISTENT'] - machine_type: + raw_key: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded + in RFC 4648 base64 to either encrypt or decrypt this resource. + required: false + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + required: false + interface: + description: + - Specifies the disk interface to use for attaching this disk, which is + either SCSI or NVME. The default is SCSI. + - Persistent disks must always use SCSI and the request will fail if you + attempt to attach a persistent disk in any other format than SCSI. + required: false + choices: + - SCSI + - NVME + mode: + description: + - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. + If not specified, the default is to attach the disk in READ_WRITE mode. + required: false + choices: + - READ_WRITE + - READ_ONLY + source: + description: + - Reference to a gcompute_disk resource. When creating a new instance, + one of initializeParams.sourceImage or disks.source is required. + - If desired, you can also attach existing non-root persistent disks using + this property. This field is only applicable for persistent disks. + - Note that for InstanceTemplate, specify the disk name, not the URL for + the disk. + - 'This field represents a link to a Disk resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_disk + task and then set this source field to "{{ name-of-resource }}" Alternatively, + you can set this source to a dictionary with the name key where the + value is the name of your Disk' + required: false + type: + description: + - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not + specified, the default is PERSISTENT. + required: false + choices: + - SCRATCH + - PERSISTENT + machine_type: + description: + - Reference to a gcompute_machine_type resource. + required: true + min_cpu_platform: + description: + - Specifies a minimum CPU platform for the VM instance. Applicable values + are the friendly names of CPU platforms . + required: false + metadata: + description: + - The metadata key/value pairs to assign to instances that are created from + this template. These pairs can consist of custom metadata or predefined + keys. + required: false + guest_accelerators: + description: + - List of the type and count of accelerator cards attached to the instance + . + required: false + suboptions: + accelerator_count: + description: + - The number of the guest accelerator cards exposed to this instance. + required: false + accelerator_type: + description: + - Full or partial URL of the accelerator type resource to expose to this + instance. + required: false + network_interfaces: + description: + - An array of configurations for this interface. This specifies how this interface + is configured to interact with other network services, such as connecting + to the internet. Only one network interface is supported per instance. + required: false + suboptions: + access_configs: + description: + - An array of configurations for this interface. Currently, only one access + config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs + specified, then this instance will have no external internet access. + required: false + suboptions: + name: description: - - Reference to a gcompute_machine_type resource. + - The name of this access configuration. The default and recommended + name is External NAT but you can use any arbitrary string you would + like. For example, My external IP or Network Access. required: true - metadata: + nat_ip: description: - - The metadata key/value pairs to assign to instances that are created from this template. - These pairs can consist of custom metadata or predefined keys. + - Specifies the title of a gcompute_address. + - An external IP address associated with this instance. + - Specify an unused static external IP address available to the project + or leave this field undefined to use an IP from a shared ephemeral + IP address pool. If you specify a static external IP address, it + must live in the same region as the zone of the instance. + - 'This field represents a link to a Address resource in GCP. It can + be specified in two ways. You can add `register: name-of-resource` + to a gcp_compute_address task and then set this nat_ip field to + "{{ name-of-resource }}" Alternatively, you can set this nat_ip + to a dictionary with the address key where the value is the address + of your Address' required: false - guest_accelerators: + type: description: - - List of the type and count of accelerator cards attached to the instance . - required: false - suboptions: - accelerator_count: - description: - - The number of the guest accelerator cards exposed to this instance. - required: false - accelerator_type: - description: - - Full or partial URL of the accelerator type resource to expose to this instance. - required: false - network_interfaces: + - The type of configuration. The default and only option is ONE_TO_ONE_NAT. + required: true + choices: + - ONE_TO_ONE_NAT + alias_ip_ranges: + description: + - An array of alias IP ranges for this network interface. Can only be + specified for network interfaces on subnet-mode networks. + required: false + suboptions: + ip_cidr_range: description: - - An array of configurations for this interface. This specifies how this interface - is configured to interact with other network services, such as connecting to the - internet. Only one network interface is supported per instance. + - The IP CIDR range represented by this alias IP range. + - This IP CIDR range must belong to the specified subnetwork and cannot + contain IP addresses reserved by system or used by other network + interfaces. This range may be a single IP address (e.g. 10.2.3.4), + a netmask (e.g. /24) or a CIDR format string (e.g. 10.1.2.0/24). required: false - suboptions: - access_configs: - description: - - An array of configurations for this interface. Currently, only one access config, - ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this - instance will have no external internet access. - required: false - suboptions: - name: - description: - - The name of this access configuration. The default and recommended name is External - NAT but you can use any arbitrary string you would like. For example, My external - IP or Network Access. - required: true - nat_ip: - description: - - Specifies the title of a gcompute_address. - - An external IP address associated with this instance. - - Specify an unused static external IP address available to the project or leave this - field undefined to use an IP from a shared ephemeral IP address pool. If you specify - a static external IP address, it must live in the same region as the zone of the - instance. - - 'This field represents a link to a Address resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_address task - and then set this nat_ip field to "{{ name-of-resource }}" Alternatively, you can - set this nat_ip to a dictionary with the address key where the value is the address - of your Address.' - required: false - type: - description: - - The type of configuration. The default and only option is ONE_TO_ONE_NAT. - required: true - choices: ['ONE_TO_ONE_NAT'] - alias_ip_ranges: - description: - - An array of alias IP ranges for this network interface. Can only be specified for - network interfaces on subnet-mode networks. - required: false - suboptions: - ip_cidr_range: - description: - - The IP CIDR range represented by this alias IP range. - - This IP CIDR range must belong to the specified subnetwork and cannot contain IP - addresses reserved by system or used by other network interfaces. This range may - be a single IP address (e.g. 10.2.3.4), a netmask (e.g. /24) or a CIDR format string - (e.g. 10.1.2.0/24). - required: false - subnetwork_range_name: - description: - - Optional subnetwork secondary range name specifying the secondary range from which - to allocate the IP CIDR range for this alias IP range. If left unspecified, the - primary range of the subnetwork will be used. - required: false - name: - description: - - The name of the network interface, generated by the server. For network devices, - these are eth0, eth1, etc . - required: false - network: - description: - - Specifies the title of an existing gcompute_network. When creating an instance, - if neither the network nor the subnetwork is specified, the default network global/networks/default - is used; if the network is not specified but the subnetwork is specified, the network - is inferred. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: false - network_ip: - description: - - An IPv4 internal network address to assign to the instance for this network interface. - If not specified by the user, an unused internal IP is assigned by the system. - required: false - subnetwork: - description: - - Reference to a gcompute_subnetwork resource. - - If the network resource is in legacy mode, do not provide this property. If the - network is in auto subnet mode, providing the subnetwork is optional. If the network - is in custom subnet mode, then this field should be specified. - - 'This field represents a link to a Subnetwork resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_subnetwork - task and then set this subnetwork field to "{{ name-of-resource }}" Alternatively, - you can set this subnetwork to a dictionary with the selfLink key where the value - is the selfLink of your Subnetwork.' - required: false - scheduling: + subnetwork_range_name: description: - - Sets the scheduling options for this instance. + - Optional subnetwork secondary range name specifying the secondary + range from which to allocate the IP CIDR range for this alias IP + range. If left unspecified, the primary range of the subnetwork + will be used. required: false - suboptions: - automatic_restart: - description: - - Specifies whether the instance should be automatically restarted if it is terminated - by Compute Engine (not terminated by a user). - - You can only set the automatic restart option for standard instances. Preemptible - instances cannot be automatically restarted. - required: false - type: bool - on_host_maintenance: - description: - - Defines the maintenance behavior for this instance. For standard instances, the - default behavior is MIGRATE. For preemptible instances, the default and only possible - behavior is TERMINATE. - - For more information, see Setting Instance Scheduling Options. - required: false - preemptible: - description: - - Defines whether the instance is preemptible. This can only be set during instance - creation, it cannot be set or changed after the instance has been created. - required: false - type: bool - service_accounts: - description: - - A list of service accounts, with their specified scopes, authorized for this instance. - Only one service account per VM instance is supported. - required: false - suboptions: - email: - description: - - Email address of the service account. - required: false - scopes: - description: - - The list of scopes to be made available for this service account. - required: false - tags: - description: - - A list of tags to apply to this instance. Tags are used to identify valid sources - or targets for network firewalls and are specified by the client during instance - creation. The tags can be later modified by the setTags method. Each tag within - the list must comply with RFC1035. - required: false - suboptions: - fingerprint: - description: - - Specifies a fingerprint for this request, which is essentially a hash of the metadata's - contents and used for optimistic locking. - - The fingerprint is initially generated by Compute Engine and changes after every - request to modify or update metadata. You must always provide an up-to-date fingerprint - hash in order to update or change metadata. - required: false - items: - description: - - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. - required: false + name: + description: + - The name of the network interface, generated by the server. For network + devices, these are eth0, eth1, etc . + required: false + network: + description: + - Specifies the title of an existing gcompute_network. When creating an + instance, if neither the network nor the subnetwork is specified, the + default network global/networks/default is used; if the network is not + specified but the subnetwork is specified, the network is inferred. + - 'This field represents a link to a Network resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a + gcp_compute_network task and then set this network field to "{{ name-of-resource + }}" Alternatively, you can set this network to a dictionary with the + selfLink key where the value is the selfLink of your Network' + required: false + network_ip: + description: + - An IPv4 internal network address to assign to the instance for this + network interface. If not specified by the user, an unused internal + IP is assigned by the system. + required: false + subnetwork: + description: + - Reference to a gcompute_subnetwork resource. + - If the network resource is in legacy mode, do not provide this property. + If the network is in auto subnet mode, providing the subnetwork is optional. + If the network is in custom subnet mode, then this field should be specified. + - 'This field represents a link to a Subnetwork resource in GCP. It can + be specified in two ways. You can add `register: name-of-resource` to + a gcp_compute_subnetwork task and then set this subnetwork field to + "{{ name-of-resource }}" Alternatively, you can set this subnetwork + to a dictionary with the selfLink key where the value is the selfLink + of your Subnetwork' + required: false + scheduling: + description: + - Sets the scheduling options for this instance. + required: false + suboptions: + automatic_restart: + description: + - Specifies whether the instance should be automatically restarted if + it is terminated by Compute Engine (not terminated by a user). + - You can only set the automatic restart option for standard instances. + Preemptible instances cannot be automatically restarted. + required: false + type: bool + on_host_maintenance: + description: + - Defines the maintenance behavior for this instance. For standard instances, + the default behavior is MIGRATE. For preemptible instances, the default + and only possible behavior is TERMINATE. + - For more information, see Setting Instance Scheduling Options. + required: false + preemptible: + description: + - Defines whether the instance is preemptible. This can only be set during + instance creation, it cannot be set or changed after the instance has + been created. + required: false + type: bool + service_accounts: + description: + - A list of service accounts, with their specified scopes, authorized for + this instance. Only one service account per VM instance is supported. + required: false + suboptions: + email: + description: + - Email address of the service account. + required: false + scopes: + description: + - The list of scopes to be made available for this service account. + required: false + tags: + description: + - A list of tags to apply to this instance. Tags are used to identify valid + sources or targets for network firewalls and are specified by the client + during instance creation. The tags can be later modified by the setTags + method. Each tag within the list must comply with RFC1035. + required: false + suboptions: + fingerprint: + description: + - Specifies a fingerprint for this request, which is essentially a hash + of the metadata's contents and used for optimistic locking. + - The fingerprint is initially generated by Compute Engine and changes + after every request to modify or update metadata. You must always provide + an up-to-date fingerprint hash in order to update or change metadata. + required: false + items: + description: + - An array of tags. Each tag must be 1-63 characters long, and comply + with RFC1035. + required: false extends_documentation_fragment: gcp ''' @@ -433,375 +461,390 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. This identifier is defined by the server. + returned: success + type: int +name: + description: + - Name of the resource. The name is 1-63 characters long and complies with RFC1035. + returned: success + type: str +properties: + description: + - The instance properties for this instance template. + returned: success + type: complex + contains: + canIpForward: + description: + - Enables instances created based on this template to send packets with source + IP addresses other than their own and receive packets with destination IP + addresses other than their own. If these instances will be used as an IP gateway + or it will be set as the next-hop in a Route resource, specify true. If unsure, + leave this set to false. + returned: success + type: bool description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. The name is 1-63 characters long and complies with RFC1035. - returned: success - type: str - properties: - description: - - The instance properties for this instance template. - returned: success - type: complex - contains: - canIpForward: - description: - - Enables instances created based on this template to send packets with source IP - addresses other than their own and receive packets with destination IP addresses - other than their own. If these instances will be used as an IP gateway or it will - be set as the next-hop in a Route resource, specify true. If unsure, leave this - set to false. - returned: success - type: bool - description: - description: - - An optional text description for the instances that are created from this instance - template. - returned: success - type: str - disks: - description: - - An array of disks that are associated with the instances that are created from this - template. - returned: success - type: complex - contains: - autoDelete: - description: - - Specifies whether the disk will be auto-deleted when the instance is deleted (but - not when the disk is detached from the instance). - - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left - behind on machine deletion.' - returned: success - type: bool - boot: - description: - - Indicates that this is a boot disk. The virtual machine will use the first partition - of the disk for its root filesystem. - returned: success - type: bool - deviceName: - description: - - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* - tree of a Linux operating system running within the instance. This name can be used - to reference the device for mounting, resizing, and so on, from within the instance. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts or decrypts a disk using a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - rsaEncryptedKey: - description: - - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption - key to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - index: - description: - - Assigns a zero-based index to this disk, where 0 is reserved for the boot disk. - For example, if you have many disks attached to an instance, each disk would have - a unique index number. If not specified, the server will choose an appropriate value. - returned: success - type: int - initializeParams: - description: - - Specifies the parameters for a new disk that will be created alongside the new instance. - Use initialization parameters to create boot disks or local SSDs attached to the - new instance. - returned: success - type: complex - contains: - diskName: - description: - - Specifies the disk name. If not specified, the default is to use the name of the - instance. - returned: success - type: str - diskSizeGb: - description: - - Specifies the size of the disk in base-2 GB. - returned: success - type: int - diskType: - description: - - Reference to a gcompute_disk_type resource. - - Specifies the disk type to use to create the instance. - - If not specified, the default is pd-standard. - returned: success - type: str - sourceImage: - description: - - The source image to create this disk. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. To create a disk with one of the public operating - system images, specify the image by its family name. - returned: success - type: str - sourceImageEncryptionKey: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - - Instance templates do not store customer-supplied encryption keys, so you cannot - create disks for instances in a managed instance group if the source images are - encrypted with your own keys. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - interface: - description: - - Specifies the disk interface to use for attaching this disk, which is either SCSI - or NVME. The default is SCSI. - - Persistent disks must always use SCSI and the request will fail if you attempt to - attach a persistent disk in any other format than SCSI. - returned: success - type: str - mode: - description: - - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, - the default is to attach the disk in READ_WRITE mode. - returned: success - type: str - source: - description: - - Reference to a gcompute_disk resource. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. - - If desired, you can also attach existing non-root persistent disks using this property. - This field is only applicable for persistent disks. - - Note that for InstanceTemplate, specify the disk name, not the URL for the disk. - returned: success - type: dict - type: - description: - - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - the default is PERSISTENT. - returned: success - type: str - machineType: - description: - - Reference to a gcompute_machine_type resource. - returned: success - type: str - metadata: - description: - - The metadata key/value pairs to assign to instances that are created from this template. - These pairs can consist of custom metadata or predefined keys. - returned: success - type: dict - guestAccelerators: - description: - - List of the type and count of accelerator cards attached to the instance . - returned: success - type: complex - contains: - acceleratorCount: - description: - - The number of the guest accelerator cards exposed to this instance. - returned: success - type: int - acceleratorType: - description: - - Full or partial URL of the accelerator type resource to expose to this instance. - returned: success - type: str - networkInterfaces: - description: - - An array of configurations for this interface. This specifies how this interface - is configured to interact with other network services, such as connecting to the - internet. Only one network interface is supported per instance. - returned: success - type: complex - contains: - accessConfigs: - description: - - An array of configurations for this interface. Currently, only one access config, - ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this - instance will have no external internet access. - returned: success - type: complex - contains: - name: - description: - - The name of this access configuration. The default and recommended name is External - NAT but you can use any arbitrary string you would like. For example, My external - IP or Network Access. - returned: success - type: str - natIP: - description: - - Specifies the title of a gcompute_address. - - An external IP address associated with this instance. - - Specify an unused static external IP address available to the project or leave this - field undefined to use an IP from a shared ephemeral IP address pool. If you specify - a static external IP address, it must live in the same region as the zone of the - instance. - returned: success - type: dict - type: - description: - - The type of configuration. The default and only option is ONE_TO_ONE_NAT. - returned: success - type: str - aliasIpRanges: - description: - - An array of alias IP ranges for this network interface. Can only be specified for - network interfaces on subnet-mode networks. - returned: success - type: complex - contains: - ipCidrRange: - description: - - The IP CIDR range represented by this alias IP range. - - This IP CIDR range must belong to the specified subnetwork and cannot contain IP - addresses reserved by system or used by other network interfaces. This range may - be a single IP address (e.g. 10.2.3.4), a netmask (e.g. /24) or a CIDR format string - (e.g. 10.1.2.0/24). - returned: success - type: str - subnetworkRangeName: - description: - - Optional subnetwork secondary range name specifying the secondary range from which - to allocate the IP CIDR range for this alias IP range. If left unspecified, the - primary range of the subnetwork will be used. - returned: success - type: str - name: - description: - - The name of the network interface, generated by the server. For network devices, - these are eth0, eth1, etc . - returned: success - type: str - network: - description: - - Specifies the title of an existing gcompute_network. When creating an instance, - if neither the network nor the subnetwork is specified, the default network global/networks/default - is used; if the network is not specified but the subnetwork is specified, the network - is inferred. - returned: success - type: dict - networkIP: - description: - - An IPv4 internal network address to assign to the instance for this network interface. - If not specified by the user, an unused internal IP is assigned by the system. - returned: success - type: str - subnetwork: - description: - - Reference to a gcompute_subnetwork resource. - - If the network resource is in legacy mode, do not provide this property. If the - network is in auto subnet mode, providing the subnetwork is optional. If the network - is in custom subnet mode, then this field should be specified. - returned: success - type: dict - scheduling: - description: - - Sets the scheduling options for this instance. - returned: success - type: complex - contains: - automaticRestart: - description: - - Specifies whether the instance should be automatically restarted if it is terminated - by Compute Engine (not terminated by a user). - - You can only set the automatic restart option for standard instances. Preemptible - instances cannot be automatically restarted. - returned: success - type: bool - onHostMaintenance: - description: - - Defines the maintenance behavior for this instance. For standard instances, the - default behavior is MIGRATE. For preemptible instances, the default and only possible - behavior is TERMINATE. - - For more information, see Setting Instance Scheduling Options. - returned: success - type: str - preemptible: - description: - - Defines whether the instance is preemptible. This can only be set during instance - creation, it cannot be set or changed after the instance has been created. - returned: success - type: bool - serviceAccounts: - description: - - A list of service accounts, with their specified scopes, authorized for this instance. - Only one service account per VM instance is supported. - returned: success - type: complex - contains: - email: - description: - - Email address of the service account. - returned: success - type: str - scopes: - description: - - The list of scopes to be made available for this service account. - returned: success - type: list - tags: - description: - - A list of tags to apply to this instance. Tags are used to identify valid sources - or targets for network firewalls and are specified by the client during instance - creation. The tags can be later modified by the setTags method. Each tag within - the list must comply with RFC1035. - returned: success - type: complex - contains: - fingerprint: - description: - - Specifies a fingerprint for this request, which is essentially a hash of the metadata's - contents and used for optimistic locking. - - The fingerprint is initially generated by Compute Engine and changes after every - request to modify or update metadata. You must always provide an up-to-date fingerprint - hash in order to update or change metadata. - returned: success - type: str - items: - description: - - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. - returned: success - type: list + description: + - An optional text description for the instances that are created from this + instance template. + returned: success + type: str + disks: + description: + - An array of disks that are associated with the instances that are created + from this template. + returned: success + type: complex + contains: + autoDelete: + description: + - Specifies whether the disk will be auto-deleted when the instance is deleted + (but not when the disk is detached from the instance). + - 'Tip: Disks should be set to autoDelete=true so that leftover disks are + not left behind on machine deletion.' + returned: success + type: bool + boot: + description: + - Indicates that this is a boot disk. The virtual machine will use the first + partition of the disk for its root filesystem. + returned: success + type: bool + deviceName: + description: + - Specifies a unique device name of your choice that is reflected into the + /dev/disk/by-id/google-* tree of a Linux operating system running within + the instance. This name can be used to reference the device for mounting, + resizing, and so on, from within the instance. + returned: success + type: str + diskEncryptionKey: + description: + - Encrypts or decrypts a disk using a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC + 4648 base64 to either encrypt or decrypt this resource. + returned: success + type: str + rsaEncryptedKey: + description: + - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied + encryption key to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + returned: success + type: str + index: + description: + - Assigns a zero-based index to this disk, where 0 is reserved for the boot + disk. For example, if you have many disks attached to an instance, each + disk would have a unique index number. If not specified, the server will + choose an appropriate value. + returned: success + type: int + initializeParams: + description: + - Specifies the parameters for a new disk that will be created alongside + the new instance. Use initialization parameters to create boot disks or + local SSDs attached to the new instance. + returned: success + type: complex + contains: + diskName: + description: + - Specifies the disk name. If not specified, the default is to use the + name of the instance. + returned: success + type: str + diskSizeGb: + description: + - Specifies the size of the disk in base-2 GB. + returned: success + type: int + diskType: + description: + - Reference to a gcompute_disk_type resource. + - Specifies the disk type to use to create the instance. + - If not specified, the default is pd-standard. + returned: success + type: str + sourceImage: + description: + - The source image to create this disk. When creating a new instance, + one of initializeParams.sourceImage or disks.source is required. To + create a disk with one of the public operating system images, specify + the image by its family name. + returned: success + type: str + sourceImageEncryptionKey: + description: + - The customer-supplied encryption key of the source image. Required + if the source image is protected by a customer-supplied encryption + key. + - Instance templates do not store customer-supplied encryption keys, + so you cannot create disks for instances in a managed instance group + if the source images are encrypted with your own keys. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded + in RFC 4648 base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + returned: success + type: str + interface: + description: + - Specifies the disk interface to use for attaching this disk, which is + either SCSI or NVME. The default is SCSI. + - Persistent disks must always use SCSI and the request will fail if you + attempt to attach a persistent disk in any other format than SCSI. + returned: success + type: str + mode: + description: + - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. + If not specified, the default is to attach the disk in READ_WRITE mode. + returned: success + type: str + source: + description: + - Reference to a gcompute_disk resource. When creating a new instance, one + of initializeParams.sourceImage or disks.source is required. + - If desired, you can also attach existing non-root persistent disks using + this property. This field is only applicable for persistent disks. + - Note that for InstanceTemplate, specify the disk name, not the URL for + the disk. + returned: success + type: dict + type: + description: + - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, + the default is PERSISTENT. + returned: success + type: str + machineType: + description: + - Reference to a gcompute_machine_type resource. + returned: success + type: str + minCpuPlatform: + description: + - Specifies a minimum CPU platform for the VM instance. Applicable values are + the friendly names of CPU platforms . + returned: success + type: str + metadata: + description: + - The metadata key/value pairs to assign to instances that are created from + this template. These pairs can consist of custom metadata or predefined keys. + returned: success + type: dict + guestAccelerators: + description: + - List of the type and count of accelerator cards attached to the instance . + returned: success + type: complex + contains: + acceleratorCount: + description: + - The number of the guest accelerator cards exposed to this instance. + returned: success + type: int + acceleratorType: + description: + - Full or partial URL of the accelerator type resource to expose to this + instance. + returned: success + type: str + networkInterfaces: + description: + - An array of configurations for this interface. This specifies how this interface + is configured to interact with other network services, such as connecting + to the internet. Only one network interface is supported per instance. + returned: success + type: complex + contains: + accessConfigs: + description: + - An array of configurations for this interface. Currently, only one access + config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, + then this instance will have no external internet access. + returned: success + type: complex + contains: + name: + description: + - The name of this access configuration. The default and recommended + name is External NAT but you can use any arbitrary string you would + like. For example, My external IP or Network Access. + returned: success + type: str + natIP: + description: + - Specifies the title of a gcompute_address. + - An external IP address associated with this instance. + - Specify an unused static external IP address available to the project + or leave this field undefined to use an IP from a shared ephemeral + IP address pool. If you specify a static external IP address, it must + live in the same region as the zone of the instance. + returned: success + type: dict + type: + description: + - The type of configuration. The default and only option is ONE_TO_ONE_NAT. + returned: success + type: str + aliasIpRanges: + description: + - An array of alias IP ranges for this network interface. Can only be specified + for network interfaces on subnet-mode networks. + returned: success + type: complex + contains: + ipCidrRange: + description: + - The IP CIDR range represented by this alias IP range. + - This IP CIDR range must belong to the specified subnetwork and cannot + contain IP addresses reserved by system or used by other network interfaces. + This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g. + /24) or a CIDR format string (e.g. 10.1.2.0/24). + returned: success + type: str + subnetworkRangeName: + description: + - Optional subnetwork secondary range name specifying the secondary + range from which to allocate the IP CIDR range for this alias IP range. + If left unspecified, the primary range of the subnetwork will be used. + returned: success + type: str + name: + description: + - The name of the network interface, generated by the server. For network + devices, these are eth0, eth1, etc . + returned: success + type: str + network: + description: + - Specifies the title of an existing gcompute_network. When creating an + instance, if neither the network nor the subnetwork is specified, the + default network global/networks/default is used; if the network is not + specified but the subnetwork is specified, the network is inferred. + returned: success + type: dict + networkIP: + description: + - An IPv4 internal network address to assign to the instance for this network + interface. If not specified by the user, an unused internal IP is assigned + by the system. + returned: success + type: str + subnetwork: + description: + - Reference to a gcompute_subnetwork resource. + - If the network resource is in legacy mode, do not provide this property. + If the network is in auto subnet mode, providing the subnetwork is optional. + If the network is in custom subnet mode, then this field should be specified. + returned: success + type: dict + scheduling: + description: + - Sets the scheduling options for this instance. + returned: success + type: complex + contains: + automaticRestart: + description: + - Specifies whether the instance should be automatically restarted if it + is terminated by Compute Engine (not terminated by a user). + - You can only set the automatic restart option for standard instances. + Preemptible instances cannot be automatically restarted. + returned: success + type: bool + onHostMaintenance: + description: + - Defines the maintenance behavior for this instance. For standard instances, + the default behavior is MIGRATE. For preemptible instances, the default + and only possible behavior is TERMINATE. + - For more information, see Setting Instance Scheduling Options. + returned: success + type: str + preemptible: + description: + - Defines whether the instance is preemptible. This can only be set during + instance creation, it cannot be set or changed after the instance has + been created. + returned: success + type: bool + serviceAccounts: + description: + - A list of service accounts, with their specified scopes, authorized for this + instance. Only one service account per VM instance is supported. + returned: success + type: complex + contains: + email: + description: + - Email address of the service account. + returned: success + type: str + scopes: + description: + - The list of scopes to be made available for this service account. + returned: success + type: list + tags: + description: + - A list of tags to apply to this instance. Tags are used to identify valid + sources or targets for network firewalls and are specified by the client during + instance creation. The tags can be later modified by the setTags method. Each + tag within the list must comply with RFC1035. + returned: success + type: complex + contains: + fingerprint: + description: + - Specifies a fingerprint for this request, which is essentially a hash + of the metadata's contents and used for optimistic locking. + - The fingerprint is initially generated by Compute Engine and changes after + every request to modify or update metadata. You must always provide an + up-to-date fingerprint hash in order to update or change metadata. + returned: success + type: str + items: + description: + - An array of tags. Each tag must be 1-63 characters long, and comply with + RFC1035. + returned: success + type: list ''' ################################################################################ @@ -855,6 +898,7 @@ def main(): type=dict(type='str', choices=['SCRATCH', 'PERSISTENT']) )), machine_type=dict(required=True, type='str'), + min_cpu_platform=dict(type='str'), metadata=dict(type='dict'), guest_accelerators=dict(type='list', elements='dict', options=dict( accelerator_count=dict(type='int'), @@ -1053,8 +1097,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -1131,11 +1173,12 @@ class InstanceTemplateProperties(object): u'description': self.request.get('description'), u'disks': InstanceTemplateDisksArray(self.request.get('disks', []), self.module).to_request(), u'machineType': self.request.get('machine_type'), + u'minCpuPlatform': self.request.get('min_cpu_platform'), u'metadata': self.request.get('metadata'), - u'guestAccelerators': InstanceTemplateGuestAcceleratorsArray(self.request.get('guest_accelerators', []), self.module).to_request(), - u'networkInterfaces': InstanceTemplateNetworkInterfacesArray(self.request.get('network_interfaces', []), self.module).to_request(), + u'guestAccelerators': InstanceTemplateGuestacceleratorsArray(self.request.get('guest_accelerators', []), self.module).to_request(), + u'networkInterfaces': InstanceTemplateNetworkinterfacesArray(self.request.get('network_interfaces', []), self.module).to_request(), u'scheduling': InstanceTemplateScheduling(self.request.get('scheduling', {}), self.module).to_request(), - u'serviceAccounts': InstanceTemplateServiceAccountsArray(self.request.get('service_accounts', []), self.module).to_request(), + u'serviceAccounts': InstanceTemplateServiceaccountsArray(self.request.get('service_accounts', []), self.module).to_request(), u'tags': InstanceTemplateTags(self.request.get('tags', {}), self.module).to_request() }) @@ -1145,11 +1188,12 @@ class InstanceTemplateProperties(object): u'description': self.request.get(u'description'), u'disks': InstanceTemplateDisksArray(self.request.get(u'disks', []), self.module).from_response(), u'machineType': self.request.get(u'machineType'), + u'minCpuPlatform': self.request.get(u'minCpuPlatform'), u'metadata': self.request.get(u'metadata'), - u'guestAccelerators': InstanceTemplateGuestAcceleratorsArray(self.request.get(u'guestAccelerators', []), self.module).from_response(), - u'networkInterfaces': InstanceTemplateNetworkInterfacesArray(self.request.get(u'networkInterfaces', []), self.module).from_response(), + u'guestAccelerators': InstanceTemplateGuestacceleratorsArray(self.request.get(u'guestAccelerators', []), self.module).from_response(), + u'networkInterfaces': InstanceTemplateNetworkinterfacesArray(self.request.get(u'networkInterfaces', []), self.module).from_response(), u'scheduling': InstanceTemplateScheduling(self.request.get(u'scheduling', {}), self.module).from_response(), - u'serviceAccounts': InstanceTemplateServiceAccountsArray(self.request.get(u'serviceAccounts', []), self.module).from_response(), + u'serviceAccounts': InstanceTemplateServiceaccountsArray(self.request.get(u'serviceAccounts', []), self.module).from_response(), u'tags': InstanceTemplateTags(self.request.get(u'tags', {}), self.module).from_response() }) @@ -1179,9 +1223,9 @@ class InstanceTemplateDisksArray(object): u'autoDelete': item.get('auto_delete'), u'boot': item.get('boot'), u'deviceName': item.get('device_name'), - u'diskEncryptionKey': InstanceTemplateDiskEncryptionKey(item.get('disk_encryption_key', {}), self.module).to_request(), + u'diskEncryptionKey': InstanceTemplateDiskencryptionkey(item.get('disk_encryption_key', {}), self.module).to_request(), u'index': item.get('index'), - u'initializeParams': InstanceTemplateInitializeParams(item.get('initialize_params', {}), self.module).to_request(), + u'initializeParams': InstanceTemplateInitializeparams(item.get('initialize_params', {}), self.module).to_request(), u'interface': item.get('interface'), u'mode': item.get('mode'), u'source': replace_resource_dict(item.get(u'source', {}), 'name'), @@ -1193,9 +1237,9 @@ class InstanceTemplateDisksArray(object): u'autoDelete': item.get(u'autoDelete'), u'boot': item.get(u'boot'), u'deviceName': item.get(u'deviceName'), - u'diskEncryptionKey': InstanceTemplateDiskEncryptionKey(item.get(u'diskEncryptionKey', {}), self.module).from_response(), + u'diskEncryptionKey': InstanceTemplateDiskencryptionkey(item.get(u'diskEncryptionKey', {}), self.module).from_response(), u'index': item.get(u'index'), - u'initializeParams': InstanceTemplateInitializeParams(self.module.params.get('initialize_params', {}), self.module).to_request(), + u'initializeParams': InstanceTemplateInitializeparams(self.module.params.get('initialize_params', {}), self.module).to_request(), u'interface': item.get(u'interface'), u'mode': item.get(u'mode'), u'source': item.get(u'source'), @@ -1203,7 +1247,7 @@ class InstanceTemplateDisksArray(object): }) -class InstanceTemplateDiskEncryptionKey(object): +class InstanceTemplateDiskencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -1226,7 +1270,7 @@ class InstanceTemplateDiskEncryptionKey(object): }) -class InstanceTemplateInitializeParams(object): +class InstanceTemplateInitializeparams(object): def __init__(self, request, module): self.module = module if request: @@ -1240,7 +1284,7 @@ class InstanceTemplateInitializeParams(object): u'diskSizeGb': self.request.get('disk_size_gb'), u'diskType': disk_type_selflink(self.request.get('disk_type'), self.module.params), u'sourceImage': self.request.get('source_image'), - u'sourceImageEncryptionKey': InstanceTemplateSourceImageEncryptionKey(self.request.get('source_image_encryption_key', {}), self.module).to_request() + u'sourceImageEncryptionKey': InstanceTemplateSourceimageencryptionkey(self.request.get('source_image_encryption_key', {}), self.module).to_request() }) def from_response(self): @@ -1250,11 +1294,11 @@ class InstanceTemplateInitializeParams(object): u'diskType': self.request.get(u'diskType'), u'sourceImage': self.request.get(u'sourceImage'), u'sourceImageEncryptionKey': - InstanceTemplateSourceImageEncryptionKey(self.request.get(u'sourceImageEncryptionKey', {}), self.module).from_response() + InstanceTemplateSourceimageencryptionkey(self.request.get(u'sourceImageEncryptionKey', {}), self.module).from_response() }) -class InstanceTemplateSourceImageEncryptionKey(object): +class InstanceTemplateSourceimageencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -1275,7 +1319,7 @@ class InstanceTemplateSourceImageEncryptionKey(object): }) -class InstanceTemplateGuestAcceleratorsArray(object): +class InstanceTemplateGuestacceleratorsArray(object): def __init__(self, request, module): self.module = module if request: @@ -1308,7 +1352,7 @@ class InstanceTemplateGuestAcceleratorsArray(object): }) -class InstanceTemplateNetworkInterfacesArray(object): +class InstanceTemplateNetworkinterfacesArray(object): def __init__(self, request, module): self.module = module if request: @@ -1330,8 +1374,8 @@ class InstanceTemplateNetworkInterfacesArray(object): def _request_for_item(self, item): return remove_nones_from_dict({ - u'accessConfigs': InstanceTemplateAccessConfigsArray(item.get('access_configs', []), self.module).to_request(), - u'aliasIpRanges': InstanceTemplateAliasIpRangesArray(item.get('alias_ip_ranges', []), self.module).to_request(), + u'accessConfigs': InstanceTemplateAccessconfigsArray(item.get('access_configs', []), self.module).to_request(), + u'aliasIpRanges': InstanceTemplateAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(), u'name': item.get('name'), u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'), u'networkIP': item.get('network_ip'), @@ -1340,8 +1384,8 @@ class InstanceTemplateNetworkInterfacesArray(object): def _response_from_item(self, item): return remove_nones_from_dict({ - u'accessConfigs': InstanceTemplateAccessConfigsArray(item.get(u'accessConfigs', []), self.module).from_response(), - u'aliasIpRanges': InstanceTemplateAliasIpRangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(), + u'accessConfigs': InstanceTemplateAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(), + u'aliasIpRanges': InstanceTemplateAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(), u'name': item.get(u'name'), u'network': item.get(u'network'), u'networkIP': item.get(u'networkIP'), @@ -1349,7 +1393,7 @@ class InstanceTemplateNetworkInterfacesArray(object): }) -class InstanceTemplateAccessConfigsArray(object): +class InstanceTemplateAccessconfigsArray(object): def __init__(self, request, module): self.module = module if request: @@ -1384,7 +1428,7 @@ class InstanceTemplateAccessConfigsArray(object): }) -class InstanceTemplateAliasIpRangesArray(object): +class InstanceTemplateAliasiprangesArray(object): def __init__(self, request, module): self.module = module if request: @@ -1440,7 +1484,7 @@ class InstanceTemplateScheduling(object): }) -class InstanceTemplateServiceAccountsArray(object): +class InstanceTemplateServiceaccountsArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_template_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_template_facts.py index 5d687b9d92..bc6eb93987 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_template_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_template_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_instance_template_facts description: - - Gather facts for GCP InstanceTemplate +- Gather facts for GCP InstanceTemplate short_description: Gather facts for GCP InstanceTemplate version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,379 +61,404 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. This identifier is defined by the + server. + returned: success + type: int + name: + description: + - Name of the resource. The name is 1-63 characters long and complies with RFC1035. + returned: success + type: str + properties: + description: + - The instance properties for this instance template. + returned: success + type: complex + contains: + canIpForward: + description: + - Enables instances created based on this template to send packets with + source IP addresses other than their own and receive packets with destination + IP addresses other than their own. If these instances will be used as + an IP gateway or it will be set as the next-hop in a Route resource, specify + true. If unsure, leave this set to false. + returned: success + type: bool description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. This identifier is defined by the server. - returned: success - type: int - name: - description: - - Name of the resource. The name is 1-63 characters long and complies with RFC1035. - returned: success - type: str - properties: - description: - - The instance properties for this instance template. - returned: success - type: complex - contains: - canIpForward: - description: - - Enables instances created based on this template to send packets with source IP - addresses other than their own and receive packets with destination IP addresses - other than their own. If these instances will be used as an IP gateway or it will - be set as the next-hop in a Route resource, specify true. If unsure, leave this - set to false. - returned: success - type: bool - description: - description: - - An optional text description for the instances that are created from this instance - template. - returned: success - type: str - disks: - description: - - An array of disks that are associated with the instances that are created from this - template. - returned: success - type: complex - contains: - autoDelete: - description: - - Specifies whether the disk will be auto-deleted when the instance is deleted (but - not when the disk is detached from the instance). - - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left - behind on machine deletion.' - returned: success - type: bool - boot: - description: - - Indicates that this is a boot disk. The virtual machine will use the first partition - of the disk for its root filesystem. - returned: success - type: bool - deviceName: - description: - - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-* - tree of a Linux operating system running within the instance. This name can be used - to reference the device for mounting, resizing, and so on, from within the instance. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts or decrypts a disk using a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - rsaEncryptedKey: - description: - - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption - key to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - index: - description: - - Assigns a zero-based index to this disk, where 0 is reserved for the boot disk. - For example, if you have many disks attached to an instance, each disk would have - a unique index number. If not specified, the server will choose an appropriate value. - returned: success - type: int - initializeParams: - description: - - Specifies the parameters for a new disk that will be created alongside the new instance. - Use initialization parameters to create boot disks or local SSDs attached to the - new instance. - returned: success - type: complex - contains: - diskName: - description: - - Specifies the disk name. If not specified, the default is to use the name of the - instance. - returned: success - type: str - diskSizeGb: - description: - - Specifies the size of the disk in base-2 GB. - returned: success - type: int - diskType: - description: - - Reference to a gcompute_disk_type resource. - - Specifies the disk type to use to create the instance. - - If not specified, the default is pd-standard. - returned: success - type: str - sourceImage: - description: - - The source image to create this disk. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. To create a disk with one of the public operating - system images, specify the image by its family name. - returned: success - type: str - sourceImageEncryptionKey: - description: - - The customer-supplied encryption key of the source image. Required if the source - image is protected by a customer-supplied encryption key. - - Instance templates do not store customer-supplied encryption keys, so you cannot - create disks for instances in a managed instance group if the source images are - encrypted with your own keys. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - interface: - description: - - Specifies the disk interface to use for attaching this disk, which is either SCSI - or NVME. The default is SCSI. - - Persistent disks must always use SCSI and the request will fail if you attempt to - attach a persistent disk in any other format than SCSI. - returned: success - type: str - mode: - description: - - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, - the default is to attach the disk in READ_WRITE mode. - returned: success - type: str - source: - description: - - Reference to a gcompute_disk resource. When creating a new instance, one of initializeParams.sourceImage - or disks.source is required. - - If desired, you can also attach existing non-root persistent disks using this property. - This field is only applicable for persistent disks. - - Note that for InstanceTemplate, specify the disk name, not the URL for the disk. - returned: success - type: dict - type: - description: - - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - the default is PERSISTENT. - returned: success - type: str - machineType: - description: - - Reference to a gcompute_machine_type resource. - returned: success - type: str - metadata: - description: - - The metadata key/value pairs to assign to instances that are created from this template. - These pairs can consist of custom metadata or predefined keys. - returned: success - type: dict - guestAccelerators: - description: - - List of the type and count of accelerator cards attached to the instance . - returned: success - type: complex - contains: - acceleratorCount: - description: - - The number of the guest accelerator cards exposed to this instance. - returned: success - type: int - acceleratorType: - description: - - Full or partial URL of the accelerator type resource to expose to this instance. - returned: success - type: str - networkInterfaces: - description: - - An array of configurations for this interface. This specifies how this interface - is configured to interact with other network services, such as connecting to the - internet. Only one network interface is supported per instance. - returned: success - type: complex - contains: - accessConfigs: - description: - - An array of configurations for this interface. Currently, only one access config, - ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified, then this - instance will have no external internet access. - returned: success - type: complex - contains: - name: - description: - - The name of this access configuration. The default and recommended name is External - NAT but you can use any arbitrary string you would like. For example, My external - IP or Network Access. - returned: success - type: str - natIP: - description: - - Specifies the title of a gcompute_address. - - An external IP address associated with this instance. - - Specify an unused static external IP address available to the project or leave this - field undefined to use an IP from a shared ephemeral IP address pool. If you specify - a static external IP address, it must live in the same region as the zone of the - instance. - returned: success - type: dict - type: - description: - - The type of configuration. The default and only option is ONE_TO_ONE_NAT. - returned: success - type: str - aliasIpRanges: - description: - - An array of alias IP ranges for this network interface. Can only be specified for - network interfaces on subnet-mode networks. - returned: success - type: complex - contains: - ipCidrRange: - description: - - The IP CIDR range represented by this alias IP range. - - This IP CIDR range must belong to the specified subnetwork and cannot contain IP - addresses reserved by system or used by other network interfaces. This range may - be a single IP address (e.g. 10.2.3.4), a netmask (e.g. /24) or a CIDR format string - (e.g. 10.1.2.0/24). - returned: success - type: str - subnetworkRangeName: - description: - - Optional subnetwork secondary range name specifying the secondary range from which - to allocate the IP CIDR range for this alias IP range. If left unspecified, the - primary range of the subnetwork will be used. - returned: success - type: str - name: - description: - - The name of the network interface, generated by the server. For network devices, - these are eth0, eth1, etc . - returned: success - type: str - network: - description: - - Specifies the title of an existing gcompute_network. When creating an instance, - if neither the network nor the subnetwork is specified, the default network global/networks/default - is used; if the network is not specified but the subnetwork is specified, the network - is inferred. - returned: success - type: dict - networkIP: - description: - - An IPv4 internal network address to assign to the instance for this network interface. - If not specified by the user, an unused internal IP is assigned by the system. - returned: success - type: str - subnetwork: - description: - - Reference to a gcompute_subnetwork resource. - - If the network resource is in legacy mode, do not provide this property. If the - network is in auto subnet mode, providing the subnetwork is optional. If the network - is in custom subnet mode, then this field should be specified. - returned: success - type: dict - scheduling: - description: - - Sets the scheduling options for this instance. - returned: success - type: complex - contains: - automaticRestart: - description: - - Specifies whether the instance should be automatically restarted if it is terminated - by Compute Engine (not terminated by a user). - - You can only set the automatic restart option for standard instances. Preemptible - instances cannot be automatically restarted. - returned: success - type: bool - onHostMaintenance: - description: - - Defines the maintenance behavior for this instance. For standard instances, the - default behavior is MIGRATE. For preemptible instances, the default and only possible - behavior is TERMINATE. - - For more information, see Setting Instance Scheduling Options. - returned: success - type: str - preemptible: - description: - - Defines whether the instance is preemptible. This can only be set during instance - creation, it cannot be set or changed after the instance has been created. - returned: success - type: bool - serviceAccounts: - description: - - A list of service accounts, with their specified scopes, authorized for this instance. - Only one service account per VM instance is supported. - returned: success - type: complex - contains: - email: - description: - - Email address of the service account. - returned: success - type: str - scopes: - description: - - The list of scopes to be made available for this service account. - returned: success - type: list - tags: - description: - - A list of tags to apply to this instance. Tags are used to identify valid sources - or targets for network firewalls and are specified by the client during instance - creation. The tags can be later modified by the setTags method. Each tag within - the list must comply with RFC1035. - returned: success - type: complex - contains: - fingerprint: - description: - - Specifies a fingerprint for this request, which is essentially a hash of the metadata's - contents and used for optimistic locking. - - The fingerprint is initially generated by Compute Engine and changes after every - request to modify or update metadata. You must always provide an up-to-date fingerprint - hash in order to update or change metadata. - returned: success - type: str - items: - description: - - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035. - returned: success - type: list + description: + - An optional text description for the instances that are created from this + instance template. + returned: success + type: str + disks: + description: + - An array of disks that are associated with the instances that are created + from this template. + returned: success + type: complex + contains: + autoDelete: + description: + - Specifies whether the disk will be auto-deleted when the instance + is deleted (but not when the disk is detached from the instance). + - 'Tip: Disks should be set to autoDelete=true so that leftover disks + are not left behind on machine deletion.' + returned: success + type: bool + boot: + description: + - Indicates that this is a boot disk. The virtual machine will use the + first partition of the disk for its root filesystem. + returned: success + type: bool + deviceName: + description: + - Specifies a unique device name of your choice that is reflected into + the /dev/disk/by-id/google-* tree of a Linux operating system running + within the instance. This name can be used to reference the device + for mounting, resizing, and so on, from within the instance. + returned: success + type: str + diskEncryptionKey: + description: + - Encrypts or decrypts a disk using a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded + in RFC 4648 base64 to either encrypt or decrypt this resource. + returned: success + type: str + rsaEncryptedKey: + description: + - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied + encryption key to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + returned: success + type: str + index: + description: + - Assigns a zero-based index to this disk, where 0 is reserved for the + boot disk. For example, if you have many disks attached to an instance, + each disk would have a unique index number. If not specified, the + server will choose an appropriate value. + returned: success + type: int + initializeParams: + description: + - Specifies the parameters for a new disk that will be created alongside + the new instance. Use initialization parameters to create boot disks + or local SSDs attached to the new instance. + returned: success + type: complex + contains: + diskName: + description: + - Specifies the disk name. If not specified, the default is to use + the name of the instance. + returned: success + type: str + diskSizeGb: + description: + - Specifies the size of the disk in base-2 GB. + returned: success + type: int + diskType: + description: + - Reference to a gcompute_disk_type resource. + - Specifies the disk type to use to create the instance. + - If not specified, the default is pd-standard. + returned: success + type: str + sourceImage: + description: + - The source image to create this disk. When creating a new instance, + one of initializeParams.sourceImage or disks.source is required. + To create a disk with one of the public operating system images, + specify the image by its family name. + returned: success + type: str + sourceImageEncryptionKey: + description: + - The customer-supplied encryption key of the source image. Required + if the source image is protected by a customer-supplied encryption + key. + - Instance templates do not store customer-supplied encryption keys, + so you cannot create disks for instances in a managed instance + group if the source images are encrypted with your own keys. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded + in RFC 4648 base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied + encryption key that protects this resource. + returned: success + type: str + interface: + description: + - Specifies the disk interface to use for attaching this disk, which + is either SCSI or NVME. The default is SCSI. + - Persistent disks must always use SCSI and the request will fail if + you attempt to attach a persistent disk in any other format than SCSI. + returned: success + type: str + mode: + description: + - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. + If not specified, the default is to attach the disk in READ_WRITE + mode. + returned: success + type: str + source: + description: + - Reference to a gcompute_disk resource. When creating a new instance, + one of initializeParams.sourceImage or disks.source is required. + - If desired, you can also attach existing non-root persistent disks + using this property. This field is only applicable for persistent + disks. + - Note that for InstanceTemplate, specify the disk name, not the URL + for the disk. + returned: success + type: dict + type: + description: + - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not + specified, the default is PERSISTENT. + returned: success + type: str + machineType: + description: + - Reference to a gcompute_machine_type resource. + returned: success + type: str + minCpuPlatform: + description: + - Specifies a minimum CPU platform for the VM instance. Applicable values + are the friendly names of CPU platforms . + returned: success + type: str + metadata: + description: + - The metadata key/value pairs to assign to instances that are created from + this template. These pairs can consist of custom metadata or predefined + keys. + returned: success + type: dict + guestAccelerators: + description: + - List of the type and count of accelerator cards attached to the instance + . + returned: success + type: complex + contains: + acceleratorCount: + description: + - The number of the guest accelerator cards exposed to this instance. + returned: success + type: int + acceleratorType: + description: + - Full or partial URL of the accelerator type resource to expose to + this instance. + returned: success + type: str + networkInterfaces: + description: + - An array of configurations for this interface. This specifies how this + interface is configured to interact with other network services, such + as connecting to the internet. Only one network interface is supported + per instance. + returned: success + type: complex + contains: + accessConfigs: + description: + - An array of configurations for this interface. Currently, only one + access config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs + specified, then this instance will have no external internet access. + returned: success + type: complex + contains: + name: + description: + - The name of this access configuration. The default and recommended + name is External NAT but you can use any arbitrary string you + would like. For example, My external IP or Network Access. + returned: success + type: str + natIP: + description: + - Specifies the title of a gcompute_address. + - An external IP address associated with this instance. + - Specify an unused static external IP address available to the + project or leave this field undefined to use an IP from a shared + ephemeral IP address pool. If you specify a static external IP + address, it must live in the same region as the zone of the instance. + returned: success + type: dict + type: + description: + - The type of configuration. The default and only option is ONE_TO_ONE_NAT. + returned: success + type: str + aliasIpRanges: + description: + - An array of alias IP ranges for this network interface. Can only be + specified for network interfaces on subnet-mode networks. + returned: success + type: complex + contains: + ipCidrRange: + description: + - The IP CIDR range represented by this alias IP range. + - This IP CIDR range must belong to the specified subnetwork and + cannot contain IP addresses reserved by system or used by other + network interfaces. This range may be a single IP address (e.g. + 10.2.3.4), a netmask (e.g. /24) or a CIDR format string (e.g. + 10.1.2.0/24). + returned: success + type: str + subnetworkRangeName: + description: + - Optional subnetwork secondary range name specifying the secondary + range from which to allocate the IP CIDR range for this alias + IP range. If left unspecified, the primary range of the subnetwork + will be used. + returned: success + type: str + name: + description: + - The name of the network interface, generated by the server. For network + devices, these are eth0, eth1, etc . + returned: success + type: str + network: + description: + - Specifies the title of an existing gcompute_network. When creating + an instance, if neither the network nor the subnetwork is specified, + the default network global/networks/default is used; if the network + is not specified but the subnetwork is specified, the network is inferred. + returned: success + type: dict + networkIP: + description: + - An IPv4 internal network address to assign to the instance for this + network interface. If not specified by the user, an unused internal + IP is assigned by the system. + returned: success + type: str + subnetwork: + description: + - Reference to a gcompute_subnetwork resource. + - If the network resource is in legacy mode, do not provide this property. + If the network is in auto subnet mode, providing the subnetwork is + optional. If the network is in custom subnet mode, then this field + should be specified. + returned: success + type: dict + scheduling: + description: + - Sets the scheduling options for this instance. + returned: success + type: complex + contains: + automaticRestart: + description: + - Specifies whether the instance should be automatically restarted if + it is terminated by Compute Engine (not terminated by a user). + - You can only set the automatic restart option for standard instances. + Preemptible instances cannot be automatically restarted. + returned: success + type: bool + onHostMaintenance: + description: + - Defines the maintenance behavior for this instance. For standard instances, + the default behavior is MIGRATE. For preemptible instances, the default + and only possible behavior is TERMINATE. + - For more information, see Setting Instance Scheduling Options. + returned: success + type: str + preemptible: + description: + - Defines whether the instance is preemptible. This can only be set + during instance creation, it cannot be set or changed after the instance + has been created. + returned: success + type: bool + serviceAccounts: + description: + - A list of service accounts, with their specified scopes, authorized for + this instance. Only one service account per VM instance is supported. + returned: success + type: complex + contains: + email: + description: + - Email address of the service account. + returned: success + type: str + scopes: + description: + - The list of scopes to be made available for this service account. + returned: success + type: list + tags: + description: + - A list of tags to apply to this instance. Tags are used to identify valid + sources or targets for network firewalls and are specified by the client + during instance creation. The tags can be later modified by the setTags + method. Each tag within the list must comply with RFC1035. + returned: success + type: complex + contains: + fingerprint: + description: + - Specifies a fingerprint for this request, which is essentially a hash + of the metadata's contents and used for optimistic locking. + - The fingerprint is initially generated by Compute Engine and changes + after every request to modify or update metadata. You must always + provide an up-to-date fingerprint hash in order to update or change + metadata. + returned: success + type: str + items: + description: + - An array of tags. Each tag must be 1-63 characters long, and comply + with RFC1035. + returned: success + type: list ''' ################################################################################ @@ -455,7 +479,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_network.py b/lib/ansible/modules/cloud/google/gcp_compute_network.py index 4eccbc5fc1..ba5407e43a 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_network.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_network.py @@ -32,78 +32,83 @@ DOCUMENTATION = ''' --- module: gcp_compute_network description: - - Represents a Network resource. - - Your Cloud Platform Console project can contain multiple networks, and each network - can have multiple instances attached to it. A network allows you to define a gateway - IP and the network range for the instances attached to that network. Every project - is provided with a default network with preset configurations and firewall rules. - You can choose to customize the default network by adding or removing rules, or - you can create new networks in that project. Generally, most users only need one - network, although you can have up to five networks per project by default. - - A network belongs to only one project, and each instance can only belong to one - network. All Compute Engine networks use the IPv4 protocol. Compute Engine currently - does not support IPv6. However, Google is a major advocate of IPv6 and it is an - important future direction. +- Represents a Network resource. +- Your Cloud Platform Console project can contain multiple networks, and each network + can have multiple instances attached to it. A network allows you to define a gateway + IP and the network range for the instances attached to that network. Every project + is provided with a default network with preset configurations and firewall rules. + You can choose to customize the default network by adding or removing rules, or + you can create new networks in that project. Generally, most users only need one + network, although you can have up to five networks per project by default. +- A network belongs to only one project, and each instance can only belong to one + network. All Compute Engine networks use the IPv4 protocol. Compute Engine currently + does not support IPv6. However, Google is a major advocate of IPv6 and it is an + important future direction. short_description: Creates a GCP Network version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + ipv4_range: + description: + - 'The range of internal addresses that are legal on this network. This range + is a CIDR specification, for example: 192.168.0.0/16. Provided by the client + when the network is created.' + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + auto_create_subnetworks: + description: + - When set to true, the network is created in "auto subnet mode". When set to + false, the network is in "custom subnet mode". + - In "auto subnet mode", a newly created network is assigned the default CIDR + of 10.128.0.0/9 and it automatically creates one subnetwork per region. + required: false + type: bool + routing_config: + description: + - The network-level routing configuration for this network. Used by Cloud Router + to determine what type of network-wide routing behavior to enforce. + required: false + version_added: 2.8 + suboptions: + routing_mode: description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - ipv4_range: - description: - - 'The range of internal addresses that are legal on this network. This range is a - CIDR specification, for example: 192.168.0.0/16. Provided by the client when the - network is created.' - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. + - The network-wide routing mode to use. If set to REGIONAL, this network's + cloud routers will only advertise routes with subnetworks of this network + in the same region as the router. If set to GLOBAL, this network's cloud + routers will advertise routes with all subnetworks of this network, across + regions. required: true - auto_create_subnetworks: - description: - - When set to true, the network is created in "auto subnet mode". When set to false, - the network is in "custom subnet mode". - - In "auto subnet mode", a newly created network is assigned the default CIDR of 10.128.0.0/9 - and it automatically creates one subnetwork per region. - required: false - type: bool - routing_config: - description: - - The network-level routing configuration for this network. Used by Cloud Router to - determine what type of network-wide routing behavior to enforce. - required: false - version_added: 2.8 - suboptions: - routing_mode: - description: - - The network-wide routing mode to use. If set to REGIONAL, this network's cloud routers - will only advertise routes with subnetworks of this network in the same region as - the router. If set to GLOBAL, this network's cloud routers will advertise routes - with all subnetworks of this network, across regions. - required: true - choices: ['REGIONAL', 'GLOBAL'] + choices: + - REGIONAL + - GLOBAL extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/networks)" - - "Official Documentation: U(https://cloud.google.com/vpc/docs/vpc)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/networks)' +- 'Official Documentation: U(https://cloud.google.com/vpc/docs/vpc)' ''' EXAMPLES = ''' @@ -118,74 +123,74 @@ EXAMPLES = ''' ''' RETURN = ''' - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - gateway_ipv4: - description: - - A gateway address for default routing to other networks. This value is read only - and is selected by the Google Compute Engine, typically as the first usable address - in the IPv4Range. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - ipv4_range: - description: - - 'The range of internal addresses that are legal on this network. This range is a - CIDR specification, for example: 192.168.0.0/16. Provided by the client when the - network is created.' - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - subnetworks: - description: - - Server-defined fully-qualified URLs for all subnetworks in this network. - returned: success - type: list - autoCreateSubnetworks: - description: - - When set to true, the network is created in "auto subnet mode". When set to false, - the network is in "custom subnet mode". - - In "auto subnet mode", a newly created network is assigned the default CIDR of 10.128.0.0/9 - and it automatically creates one subnetwork per region. - returned: success - type: bool - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - routingConfig: - description: - - The network-level routing configuration for this network. Used by Cloud Router to - determine what type of network-wide routing behavior to enforce. - returned: success - type: complex - contains: - routingMode: - description: - - The network-wide routing mode to use. If set to REGIONAL, this network's cloud routers - will only advertise routes with subnetworks of this network in the same region as - the router. If set to GLOBAL, this network's cloud routers will advertise routes - with all subnetworks of this network, across regions. - returned: success - type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +gateway_ipv4: + description: + - A gateway address for default routing to other networks. This value is read only + and is selected by the Google Compute Engine, typically as the first usable address + in the IPv4Range. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +ipv4_range: + description: + - 'The range of internal addresses that are legal on this network. This range is + a CIDR specification, for example: 192.168.0.0/16. Provided by the client when + the network is created.' + returned: success + type: str +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +subnetworks: + description: + - Server-defined fully-qualified URLs for all subnetworks in this network. + returned: success + type: list +autoCreateSubnetworks: + description: + - When set to true, the network is created in "auto subnet mode". When set to false, + the network is in "custom subnet mode". + - In "auto subnet mode", a newly created network is assigned the default CIDR of + 10.128.0.0/9 and it automatically creates one subnetwork per region. + returned: success + type: bool +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +routingConfig: + description: + - The network-level routing configuration for this network. Used by Cloud Router + to determine what type of network-wide routing behavior to enforce. + returned: success + type: complex + contains: + routingMode: + description: + - The network-wide routing mode to use. If set to REGIONAL, this network's cloud + routers will only advertise routes with subnetworks of this network in the + same region as the router. If set to GLOBAL, this network's cloud routers + will advertise routes with all subnetworks of this network, across regions. + returned: success + type: str ''' ################################################################################ @@ -273,7 +278,7 @@ def routing_config_update(module, request, response): "projects/{project}/regions/{region}/subnetworks/{name}" ]).format(**module.params), { - u'routingConfig': NetworkRoutingConfigArray(module.params.get('routing_config', []), module).to_request() + u'routingConfig': NetworkRoutingconfigArray(module.params.get('routing_config', []), module).to_request() } ) @@ -290,7 +295,7 @@ def resource_to_request(module): u'IPv4Range': module.params.get('ipv4_range'), u'name': module.params.get('name'), u'autoCreateSubnetworks': module.params.get('auto_create_subnetworks'), - u'routingConfig': NetworkRoutingConfigArray(module.params.get('routing_config', []), module).to_request() + u'routingConfig': NetworkRoutingconfigArray(module.params.get('routing_config', []), module).to_request() } return_vals = {} for k, v in request.items(): @@ -364,7 +369,7 @@ def response_to_hash(module, response): u'subnetworks': response.get(u'subnetworks'), u'autoCreateSubnetworks': module.params.get('auto_create_subnetworks'), u'creationTimestamp': response.get(u'creationTimestamp'), - u'routingConfig': NetworkRoutingConfigArray(response.get(u'routingConfig', []), module).from_response() + u'routingConfig': NetworkRoutingconfigArray(response.get(u'routingConfig', []), module).from_response() } @@ -392,8 +397,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -405,7 +408,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class NetworkRoutingConfigArray(object): +class NetworkRoutingconfigArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_network_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_network_facts.py index f7c87a316c..d54dad6c80 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_network_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_network_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_network_facts description: - - Gather facts for GCP Network +- Gather facts for GCP Network short_description: Gather facts for GCP Network version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,78 +61,79 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - gateway_ipv4: - description: - - A gateway address for default routing to other networks. This value is read only - and is selected by the Google Compute Engine, typically as the first usable address - in the IPv4Range. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - ipv4_range: - description: - - 'The range of internal addresses that are legal on this network. This range is a - CIDR specification, for example: 192.168.0.0/16. Provided by the client when the - network is created.' - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - subnetworks: - description: - - Server-defined fully-qualified URLs for all subnetworks in this network. - returned: success - type: list - autoCreateSubnetworks: - description: - - When set to true, the network is created in "auto subnet mode". When set to false, - the network is in "custom subnet mode". - - In "auto subnet mode", a newly created network is assigned the default CIDR of 10.128.0.0/9 - and it automatically creates one subnetwork per region. - returned: success - type: bool - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - routingConfig: - description: - - The network-level routing configuration for this network. Used by Cloud Router to - determine what type of network-wide routing behavior to enforce. - returned: success - type: complex - contains: - routingMode: - description: - - The network-wide routing mode to use. If set to REGIONAL, this network's cloud routers - will only advertise routes with subnetworks of this network in the same region as - the router. If set to GLOBAL, this network's cloud routers will advertise routes - with all subnetworks of this network, across regions. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + gateway_ipv4: + description: + - A gateway address for default routing to other networks. This value is read + only and is selected by the Google Compute Engine, typically as the first + usable address in the IPv4Range. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + ipv4_range: + description: + - 'The range of internal addresses that are legal on this network. This range + is a CIDR specification, for example: 192.168.0.0/16. Provided by the client + when the network is created.' + returned: success + type: str + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + subnetworks: + description: + - Server-defined fully-qualified URLs for all subnetworks in this network. + returned: success + type: list + autoCreateSubnetworks: + description: + - When set to true, the network is created in "auto subnet mode". When set to + false, the network is in "custom subnet mode". + - In "auto subnet mode", a newly created network is assigned the default CIDR + of 10.128.0.0/9 and it automatically creates one subnetwork per region. + returned: success + type: bool + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + routingConfig: + description: + - The network-level routing configuration for this network. Used by Cloud Router + to determine what type of network-wide routing behavior to enforce. + returned: success + type: complex + contains: + routingMode: + description: + - The network-wide routing mode to use. If set to REGIONAL, this network's + cloud routers will only advertise routes with subnetworks of this network + in the same region as the router. If set to GLOBAL, this network's cloud + routers will advertise routes with all subnetworks of this network, across + regions. + returned: success + type: str ''' ################################################################################ @@ -154,7 +154,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py b/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py index 819da0ab38..d13b3f7391 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py @@ -32,127 +32,128 @@ DOCUMENTATION = ''' --- module: gcp_compute_region_disk description: - - Persistent disks are durable storage devices that function similarly to the physical - disks in a desktop or a server. Compute Engine manages the hardware behind these - devices to ensure data redundancy and optimize performance for you. Persistent disks - are available as either standard hard disk drives (HDD) or solid-state drives (SSD). - - Persistent disks are located independently from your virtual machine instances, - so you can detach or move persistent disks to keep your data even after you delete - your instances. Persistent disk performance scales automatically with size, so you - can resize your existing persistent disks or add more persistent disks to an instance - to meet your performance and storage space requirements. - - Add a persistent disk to your instance when you need reliable and affordable storage - with consistent performance characteristics. +- Persistent disks are durable storage devices that function similarly to the physical + disks in a desktop or a server. Compute Engine manages the hardware behind these + devices to ensure data redundancy and optimize performance for you. Persistent disks + are available as either standard hard disk drives (HDD) or solid-state drives (SSD). +- Persistent disks are located independently from your virtual machine instances, + so you can detach or move persistent disks to keep your data even after you delete + your instances. Persistent disk performance scales automatically with size, so you + can resize your existing persistent disks or add more persistent disks to an instance + to meet your performance and storage space requirements. +- Add a persistent disk to your instance when you need reliable and affordable storage + with consistent performance characteristics. short_description: Creates a GCP RegionDisk version_added: 2.8 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + labels: + description: + - Labels to apply to this disk. A list of key->value pairs. + required: false + licenses: + description: + - Any applicable publicly visible licenses. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + size_gb: + description: + - Size of the persistent disk, specified in GB. You can specify this field when + creating a persistent disk using the sourceImage or sourceSnapshot parameter, + or specify it alone to create an empty persistent disk. + - If you specify this field along with sourceImage or sourceSnapshot, the value + of sizeGb must not be less than the size of the sourceImage or the size of the + snapshot. + required: false + replica_zones: + description: + - URLs of the zones where the disk should be replicated to. + required: true + type: + description: + - URL of the disk type resource describing which disk type to use to create the + disk. Provide this when creating the disk. + required: false + region: + description: + - A reference to the region where the disk resides. + required: true + disk_encryption_key: + description: + - Encrypts the disk using a customer-supplied encryption key. + - After you encrypt a disk with a customer-supplied key, you must provide the + same key if you use the disk later (e.g. to create a disk snapshot or an image, + or to attach the disk to a virtual machine). + - Customer-supplied encryption keys do not protect access to metadata of the disk. + - If you do not provide an encryption key when creating the disk, then the disk + will be encrypted using an automatically generated key and you do not need to + provide a key to use the disk later. + required: false + suboptions: + raw_key: description: - - An optional description of this resource. Provide this property when you create - the resource. + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. required: false - labels: + sha256: description: - - Labels to apply to this disk. A list of key->value pairs. + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. required: false - licenses: + source_snapshot: + description: + - The source snapshot used to create this disk. You can provide this as a partial + or full URL to the resource. + - 'This field represents a link to a Snapshot resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_snapshot + task and then set this source_snapshot field to "{{ name-of-resource }}" Alternatively, + you can set this source_snapshot to a dictionary with the selfLink key where + the value is the selfLink of your Snapshot' + required: false + source_snapshot_encryption_key: + description: + - The customer-supplied encryption key of the source snapshot. Required if the + source snapshot is protected by a customer-supplied encryption key. + required: false + suboptions: + raw_key: description: - - Any applicable publicly visible licenses. + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. required: false - name: + sha256: description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - size_gb: - description: - - Size of the persistent disk, specified in GB. You can specify this field when creating - a persistent disk using the sourceImage or sourceSnapshot parameter, or specify - it alone to create an empty persistent disk. - - If you specify this field along with sourceImage or sourceSnapshot, the value of - sizeGb must not be less than the size of the sourceImage or the size of the snapshot. + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. required: false - replica_zones: - description: - - URLs of the zones where the disk should be replicated to. - required: true - type: - description: - - URL of the disk type resource describing which disk type to use to create the disk. - Provide this when creating the disk. - required: false - region: - description: - - A reference to the region where the disk resides. - required: true - disk_encryption_key: - description: - - Encrypts the disk using a customer-supplied encryption key. - - After you encrypt a disk with a customer-supplied key, you must provide the same - key if you use the disk later (e.g. to create a disk snapshot or an image, or to - attach the disk to a virtual machine). - - Customer-supplied encryption keys do not protect access to metadata of the disk. - - If you do not provide an encryption key when creating the disk, then the disk will - be encrypted using an automatically generated key and you do not need to provide - a key to use the disk later. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false - source_snapshot: - description: - - 'The source snapshot used to create this disk. You can provide this as a partial or - full URL to the resource. For example, the following are valid values: * - `U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`) - * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .' - - 'This field represents a link to a Snapshot resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_snapshot - task and then set this source_snapshot field to "{{ name-of-resource }}" Alternatively, - you can set this source_snapshot to a dictionary with the selfLink key where the - value is the selfLink of your Snapshot.' - required: false - source_snapshot_encryption_key: - description: - - The customer-supplied encryption key of the source snapshot. Required if the source - snapshot is protected by a customer-supplied encryption key. - required: false - suboptions: - raw_key: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - required: false - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - required: false extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)" - - "Adding or Resizing Regional Persistent Disks: U(https://cloud.google.com/compute/docs/disks/regional-persistent-disk)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)' +- 'Adding or Resizing Regional Persistent Disks: U(https://cloud.google.com/compute/docs/disks/regional-persistent-disk)' ''' EXAMPLES = ''' @@ -173,150 +174,149 @@ EXAMPLES = ''' ''' RETURN = ''' - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - lastAttachTimestamp: - description: - - Last attach timestamp in RFC3339 text format. - returned: success - type: str - lastDetachTimestamp: - description: - - Last dettach timestamp in RFC3339 text format. - returned: success - type: str - labels: - description: - - Labels to apply to this disk. A list of key->value pairs. - returned: success - type: dict - licenses: - description: - - Any applicable publicly visible licenses. - returned: success - type: list - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - sizeGb: - description: - - Size of the persistent disk, specified in GB. You can specify this field when creating - a persistent disk using the sourceImage or sourceSnapshot parameter, or specify - it alone to create an empty persistent disk. - - If you specify this field along with sourceImage or sourceSnapshot, the value of - sizeGb must not be less than the size of the sourceImage or the size of the snapshot. - returned: success - type: int - users: - description: - - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance - .' - returned: success - type: list - replicaZones: - description: - - URLs of the zones where the disk should be replicated to. - returned: success - type: list - type: - description: - - URL of the disk type resource describing which disk type to use to create the disk. - Provide this when creating the disk. - returned: success - type: str - region: - description: - - A reference to the region where the disk resides. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts the disk using a customer-supplied encryption key. - - After you encrypt a disk with a customer-supplied key, you must provide the same - key if you use the disk later (e.g. to create a disk snapshot or an image, or to - attach the disk to a virtual machine). - - Customer-supplied encryption keys do not protect access to metadata of the disk. - - If you do not provide an encryption key when creating the disk, then the disk will - be encrypted using an automatically generated key and you do not need to provide - a key to use the disk later. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshot: - description: - - 'The source snapshot used to create this disk. You can provide this as a partial or - full URL to the resource. For example, the following are valid values: * - `U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`) - * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .' - returned: success - type: dict - sourceSnapshotEncryptionKey: - description: - - The customer-supplied encryption key of the source snapshot. Required if the source - snapshot is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshotId: - description: - - The unique ID of the snapshot used to create this disk. This value identifies the - exact snapshot that was used to create this persistent disk. For example, if you - created the persistent disk from a snapshot that was later deleted and recreated - under the same name, the source snapshot ID would identify the exact version of - the snapshot that was used. - returned: success - type: str +labelFingerprint: + description: + - The fingerprint used for optimistic locking of this resource. Used internally + during updates. + returned: success + type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +lastAttachTimestamp: + description: + - Last attach timestamp in RFC3339 text format. + returned: success + type: str +lastDetachTimestamp: + description: + - Last dettach timestamp in RFC3339 text format. + returned: success + type: str +labels: + description: + - Labels to apply to this disk. A list of key->value pairs. + returned: success + type: dict +licenses: + description: + - Any applicable publicly visible licenses. + returned: success + type: list +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +sizeGb: + description: + - Size of the persistent disk, specified in GB. You can specify this field when + creating a persistent disk using the sourceImage or sourceSnapshot parameter, + or specify it alone to create an empty persistent disk. + - If you specify this field along with sourceImage or sourceSnapshot, the value + of sizeGb must not be less than the size of the sourceImage or the size of the + snapshot. + returned: success + type: int +users: + description: + - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance + .' + returned: success + type: list +replicaZones: + description: + - URLs of the zones where the disk should be replicated to. + returned: success + type: list +type: + description: + - URL of the disk type resource describing which disk type to use to create the + disk. Provide this when creating the disk. + returned: success + type: str +region: + description: + - A reference to the region where the disk resides. + returned: success + type: str +diskEncryptionKey: + description: + - Encrypts the disk using a customer-supplied encryption key. + - After you encrypt a disk with a customer-supplied key, you must provide the same + key if you use the disk later (e.g. to create a disk snapshot or an image, or + to attach the disk to a virtual machine). + - Customer-supplied encryption keys do not protect access to metadata of the disk. + - If you do not provide an encryption key when creating the disk, then the disk + will be encrypted using an automatically generated key and you do not need to + provide a key to use the disk later. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str +sourceSnapshot: + description: + - The source snapshot used to create this disk. You can provide this as a partial + or full URL to the resource. + returned: success + type: dict +sourceSnapshotEncryptionKey: + description: + - The customer-supplied encryption key of the source snapshot. Required if the source + snapshot is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str +sourceSnapshotId: + description: + - The unique ID of the snapshot used to create this disk. This value identifies + the exact snapshot that was used to create this persistent disk. For example, + if you created the persistent disk from a snapshot that was later deleted and + recreated under the same name, the source snapshot ID would identify the exact + version of the snapshot that was used. + returned: success + type: str ''' ################################################################################ @@ -443,8 +443,8 @@ def delete(module, link, kind): def resource_to_request(module): request = { u'kind': 'compute#disk', - u'diskEncryptionKey': RegionDiskDiskEncryptionKey(module.params.get('disk_encryption_key', {}), module).to_request(), - u'sourceSnapshotEncryptionKey': RegionDiskSourceSnapshotEncryptionKey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(), + u'diskEncryptionKey': RegionDiskDiskencryptionkey(module.params.get('disk_encryption_key', {}), module).to_request(), + u'sourceSnapshotEncryptionKey': RegionDiskSourcesnapshotencryptionkey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(), u'description': module.params.get('description'), u'labels': module.params.get('labels'), u'licenses': module.params.get('licenses'), @@ -575,8 +575,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -588,7 +586,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class RegionDiskDiskEncryptionKey(object): +class RegionDiskDiskencryptionkey(object): def __init__(self, request, module): self.module = module if request: @@ -609,7 +607,7 @@ class RegionDiskDiskEncryptionKey(object): }) -class RegionDiskSourceSnapshotEncryptionKey(object): +class RegionDiskSourcesnapshotencryptionkey(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_region_disk_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_region_disk_facts.py index 99810136f6..6d13a1eb7a 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_region_disk_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_region_disk_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_region_disk_facts description: - - Gather facts for GCP RegionDisk +- Gather facts for GCP RegionDisk short_description: Gather facts for GCP RegionDisk version_added: 2.8 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - A reference to the region where the disk resides. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - A reference to the region where the disk resides. + required: true extends_documentation_fragment: gcp ''' @@ -67,154 +66,154 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - lastAttachTimestamp: - description: - - Last attach timestamp in RFC3339 text format. - returned: success - type: str - lastDetachTimestamp: - description: - - Last dettach timestamp in RFC3339 text format. - returned: success - type: str - labels: - description: - - Labels to apply to this disk. A list of key->value pairs. - returned: success - type: dict - licenses: - description: - - Any applicable publicly visible licenses. - returned: success - type: list - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - sizeGb: - description: - - Size of the persistent disk, specified in GB. You can specify this field when creating - a persistent disk using the sourceImage or sourceSnapshot parameter, or specify - it alone to create an empty persistent disk. - - If you specify this field along with sourceImage or sourceSnapshot, the value of - sizeGb must not be less than the size of the sourceImage or the size of the snapshot. - returned: success - type: int - users: - description: - - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance - .' - returned: success - type: list - replicaZones: - description: - - URLs of the zones where the disk should be replicated to. - returned: success - type: list - type: - description: - - URL of the disk type resource describing which disk type to use to create the disk. - Provide this when creating the disk. - returned: success - type: str - region: - description: - - A reference to the region where the disk resides. - returned: success - type: str - diskEncryptionKey: - description: - - Encrypts the disk using a customer-supplied encryption key. - - After you encrypt a disk with a customer-supplied key, you must provide the same - key if you use the disk later (e.g. to create a disk snapshot or an image, or to - attach the disk to a virtual machine). - - Customer-supplied encryption keys do not protect access to metadata of the disk. - - If you do not provide an encryption key when creating the disk, then the disk will - be encrypted using an automatically generated key and you do not need to provide - a key to use the disk later. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshot: - description: - - 'The source snapshot used to create this disk. You can provide this as a partial - or full URL to the resource. For example, the following are valid values: * - `U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`) - * `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .' - returned: success - type: dict - sourceSnapshotEncryptionKey: - description: - - The customer-supplied encryption key of the source snapshot. Required if the source - snapshot is protected by a customer-supplied encryption key. - returned: success - type: complex - contains: - rawKey: - description: - - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 - to either encrypt or decrypt this resource. - returned: success - type: str - sha256: - description: - - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key - that protects this resource. - returned: success - type: str - sourceSnapshotId: - description: - - The unique ID of the snapshot used to create this disk. This value identifies the - exact snapshot that was used to create this persistent disk. For example, if you - created the persistent disk from a snapshot that was later deleted and recreated - under the same name, the source snapshot ID would identify the exact version of - the snapshot that was used. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + labelFingerprint: + description: + - The fingerprint used for optimistic locking of this resource. Used internally + during updates. + returned: success + type: str + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + lastAttachTimestamp: + description: + - Last attach timestamp in RFC3339 text format. + returned: success + type: str + lastDetachTimestamp: + description: + - Last dettach timestamp in RFC3339 text format. + returned: success + type: str + labels: + description: + - Labels to apply to this disk. A list of key->value pairs. + returned: success + type: dict + licenses: + description: + - Any applicable publicly visible licenses. + returned: success + type: list + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + sizeGb: + description: + - Size of the persistent disk, specified in GB. You can specify this field when + creating a persistent disk using the sourceImage or sourceSnapshot parameter, + or specify it alone to create an empty persistent disk. + - If you specify this field along with sourceImage or sourceSnapshot, the value + of sizeGb must not be less than the size of the sourceImage or the size of + the snapshot. + returned: success + type: int + users: + description: + - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance + .' + returned: success + type: list + replicaZones: + description: + - URLs of the zones where the disk should be replicated to. + returned: success + type: list + type: + description: + - URL of the disk type resource describing which disk type to use to create + the disk. Provide this when creating the disk. + returned: success + type: str + region: + description: + - A reference to the region where the disk resides. + returned: success + type: str + diskEncryptionKey: + description: + - Encrypts the disk using a customer-supplied encryption key. + - After you encrypt a disk with a customer-supplied key, you must provide the + same key if you use the disk later (e.g. to create a disk snapshot or an image, + or to attach the disk to a virtual machine). + - Customer-supplied encryption keys do not protect access to metadata of the + disk. + - If you do not provide an encryption key when creating the disk, then the disk + will be encrypted using an automatically generated key and you do not need + to provide a key to use the disk later. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + sourceSnapshot: + description: + - The source snapshot used to create this disk. You can provide this as a partial + or full URL to the resource. + returned: success + type: dict + sourceSnapshotEncryptionKey: + description: + - The customer-supplied encryption key of the source snapshot. Required if the + source snapshot is protected by a customer-supplied encryption key. + returned: success + type: complex + contains: + rawKey: + description: + - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 + base64 to either encrypt or decrypt this resource. + returned: success + type: str + sha256: + description: + - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption + key that protects this resource. + returned: success + type: str + sourceSnapshotId: + description: + - The unique ID of the snapshot used to create this disk. This value identifies + the exact snapshot that was used to create this persistent disk. For example, + if you created the persistent disk from a snapshot that was later deleted + and recreated under the same name, the source snapshot ID would identify the + exact version of the snapshot that was used. + returned: success + type: str ''' ################################################################################ @@ -236,7 +235,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_route.py b/lib/ansible/modules/cloud/google/gcp_compute_route.py index bbda85c765..546b0dfd35 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_route.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_route.py @@ -32,103 +32,105 @@ DOCUMENTATION = ''' --- module: gcp_compute_route description: - - Represents a Route resource. - - A route is a rule that specifies how certain packets should be handled by the virtual - network. Routes are associated with virtual machines by tag, and the set of routes - for a particular virtual machine is called its routing table. For each packet leaving - a virtual machine, the system searches that virtual machine's routing table for - a single best matching route. - - Routes match packets by destination IP address, preferring smaller or more specific - ranges over larger ones. If there is a tie, the system selects the route with the - smallest priority value. If there is still a tie, it uses the layer three and four - packet headers to select just one of the remaining matching routes. The packet is - then forwarded as specified by the next_hop field of the winning route -- either - to another virtual machine destination, a virtual machine gateway or a Compute Engine-operated - gateway. Packets that do not match any route in the sending virtual machine's routing - table will be dropped. - - A Route resource must have exactly one specification of either nextHopGateway, nextHopInstance, - nextHopIp, or nextHopVpnTunnel. +- Represents a Route resource. +- A route is a rule that specifies how certain packets should be handled by the virtual + network. Routes are associated with virtual machines by tag, and the set of routes + for a particular virtual machine is called its routing table. For each packet leaving + a virtual machine, the system searches that virtual machine's routing table for + a single best matching route. +- Routes match packets by destination IP address, preferring smaller or more specific + ranges over larger ones. If there is a tie, the system selects the route with the + smallest priority value. If there is still a tie, it uses the layer three and four + packet headers to select just one of the remaining matching routes. The packet is + then forwarded as specified by the next_hop field of the winning route -- either + to another virtual machine destination, a virtual machine gateway or a Compute Engine-operated + gateway. Packets that do not match any route in the sending virtual machine's routing + table will be dropped. +- A Route resource must have exactly one specification of either nextHopGateway, nextHopInstance, + nextHopIp, or nextHopVpnTunnel. short_description: Creates a GCP Route version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - dest_range: - description: - - The destination range of outgoing packets that this route applies to. - - Only IPv4 is supported. - required: true + state: description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - version_added: 2.7 - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - network: - description: - - The network that this route applies to. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: true - priority: - description: - - The priority of this route. Priority is used to break ties in cases where there - is more than one matching route of equal prefix length. - - In the case of two routes with equal prefix length, the one with the lowest-numbered - priority value wins. - - Default value is 1000. Valid range is 0 through 65535. - required: false - tags: - description: - - A list of instance tags to which this route applies. - required: false - next_hop_gateway: - description: - - URL to a gateway that should handle matching packets. - - 'Currently, you can only specify the internet gateway, using a full or partial valid - URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway) - * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway - .' - required: false - next_hop_instance: - description: - - URL to an instance that should handle matching packets. - - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/) - instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance - .' - required: false - next_hop_ip: - description: - - Network IP address of an instance that should handle matching packets. - required: false - next_hop_vpn_tunnel: - description: - - URL to a VpnTunnel that should handle matching packets. - required: false + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + dest_range: + description: + - The destination range of outgoing packets that this route applies to. + - Only IPv4 is supported. + required: true + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + version_added: 2.7 + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + network: + description: + - The network that this route applies to. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: true + priority: + description: + - The priority of this route. Priority is used to break ties in cases where there + is more than one matching route of equal prefix length. + - In the case of two routes with equal prefix length, the one with the lowest-numbered + priority value wins. + - Default value is 1000. Valid range is 0 through 65535. + required: false + tags: + description: + - A list of instance tags to which this route applies. + required: false + next_hop_gateway: + description: + - URL to a gateway that should handle matching packets. + - 'Currently, you can only specify the internet gateway, using a full or partial + valid URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway) + * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway + .' + required: false + next_hop_instance: + description: + - URL to an instance that should handle matching packets. + - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/) + instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance + .' + required: false + next_hop_ip: + description: + - Network IP address of an instance that should handle matching packets. + required: false + next_hop_vpn_tunnel: + description: + - URL to a VpnTunnel that should handle matching packets. + required: false extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/routes)" - - "Using Routes: U(https://cloud.google.com/vpc/docs/using-routes)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/routes)' +- 'Using Routes: U(https://cloud.google.com/vpc/docs/using-routes)' ''' EXAMPLES = ''' @@ -157,79 +159,79 @@ EXAMPLES = ''' ''' RETURN = ''' - destRange: - description: - - The destination range of outgoing packets that this route applies to. - - Only IPv4 is supported. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - The network that this route applies to. - returned: success - type: dict - priority: - description: - - The priority of this route. Priority is used to break ties in cases where there - is more than one matching route of equal prefix length. - - In the case of two routes with equal prefix length, the one with the lowest-numbered - priority value wins. - - Default value is 1000. Valid range is 0 through 65535. - returned: success - type: int - tags: - description: - - A list of instance tags to which this route applies. - returned: success - type: list - nextHopGateway: - description: - - URL to a gateway that should handle matching packets. - - 'Currently, you can only specify the internet gateway, using a full or partial valid - URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway) - * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway - .' - returned: success - type: str - nextHopInstance: - description: - - URL to an instance that should handle matching packets. - - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/) - instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance - .' - returned: success - type: str - nextHopIp: - description: - - Network IP address of an instance that should handle matching packets. - returned: success - type: str - nextHopVpnTunnel: - description: - - URL to a VpnTunnel that should handle matching packets. - returned: success - type: str - nextHopNetwork: - description: - - URL to a Network that should handle matching packets. - returned: success - type: str +destRange: + description: + - The destination range of outgoing packets that this route applies to. + - Only IPv4 is supported. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +network: + description: + - The network that this route applies to. + returned: success + type: dict +priority: + description: + - The priority of this route. Priority is used to break ties in cases where there + is more than one matching route of equal prefix length. + - In the case of two routes with equal prefix length, the one with the lowest-numbered + priority value wins. + - Default value is 1000. Valid range is 0 through 65535. + returned: success + type: int +tags: + description: + - A list of instance tags to which this route applies. + returned: success + type: list +nextHopGateway: + description: + - URL to a gateway that should handle matching packets. + - 'Currently, you can only specify the internet gateway, using a full or partial + valid URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway) + * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway + .' + returned: success + type: str +nextHopInstance: + description: + - URL to an instance that should handle matching packets. + - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/) + instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance + .' + returned: success + type: str +nextHopIp: + description: + - Network IP address of an instance that should handle matching packets. + returned: success + type: str +nextHopVpnTunnel: + description: + - URL to a VpnTunnel that should handle matching packets. + returned: success + type: str +nextHopNetwork: + description: + - URL to a Network that should handle matching packets. + returned: success + type: str ''' ################################################################################ @@ -425,8 +427,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_route_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_route_facts.py index 312d9af00c..2e7f0dd2f4 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_route_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_route_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_route_facts description: - - Gather facts for GCP Route +- Gather facts for GCP Route short_description: Gather facts for GCP Route version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,83 +61,83 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - destRange: - description: - - The destination range of outgoing packets that this route applies to. - - Only IPv4 is supported. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - The network that this route applies to. - returned: success - type: dict - priority: - description: - - The priority of this route. Priority is used to break ties in cases where there - is more than one matching route of equal prefix length. - - In the case of two routes with equal prefix length, the one with the lowest-numbered - priority value wins. - - Default value is 1000. Valid range is 0 through 65535. - returned: success - type: int - tags: - description: - - A list of instance tags to which this route applies. - returned: success - type: list - nextHopGateway: - description: - - URL to a gateway that should handle matching packets. - - 'Currently, you can only specify the internet gateway, using a full or partial valid - URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway) - * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway - .' - returned: success - type: str - nextHopInstance: - description: - - URL to an instance that should handle matching packets. - - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/) - instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance - .' - returned: success - type: str - nextHopIp: - description: - - Network IP address of an instance that should handle matching packets. - returned: success - type: str - nextHopVpnTunnel: - description: - - URL to a VpnTunnel that should handle matching packets. - returned: success - type: str - nextHopNetwork: - description: - - URL to a Network that should handle matching packets. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + destRange: + description: + - The destination range of outgoing packets that this route applies to. + - Only IPv4 is supported. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + network: + description: + - The network that this route applies to. + returned: success + type: dict + priority: + description: + - The priority of this route. Priority is used to break ties in cases where + there is more than one matching route of equal prefix length. + - In the case of two routes with equal prefix length, the one with the lowest-numbered + priority value wins. + - Default value is 1000. Valid range is 0 through 65535. + returned: success + type: int + tags: + description: + - A list of instance tags to which this route applies. + returned: success + type: list + nextHopGateway: + description: + - URL to a gateway that should handle matching packets. + - 'Currently, you can only specify the internet gateway, using a full or partial + valid URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway) + * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway + .' + returned: success + type: str + nextHopInstance: + description: + - URL to an instance that should handle matching packets. + - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/) + instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance + .' + returned: success + type: str + nextHopIp: + description: + - Network IP address of an instance that should handle matching packets. + returned: success + type: str + nextHopVpnTunnel: + description: + - URL to a VpnTunnel that should handle matching packets. + returned: success + type: str + nextHopNetwork: + description: + - URL to a Network that should handle matching packets. + returned: success + type: str ''' ################################################################################ @@ -159,7 +158,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_router.py b/lib/ansible/modules/cloud/google/gcp_compute_router.py index 40d88a7d9e..be8bf03f37 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_router.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_router.py @@ -32,91 +32,97 @@ DOCUMENTATION = ''' --- module: gcp_compute_router description: - - Represents a Router resource. +- Represents a Router resource. short_description: Creates a GCP Router version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - required: true + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match the regular + expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must + be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + required: true + description: + description: + - An optional description of this resource. + required: false + network: + description: + - A reference to the network to which this router belongs. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: true + bgp: + description: + - BGP information specific to this router. + required: false + suboptions: + asn: description: - - An optional description of this resource. - required: false - network: - description: - - A reference to the network to which this router belongs. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' + - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, + either 16-bit or 32-bit. The value will be fixed for this router resource. + All VPN tunnels that link to this router will have the same local ASN. required: true - bgp: + advertise_mode: description: - - BGP information specific to this router. + - User-specified flag to indicate which mode to use for advertisement. + - 'Valid values of this enum field are: DEFAULT, CUSTOM .' + required: false + default: DEFAULT + choices: + - DEFAULT + - CUSTOM + advertised_groups: + description: + - User-specified list of prefix groups to advertise in custom mode. + - This field can only be populated if advertiseMode is CUSTOM and is advertised + to all peers of the router. These groups will be advertised in addition + to any specified prefixes. Leave this field blank to advertise no custom + groups. + - 'This enum field has the one valid value: ALL_SUBNETS .' + required: false + advertised_ip_ranges: + description: + - User-specified list of individual IP ranges to advertise in custom mode. + This field can only be populated if advertiseMode is CUSTOM and is advertised + to all peers of the router. These IP ranges will be advertised in addition + to any specified groups. + - Leave this field blank to advertise no custom IP ranges. required: false suboptions: - asn: - description: - - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, either - 16-bit or 32-bit. The value will be fixed for this router resource. All VPN tunnels - that link to this router will have the same local ASN. - required: true - advertise_mode: - description: - - User-specified flag to indicate which mode to use for advertisement. - - 'Valid values of this enum field are: DEFAULT, CUSTOM .' - required: false - default: DEFAULT - choices: ['DEFAULT', 'CUSTOM'] - advertised_groups: - description: - - User-specified list of prefix groups to advertise in custom mode. - - This field can only be populated if advertiseMode is CUSTOM and is advertised to - all peers of the router. These groups will be advertised in addition to any specified - prefixes. Leave this field blank to advertise no custom groups. - - 'This enum field has the one valid value: ALL_SUBNETS .' - required: false - advertised_ip_ranges: - description: - - User-specified list of individual IP ranges to advertise in custom mode. This field - can only be populated if advertiseMode is CUSTOM and is advertised to all peers - of the router. These IP ranges will be advertised in addition to any specified groups. - - Leave this field blank to advertise no custom IP ranges. - required: false - suboptions: - range: - description: - - The IP range to advertise. The value must be a CIDR-formatted string. - required: false - description: - description: - - User-specified description for the IP range. - required: false - region: - description: - - Region where the router resides. - required: true + range: + description: + - The IP range to advertise. The value must be a CIDR-formatted string. + required: false + description: + description: + - User-specified description for the IP range. + required: false + region: + description: + - Region where the router resides. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/routers)" - - "Google Cloud Router: U(https://cloud.google.com/router/docs/)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/routers)' +- 'Google Cloud Router: U(https://cloud.google.com/router/docs/)' ''' EXAMPLES = ''' @@ -149,87 +155,88 @@ EXAMPLES = ''' ''' RETURN = ''' - id: +id: + description: + - The unique identifier for the resource. + returned: success + type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. + Specifically, the name must be 1-63 characters long and match the regular expression + `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase + letter, and all following characters must be a dash, lowercase letter, or digit, + except the last character, which cannot be a dash. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +network: + description: + - A reference to the network to which this router belongs. + returned: success + type: dict +bgp: + description: + - BGP information specific to this router. + returned: success + type: complex + contains: + asn: + description: + - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, + either 16-bit or 32-bit. The value will be fixed for this router resource. + All VPN tunnels that link to this router will have the same local ASN. + returned: success + type: int + advertiseMode: + description: + - User-specified flag to indicate which mode to use for advertisement. + - 'Valid values of this enum field are: DEFAULT, CUSTOM .' + returned: success + type: str + advertisedGroups: + description: + - User-specified list of prefix groups to advertise in custom mode. + - This field can only be populated if advertiseMode is CUSTOM and is advertised + to all peers of the router. These groups will be advertised in addition to + any specified prefixes. Leave this field blank to advertise no custom groups. + - 'This enum field has the one valid value: ALL_SUBNETS .' + returned: success + type: list + advertisedIpRanges: + description: + - User-specified list of individual IP ranges to advertise in custom mode. This + field can only be populated if advertiseMode is CUSTOM and is advertised to + all peers of the router. These IP ranges will be advertised in addition to + any specified groups. + - Leave this field blank to advertise no custom IP ranges. + returned: success + type: complex + contains: + range: + description: + - The IP range to advertise. The value must be a CIDR-formatted string. + returned: success + type: str description: - - The unique identifier for the resource. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - network: - description: - - A reference to the network to which this router belongs. - returned: success - type: dict - bgp: - description: - - BGP information specific to this router. - returned: success - type: complex - contains: - asn: - description: - - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, either - 16-bit or 32-bit. The value will be fixed for this router resource. All VPN tunnels - that link to this router will have the same local ASN. - returned: success - type: int - advertiseMode: - description: - - User-specified flag to indicate which mode to use for advertisement. - - 'Valid values of this enum field are: DEFAULT, CUSTOM .' - returned: success - type: str - advertisedGroups: - description: - - User-specified list of prefix groups to advertise in custom mode. - - This field can only be populated if advertiseMode is CUSTOM and is advertised to - all peers of the router. These groups will be advertised in addition to any specified - prefixes. Leave this field blank to advertise no custom groups. - - 'This enum field has the one valid value: ALL_SUBNETS .' - returned: success - type: list - advertisedIpRanges: - description: - - User-specified list of individual IP ranges to advertise in custom mode. This field - can only be populated if advertiseMode is CUSTOM and is advertised to all peers - of the router. These IP ranges will be advertised in addition to any specified groups. - - Leave this field blank to advertise no custom IP ranges. - returned: success - type: complex - contains: - range: - description: - - The IP range to advertise. The value must be a CIDR-formatted string. - returned: success - type: str - description: - description: - - User-specified description for the IP range. - returned: success - type: str - region: - description: - - Region where the router resides. - returned: success - type: str + description: + - User-specified description for the IP range. + returned: success + type: str +region: + description: + - Region where the router resides. + returned: success + type: str ''' ################################################################################ @@ -419,8 +426,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -445,7 +450,7 @@ class RouterBgp(object): u'asn': self.request.get('asn'), u'advertiseMode': self.request.get('advertise_mode'), u'advertisedGroups': self.request.get('advertised_groups'), - u'advertisedIpRanges': RouterAdvertisedIpRangesArray(self.request.get('advertised_ip_ranges', []), self.module).to_request() + u'advertisedIpRanges': RouterAdvertisediprangesArray(self.request.get('advertised_ip_ranges', []), self.module).to_request() }) def from_response(self): @@ -453,11 +458,11 @@ class RouterBgp(object): u'asn': self.request.get(u'asn'), u'advertiseMode': self.request.get(u'advertiseMode'), u'advertisedGroups': self.request.get(u'advertisedGroups'), - u'advertisedIpRanges': RouterAdvertisedIpRangesArray(self.request.get(u'advertisedIpRanges', []), self.module).from_response() + u'advertisedIpRanges': RouterAdvertisediprangesArray(self.request.get(u'advertisedIpRanges', []), self.module).from_response() }) -class RouterAdvertisedIpRangesArray(object): +class RouterAdvertisediprangesArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_router_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_router_facts.py index ae9057d727..50f61da2c1 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_router_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_router_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_router_facts description: - - Gather facts for GCP Router +- Gather facts for GCP Router short_description: Gather facts for GCP Router version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - Region where the router resides. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - Region where the router resides. + required: true extends_documentation_fragment: gcp ''' @@ -67,91 +66,93 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - id: + description: List of items + returned: always + type: complex + contains: + id: + description: + - The unique identifier for the resource. + returned: success + type: int + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match the + regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character + must be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + network: + description: + - A reference to the network to which this router belongs. + returned: success + type: dict + bgp: + description: + - BGP information specific to this router. + returned: success + type: complex + contains: + asn: + description: + - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, + either 16-bit or 32-bit. The value will be fixed for this router resource. + All VPN tunnels that link to this router will have the same local ASN. + returned: success + type: int + advertiseMode: + description: + - User-specified flag to indicate which mode to use for advertisement. + - 'Valid values of this enum field are: DEFAULT, CUSTOM .' + returned: success + type: str + advertisedGroups: + description: + - User-specified list of prefix groups to advertise in custom mode. + - This field can only be populated if advertiseMode is CUSTOM and is advertised + to all peers of the router. These groups will be advertised in addition + to any specified prefixes. Leave this field blank to advertise no custom + groups. + - 'This enum field has the one valid value: ALL_SUBNETS .' + returned: success + type: list + advertisedIpRanges: + description: + - User-specified list of individual IP ranges to advertise in custom mode. + This field can only be populated if advertiseMode is CUSTOM and is advertised + to all peers of the router. These IP ranges will be advertised in addition + to any specified groups. + - Leave this field blank to advertise no custom IP ranges. + returned: success + type: complex + contains: + range: + description: + - The IP range to advertise. The value must be a CIDR-formatted string. + returned: success + type: str description: - - The unique identifier for the resource. - returned: success - type: int - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - network: - description: - - A reference to the network to which this router belongs. - returned: success - type: dict - bgp: - description: - - BGP information specific to this router. - returned: success - type: complex - contains: - asn: - description: - - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN, either - 16-bit or 32-bit. The value will be fixed for this router resource. All VPN tunnels - that link to this router will have the same local ASN. - returned: success - type: int - advertiseMode: - description: - - User-specified flag to indicate which mode to use for advertisement. - - 'Valid values of this enum field are: DEFAULT, CUSTOM .' - returned: success - type: str - advertisedGroups: - description: - - User-specified list of prefix groups to advertise in custom mode. - - This field can only be populated if advertiseMode is CUSTOM and is advertised to - all peers of the router. These groups will be advertised in addition to any specified - prefixes. Leave this field blank to advertise no custom groups. - - 'This enum field has the one valid value: ALL_SUBNETS .' - returned: success - type: list - advertisedIpRanges: - description: - - User-specified list of individual IP ranges to advertise in custom mode. This field - can only be populated if advertiseMode is CUSTOM and is advertised to all peers - of the router. These IP ranges will be advertised in addition to any specified groups. - - Leave this field blank to advertise no custom IP ranges. - returned: success - type: complex - contains: - range: - description: - - The IP range to advertise. The value must be a CIDR-formatted string. - returned: success - type: str - description: - description: - - User-specified description for the IP range. - returned: success - type: str - region: - description: - - Region where the router resides. - returned: success - type: str + description: + - User-specified description for the IP range. + returned: success + type: str + region: + description: + - Region where the router resides. + returned: success + type: str ''' ################################################################################ @@ -173,7 +174,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py index 5fdd494b04..1626e85c4d 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py @@ -32,49 +32,51 @@ DOCUMENTATION = ''' --- module: gcp_compute_ssl_certificate description: - - An SslCertificate resource, used for HTTPS load balancing. This resource provides - a mechanism to upload an SSL key and certificate to the load balancer to serve secure - connections from the user. +- An SslCertificate resource, used for HTTPS load balancing. This resource provides + a mechanism to upload an SSL key and certificate to the load balancer to serve secure + connections from the user. short_description: Creates a GCP SslCertificate version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - certificate: - description: - - The certificate in PEM format. - - The certificate chain must be no greater than 5 certs long. - - The chain must include at least one intermediate cert. - required: true + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: false - private_key: - description: - - The write-only private key in PEM format. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + certificate: + description: + - The certificate in PEM format. + - The certificate chain must be no greater than 5 certs long. + - The chain must include at least one intermediate cert. + required: true + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: false + private_key: + description: + - The write-only private key in PEM format. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/sslCertificates)" - - "Official Documentation: U(https://cloud.google.com/load-balancing/docs/ssl-certificates)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/sslCertificates)' +- 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/ssl-certificates)' ''' EXAMPLES = ''' @@ -113,43 +115,43 @@ EXAMPLES = ''' ''' RETURN = ''' - certificate: - description: - - The certificate in PEM format. - - The certificate chain must be no greater than 5 certs long. - - The chain must include at least one intermediate cert. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - privateKey: - description: - - The write-only private key in PEM format. - returned: success - type: str +certificate: + description: + - The certificate in PEM format. + - The certificate chain must be no greater than 5 certs long. + - The chain must include at least one intermediate cert. + returned: success + type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +privateKey: + description: + - The write-only private key in PEM format. + returned: success + type: str ''' ################################################################################ @@ -328,8 +330,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_facts.py index 4fc37c9483..e82ed7db54 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_ssl_certificate_facts description: - - Gather facts for GCP SslCertificate +- Gather facts for GCP SslCertificate short_description: Gather facts for GCP SslCertificate version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,47 +61,47 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - certificate: - description: - - The certificate in PEM format. - - The certificate chain must be no greater than 5 certs long. - - The chain must include at least one intermediate cert. - returned: success - type: str - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - privateKey: - description: - - The write-only private key in PEM format. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + certificate: + description: + - The certificate in PEM format. + - The certificate chain must be no greater than 5 certs long. + - The chain must include at least one intermediate cert. + returned: success + type: str + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + privateKey: + description: + - The write-only private key in PEM format. + returned: success + type: str ''' ################################################################################ @@ -123,7 +122,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py index 003eaf34eb..d133603685 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py @@ -32,58 +32,68 @@ DOCUMENTATION = ''' --- module: gcp_compute_ssl_policy description: - - Represents a SSL policy. SSL policies give you the ability to control the features - of SSL that your SSL proxy or HTTPS load balancer negotiates. +- Represents a SSL policy. SSL policies give you the ability to control the features + of SSL that your SSL proxy or HTTPS load balancer negotiates. short_description: Creates a GCP SslPolicy version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - profile: - description: - - Profile specifies the set of SSL features that can be used by the load balancer - when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`, `RESTRICTED`, - or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable must be specified - in the `customFeatures` field. - required: false - choices: ['COMPATIBLE', 'MODERN', 'RESTRICTED', 'CUSTOM'] - min_tls_version: - description: - - The minimum version of SSL protocol that can be used by the clients to establish - a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`, `TLS_1_2`. - required: false - choices: ['TLS_1_0', 'TLS_1_1', 'TLS_1_2'] - custom_features: - description: - - A list of features enabled when the selected profile is CUSTOM. The method returns - the set of features that can be specified in this list. This field must be empty - if the profile is not CUSTOM. - required: false + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + profile: + description: + - Profile specifies the set of SSL features that can be used by the load balancer + when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`, + `RESTRICTED`, or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable + must be specified in the `customFeatures` field. + required: false + choices: + - COMPATIBLE + - MODERN + - RESTRICTED + - CUSTOM + min_tls_version: + description: + - The minimum version of SSL protocol that can be used by the clients to establish + a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`, + `TLS_1_2`. + required: false + choices: + - TLS_1_0 + - TLS_1_1 + - TLS_1_2 + custom_features: + description: + - A list of features enabled when the selected profile is CUSTOM. The method returns + the set of features that can be specified in this list. This field must be empty + if the profile is not CUSTOM. + required: false extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/sslPolicies)" - - "Using SSL Policies: U(https://cloud.google.com/compute/docs/load-balancing/ssl-policies)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/sslPolicies)' +- 'Using SSL Policies: U(https://cloud.google.com/compute/docs/load-balancing/ssl-policies)' ''' EXAMPLES = ''' @@ -102,80 +112,81 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - profile: - description: - - Profile specifies the set of SSL features that can be used by the load balancer - when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`, `RESTRICTED`, - or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable must be specified - in the `customFeatures` field. - returned: success - type: str - minTlsVersion: - description: - - The minimum version of SSL protocol that can be used by the clients to establish - a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`, `TLS_1_2`. - returned: success - type: str - enabledFeatures: - description: - - The list of features enabled in the SSL policy. - returned: success - type: list - customFeatures: - description: - - A list of features enabled when the selected profile is CUSTOM. The method returns - the set of features that can be specified in this list. This field must be empty - if the profile is not CUSTOM. - returned: success - type: list - fingerprint: - description: - - Fingerprint of this resource. A hash of the contents stored in this object. This - field is used in optimistic locking. - returned: success - type: str - warnings: - description: - - If potential misconfigurations are detected for this SSL policy, this field will - be populated with warning messages. - returned: success - type: complex - contains: - code: - description: - - A warning code, if applicable. - returned: success - type: str - message: - description: - - A human-readable description of the warning code. - returned: success - type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +profile: + description: + - Profile specifies the set of SSL features that can be used by the load balancer + when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`, + `RESTRICTED`, or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable + must be specified in the `customFeatures` field. + returned: success + type: str +minTlsVersion: + description: + - The minimum version of SSL protocol that can be used by the clients to establish + a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`, + `TLS_1_2`. + returned: success + type: str +enabledFeatures: + description: + - The list of features enabled in the SSL policy. + returned: success + type: list +customFeatures: + description: + - A list of features enabled when the selected profile is CUSTOM. The method returns + the set of features that can be specified in this list. This field must be empty + if the profile is not CUSTOM. + returned: success + type: list +fingerprint: + description: + - Fingerprint of this resource. A hash of the contents stored in this object. This + field is used in optimistic locking. + returned: success + type: str +warnings: + description: + - If potential misconfigurations are detected for this SSL policy, this field will + be populated with warning messages. + returned: success + type: complex + contains: + code: + description: + - A warning code, if applicable. + returned: success + type: str + message: + description: + - A human-readable description of the warning code. + returned: success + type: str ''' ################################################################################ @@ -361,8 +372,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_facts.py index 80de3606b9..fffd3c62d0 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_ssl_policy_facts description: - - Gather facts for GCP SslPolicy +- Gather facts for GCP SslPolicy short_description: Gather facts for GCP SslPolicy version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,84 +61,85 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - profile: - description: - - Profile specifies the set of SSL features that can be used by the load balancer - when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`, `RESTRICTED`, - or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable must be specified - in the `customFeatures` field. - returned: success - type: str - minTlsVersion: - description: - - The minimum version of SSL protocol that can be used by the clients to establish - a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`, `TLS_1_2`. - returned: success - type: str - enabledFeatures: - description: - - The list of features enabled in the SSL policy. - returned: success - type: list - customFeatures: - description: - - A list of features enabled when the selected profile is CUSTOM. The method returns - the set of features that can be specified in this list. This field must be empty - if the profile is not CUSTOM. - returned: success - type: list - fingerprint: - description: - - Fingerprint of this resource. A hash of the contents stored in this object. This - field is used in optimistic locking. - returned: success - type: str - warnings: - description: - - If potential misconfigurations are detected for this SSL policy, this field will - be populated with warning messages. - returned: success - type: complex - contains: - code: - description: - - A warning code, if applicable. - returned: success - type: str - message: - description: - - A human-readable description of the warning code. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + profile: + description: + - Profile specifies the set of SSL features that can be used by the load balancer + when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`, + `RESTRICTED`, or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable + must be specified in the `customFeatures` field. + returned: success + type: str + minTlsVersion: + description: + - The minimum version of SSL protocol that can be used by the clients to establish + a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`, + `TLS_1_2`. + returned: success + type: str + enabledFeatures: + description: + - The list of features enabled in the SSL policy. + returned: success + type: list + customFeatures: + description: + - A list of features enabled when the selected profile is CUSTOM. The method + returns the set of features that can be specified in this list. This field + must be empty if the profile is not CUSTOM. + returned: success + type: list + fingerprint: + description: + - Fingerprint of this resource. A hash of the contents stored in this object. + This field is used in optimistic locking. + returned: success + type: str + warnings: + description: + - If potential misconfigurations are detected for this SSL policy, this field + will be populated with warning messages. + returned: success + type: complex + contains: + code: + description: + - A warning code, if applicable. + returned: success + type: str + message: + description: + - A human-readable description of the warning code. + returned: success + type: str ''' ################################################################################ @@ -160,7 +160,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py index 9348fb6293..d8e2946595 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py @@ -32,109 +32,111 @@ DOCUMENTATION = ''' --- module: gcp_compute_subnetwork description: - - A VPC network is a virtual version of the traditional physical networks that exist - within and between physical data centers. A VPC network provides connectivity for - your Compute Engine virtual machine (VM) instances, Container Engine containers, - App Engine Flex services, and other network-related resources. - - Each GCP project contains one or more VPC networks. Each VPC network is a global - entity spanning all GCP regions. This global VPC network allows VM instances and - other resources to communicate with each other via internal, private IP addresses. - - Each VPC network is subdivided into subnets, and each subnet is contained within - a single region. You can have more than one subnet in a region for a given VPC network. - Each subnet has a contiguous private RFC1918 IP space. You create instances, containers, - and the like in these subnets. - - When you create an instance, you must create it in a subnet, and the instance draws - its internal IP address from that subnet. - - Virtual machine (VM) instances in a VPC network can communicate with instances in - all other subnets of the same VPC network, regardless of region, using their RFC1918 - private IP addresses. You can isolate portions of the network, even entire subnets, - using firewall rules. +- A VPC network is a virtual version of the traditional physical networks that exist + within and between physical data centers. A VPC network provides connectivity for + your Compute Engine virtual machine (VM) instances, Container Engine containers, + App Engine Flex services, and other network-related resources. +- Each GCP project contains one or more VPC networks. Each VPC network is a global + entity spanning all GCP regions. This global VPC network allows VM instances and + other resources to communicate with each other via internal, private IP addresses. +- Each VPC network is subdivided into subnets, and each subnet is contained within + a single region. You can have more than one subnet in a region for a given VPC network. + Each subnet has a contiguous private RFC1918 IP space. You create instances, containers, + and the like in these subnets. +- When you create an instance, you must create it in a subnet, and the instance draws + its internal IP address from that subnet. +- Virtual machine (VM) instances in a VPC network can communicate with instances in + all other subnets of the same VPC network, regardless of region, using their RFC1918 + private IP addresses. You can isolate portions of the network, even entire subnets, + using firewall rules. short_description: Creates a GCP Subnetwork version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. This field can be set only at resource creation time. + required: false + ip_cidr_range: + description: + - The range of internal addresses that are owned by this subnetwork. + - Provide this property when you create the subnetwork. For example, 10.0.0.0/8 + or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. + Only IPv4 is supported. + required: true + name: + description: + - The name of the resource, provided by the client when initially creating the + resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + network: + description: + - The network this subnet belongs to. + - Only networks that are in the distributed mode can have subnetworks. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: true + enable_flow_logs: + description: + - Whether to enable flow logging for this subnetwork. + required: false + type: bool + version_added: 2.8 + secondary_ip_ranges: + description: + - An array of configurations for secondary IP ranges for VM instances contained + in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange + of the subnetwork. The alias IPs may belong to either primary or secondary ranges. + required: false + version_added: 2.8 + suboptions: + range_name: description: - - An optional description of this resource. Provide this property when you create - the resource. This field can be set only at resource creation time. - required: false - ip_cidr_range: - description: - - The range of internal addresses that are owned by this subnetwork. - - Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or - 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. Only - IPv4 is supported. + - The name associated with this subnetwork secondary range, used when adding + an alias IP range to a VM instance. The name must be 1-63 characters long, + and comply with RFC1035. The name must be unique within the subnetwork. required: true - name: + ip_cidr_range: description: - - The name of the resource, provided by the client when initially creating the resource. - The name must be 1-63 characters long, and comply with RFC1035. Specifically, the - name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - network: - description: - - The network this subnet belongs to. - - Only networks that are in the distributed mode can have subnetworks. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: true - enable_flow_logs: - description: - - Whether to enable flow logging for this subnetwork. - required: false - type: bool - version_added: 2.8 - secondary_ip_ranges: - description: - - An array of configurations for secondary IP ranges for VM instances contained in - this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange - of the subnetwork. The alias IPs may belong to either primary or secondary ranges. - required: false - version_added: 2.8 - suboptions: - range_name: - description: - - The name associated with this subnetwork secondary range, used when adding an alias - IP range to a VM instance. The name must be 1-63 characters long, and comply with - RFC1035. The name must be unique within the subnetwork. - required: true - ip_cidr_range: - description: - - The range of IP addresses belonging to this subnetwork secondary range. Provide - this property when you create the subnetwork. - - Ranges must be unique and non-overlapping with all primary and secondary IP ranges - within a network. Only IPv4 is supported. - required: true - private_ip_google_access: - description: - - Whether the VMs in this subnet can access Google services without assigned external - IP addresses. - required: false - type: bool - region: - description: - - URL of the GCP region for this subnetwork. + - The range of IP addresses belonging to this subnetwork secondary range. + Provide this property when you create the subnetwork. + - Ranges must be unique and non-overlapping with all primary and secondary + IP ranges within a network. Only IPv4 is supported. required: true + private_ip_google_access: + description: + - Whether the VMs in this subnet can access Google services without assigned external + IP addresses. + required: false + type: bool + region: + description: + - URL of the GCP region for this subnetwork. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/subnetworks)" - - "Private Google Access: U(https://cloud.google.com/vpc/docs/configure-private-google-access)" - - "Cloud Networking: U(https://cloud.google.com/vpc/docs/using-vpc)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/subnetworks)' +- 'Private Google Access: U(https://cloud.google.com/vpc/docs/configure-private-google-access)' +- 'Cloud Networking: U(https://cloud.google.com/vpc/docs/using-vpc)' ''' EXAMPLES = ''' @@ -161,97 +163,97 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. This field can be set only at resource creation time. - returned: success - type: str - gatewayAddress: - description: - - The gateway address for default routes to reach destination addresses outside this - subnetwork. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. This field can be set only at resource creation time. + returned: success + type: str +gatewayAddress: + description: + - The gateway address for default routes to reach destination addresses outside + this subnetwork. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +ipCidrRange: + description: + - The range of internal addresses that are owned by this subnetwork. + - Provide this property when you create the subnetwork. For example, 10.0.0.0/8 + or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. + Only IPv4 is supported. + returned: success + type: str +name: + description: + - The name of the resource, provided by the client when initially creating the resource. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +network: + description: + - The network this subnet belongs to. + - Only networks that are in the distributed mode can have subnetworks. + returned: success + type: dict +enableFlowLogs: + description: + - Whether to enable flow logging for this subnetwork. + returned: success + type: bool +fingerprint: + description: + - Fingerprint of this resource. This field is used internally during updates of + this resource. + returned: success + type: str +secondaryIpRanges: + description: + - An array of configurations for secondary IP ranges for VM instances contained + in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange + of the subnetwork. The alias IPs may belong to either primary or secondary ranges. + returned: success + type: complex + contains: + rangeName: + description: + - The name associated with this subnetwork secondary range, used when adding + an alias IP range to a VM instance. The name must be 1-63 characters long, + and comply with RFC1035. The name must be unique within the subnetwork. + returned: success + type: str ipCidrRange: - description: - - The range of internal addresses that are owned by this subnetwork. - - Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or - 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. Only - IPv4 is supported. - returned: success - type: str - name: - description: - - The name of the resource, provided by the client when initially creating the resource. - The name must be 1-63 characters long, and comply with RFC1035. Specifically, the - name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - The network this subnet belongs to. - - Only networks that are in the distributed mode can have subnetworks. - returned: success - type: dict - enableFlowLogs: - description: - - Whether to enable flow logging for this subnetwork. - returned: success - type: bool - fingerprint: - description: - - Fingerprint of this resource. This field is used internally during updates of this - resource. - returned: success - type: str - secondaryIpRanges: - description: - - An array of configurations for secondary IP ranges for VM instances contained in - this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange - of the subnetwork. The alias IPs may belong to either primary or secondary ranges. - returned: success - type: complex - contains: - rangeName: - description: - - The name associated with this subnetwork secondary range, used when adding an alias - IP range to a VM instance. The name must be 1-63 characters long, and comply with - RFC1035. The name must be unique within the subnetwork. - returned: success - type: str - ipCidrRange: - description: - - The range of IP addresses belonging to this subnetwork secondary range. Provide - this property when you create the subnetwork. - - Ranges must be unique and non-overlapping with all primary and secondary IP ranges - within a network. Only IPv4 is supported. - returned: success - type: str - privateIpGoogleAccess: - description: - - Whether the VMs in this subnet can access Google services without assigned external - IP addresses. - returned: success - type: bool - region: - description: - - URL of the GCP region for this subnetwork. - returned: success - type: str + description: + - The range of IP addresses belonging to this subnetwork secondary range. Provide + this property when you create the subnetwork. + - Ranges must be unique and non-overlapping with all primary and secondary IP + ranges within a network. Only IPv4 is supported. + returned: success + type: str +privateIpGoogleAccess: + description: + - Whether the VMs in this subnet can access Google services without assigned external + IP addresses. + returned: success + type: bool +region: + description: + - URL of the GCP region for this subnetwork. + returned: success + type: str ''' ################################################################################ @@ -361,7 +363,7 @@ def enable_flow_logs_update(module, request, response): { u'enableFlowLogs': module.params.get('enable_flow_logs'), u'fingerprint': response.get('fingerprint'), - u'secondaryIpRanges': SubnetworkSecondaryIpRangesArray(module.params.get('secondary_ip_ranges', []), module).to_request() + u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request() } ) @@ -392,7 +394,7 @@ def resource_to_request(module): u'name': module.params.get('name'), u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'), u'enableFlowLogs': module.params.get('enable_flow_logs'), - u'secondaryIpRanges': SubnetworkSecondaryIpRangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(), + u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(), u'privateIpGoogleAccess': module.params.get('private_ip_google_access'), u'region': module.params.get('region') } @@ -469,7 +471,7 @@ def response_to_hash(module, response): u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'), u'enableFlowLogs': response.get(u'enableFlowLogs'), u'fingerprint': response.get(u'fingerprint'), - u'secondaryIpRanges': SubnetworkSecondaryIpRangesArray(response.get(u'secondaryIpRanges', []), module).from_response(), + u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(response.get(u'secondaryIpRanges', []), module).from_response(), u'privateIpGoogleAccess': response.get(u'privateIpGoogleAccess'), u'region': module.params.get('region') } @@ -499,8 +501,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -512,7 +512,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class SubnetworkSecondaryIpRangesArray(object): +class SubnetworkSecondaryiprangesArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_facts.py index 2952d3a151..e6aa384beb 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_subnetwork_facts description: - - Gather facts for GCP Subnetwork +- Gather facts for GCP Subnetwork short_description: Gather facts for GCP Subnetwork version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - URL of the GCP region for this subnetwork. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - URL of the GCP region for this subnetwork. + required: true extends_documentation_fragment: gcp ''' @@ -67,101 +66,102 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. This field can be set only at resource creation time. - returned: success - type: str - gatewayAddress: - description: - - The gateway address for default routes to reach destination addresses outside this - subnetwork. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. This field can be set only at resource creation time. + returned: success + type: str + gatewayAddress: + description: + - The gateway address for default routes to reach destination addresses outside + this subnetwork. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + ipCidrRange: + description: + - The range of internal addresses that are owned by this subnetwork. + - Provide this property when you create the subnetwork. For example, 10.0.0.0/8 + or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. + Only IPv4 is supported. + returned: success + type: str + name: + description: + - The name of the resource, provided by the client when initially creating the + resource. The name must be 1-63 characters long, and comply with RFC1035. + Specifically, the name must be 1-63 characters long and match the regular + expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must + be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + returned: success + type: str + network: + description: + - The network this subnet belongs to. + - Only networks that are in the distributed mode can have subnetworks. + returned: success + type: dict + enableFlowLogs: + description: + - Whether to enable flow logging for this subnetwork. + returned: success + type: bool + fingerprint: + description: + - Fingerprint of this resource. This field is used internally during updates + of this resource. + returned: success + type: str + secondaryIpRanges: + description: + - An array of configurations for secondary IP ranges for VM instances contained + in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange + of the subnetwork. The alias IPs may belong to either primary or secondary + ranges. + returned: success + type: complex + contains: + rangeName: + description: + - The name associated with this subnetwork secondary range, used when adding + an alias IP range to a VM instance. The name must be 1-63 characters long, + and comply with RFC1035. The name must be unique within the subnetwork. + returned: success + type: str ipCidrRange: - description: - - The range of internal addresses that are owned by this subnetwork. - - Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or - 192.168.0.0/16. Ranges must be unique and non-overlapping within a network. Only - IPv4 is supported. - returned: success - type: str - name: - description: - - The name of the resource, provided by the client when initially creating the resource. - The name must be 1-63 characters long, and comply with RFC1035. Specifically, the - name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - network: - description: - - The network this subnet belongs to. - - Only networks that are in the distributed mode can have subnetworks. - returned: success - type: dict - enableFlowLogs: - description: - - Whether to enable flow logging for this subnetwork. - returned: success - type: bool - fingerprint: - description: - - Fingerprint of this resource. This field is used internally during updates of this - resource. - returned: success - type: str - secondaryIpRanges: - description: - - An array of configurations for secondary IP ranges for VM instances contained in - this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange - of the subnetwork. The alias IPs may belong to either primary or secondary ranges. - returned: success - type: complex - contains: - rangeName: - description: - - The name associated with this subnetwork secondary range, used when adding an alias - IP range to a VM instance. The name must be 1-63 characters long, and comply with - RFC1035. The name must be unique within the subnetwork. - returned: success - type: str - ipCidrRange: - description: - - The range of IP addresses belonging to this subnetwork secondary range. Provide - this property when you create the subnetwork. - - Ranges must be unique and non-overlapping with all primary and secondary IP ranges - within a network. Only IPv4 is supported. - returned: success - type: str - privateIpGoogleAccess: - description: - - Whether the VMs in this subnet can access Google services without assigned external - IP addresses. - returned: success - type: bool - region: - description: - - URL of the GCP region for this subnetwork. - returned: success - type: str + description: + - The range of IP addresses belonging to this subnetwork secondary range. + Provide this property when you create the subnetwork. + - Ranges must be unique and non-overlapping with all primary and secondary + IP ranges within a network. Only IPv4 is supported. + returned: success + type: str + privateIpGoogleAccess: + description: + - Whether the VMs in this subnet can access Google services without assigned + external IP addresses. + returned: success + type: bool + region: + description: + - URL of the GCP region for this subnetwork. + returned: success + type: str ''' ################################################################################ @@ -183,7 +183,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py index 808d4d3c28..5fc0ec61a2 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py @@ -32,47 +32,50 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_http_proxy description: - - Represents a TargetHttpProxy resource, which is used by one or more global forwarding - rule to route incoming HTTP requests to a URL map. +- Represents a TargetHttpProxy resource, which is used by one or more global forwarding + rule to route incoming HTTP requests to a URL map. short_description: Creates a GCP TargetHttpProxy version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - url_map: - description: - - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - - 'This field represents a link to a UrlMap resource in GCP. It can be specified in - two ways. You can add `register: name-of-resource` to a gcp_compute_url_map task - and then set this url_map field to "{{ name-of-resource }}" Alternatively, you can - set this url_map to a dictionary with the selfLink key where the value is the selfLink - of your UrlMap.' - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + url_map: + description: + - A reference to the UrlMap resource that defines the mapping from URL to the + BackendService. + - 'This field represents a link to a UrlMap resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_url_map + task and then set this url_map field to "{{ name-of-resource }}" Alternatively, + you can set this url_map to a dictionary with the selfLink key where the value + is the selfLink of your UrlMap' + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies)" - - "Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies)' +- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)' ''' EXAMPLES = ''' @@ -134,36 +137,36 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - urlMap: - description: - - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - returned: success - type: dict +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +urlMap: + description: + - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. + returned: success + type: dict ''' ################################################################################ @@ -359,8 +362,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_facts.py index 0506a929ca..7a558e0d9b 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_http_proxy_facts description: - - Gather facts for GCP TargetHttpProxy +- Gather facts for GCP TargetHttpProxy short_description: Gather facts for GCP TargetHttpProxy version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,40 +61,41 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - urlMap: - description: - - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - returned: success - type: dict + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + urlMap: + description: + - A reference to the UrlMap resource that defines the mapping from URL to the + BackendService. + returned: success + type: dict ''' ################################################################################ @@ -116,7 +116,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py index fc298bdc89..d2e2eed5a6 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py @@ -32,62 +32,69 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_https_proxy description: - - Represents a TargetHttpsProxy resource, which is used by one or more global forwarding - rule to route incoming HTTPS requests to a URL map. +- Represents a TargetHttpsProxy resource, which is used by one or more global forwarding + rule to route incoming HTTPS requests to a URL map. short_description: Creates a GCP TargetHttpsProxy version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - quic_override: - description: - - Specifies the QUIC override policy for this resource. This determines whether the - load balancer will attempt to negotiate QUIC with clients or not. Can specify one - of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy with no - user overrides, which is equivalent to DISABLE. Not specifying this field is equivalent - to specifying NONE. - required: false - version_added: 2.7 - choices: ['NONE', 'ENABLE', 'DISABLE'] - ssl_certificates: - description: - - A list of SslCertificate resources that are used to authenticate connections between - users and the load balancer. Currently, exactly one SSL certificate must be specified. - required: true - url_map: - description: - - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - - 'This field represents a link to a UrlMap resource in GCP. It can be specified in - two ways. You can add `register: name-of-resource` to a gcp_compute_url_map task - and then set this url_map field to "{{ name-of-resource }}" Alternatively, you can - set this url_map to a dictionary with the selfLink key where the value is the selfLink - of your UrlMap.' - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + quic_override: + description: + - Specifies the QUIC override policy for this resource. This determines whether + the load balancer will attempt to negotiate QUIC with clients or not. Can specify + one of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy + with no user overrides, which is equivalent to DISABLE. Not specifying this + field is equivalent to specifying NONE. + required: false + version_added: 2.7 + choices: + - NONE + - ENABLE + - DISABLE + ssl_certificates: + description: + - A list of SslCertificate resources that are used to authenticate connections + between users and the load balancer. Currently, exactly one SSL certificate + must be specified. + required: true + url_map: + description: + - A reference to the UrlMap resource that defines the mapping from URL to the + BackendService. + - 'This field represents a link to a UrlMap resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_url_map + task and then set this url_map field to "{{ name-of-resource }}" Alternatively, + you can set this url_map to a dictionary with the selfLink key where the value + is the selfLink of your UrlMap' + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetHttpsProxies)" - - "Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetHttpsProxies)' +- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)' ''' EXAMPLES = ''' @@ -185,51 +192,51 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - quicOverride: - description: - - Specifies the QUIC override policy for this resource. This determines whether the - load balancer will attempt to negotiate QUIC with clients or not. Can specify one - of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy with no - user overrides, which is equivalent to DISABLE. Not specifying this field is equivalent - to specifying NONE. - returned: success - type: str - sslCertificates: - description: - - A list of SslCertificate resources that are used to authenticate connections between - users and the load balancer. Currently, exactly one SSL certificate must be specified. - returned: success - type: list - urlMap: - description: - - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - returned: success - type: dict +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +quicOverride: + description: + - Specifies the QUIC override policy for this resource. This determines whether + the load balancer will attempt to negotiate QUIC with clients or not. Can specify + one of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy with + no user overrides, which is equivalent to DISABLE. Not specifying this field is + equivalent to specifying NONE. + returned: success + type: str +sslCertificates: + description: + - A list of SslCertificate resources that are used to authenticate connections between + users and the load balancer. Currently, exactly one SSL certificate must be specified. + returned: success + type: list +urlMap: + description: + - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. + returned: success + type: dict ''' ################################################################################ @@ -461,8 +468,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_facts.py index 1b536b643b..e486510e03 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_https_proxy_facts description: - - Gather facts for GCP TargetHttpsProxy +- Gather facts for GCP TargetHttpsProxy short_description: Gather facts for GCP TargetHttpsProxy version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,55 +61,57 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - quicOverride: - description: - - Specifies the QUIC override policy for this resource. This determines whether the - load balancer will attempt to negotiate QUIC with clients or not. Can specify one - of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy with no - user overrides, which is equivalent to DISABLE. Not specifying this field is equivalent - to specifying NONE. - returned: success - type: str - sslCertificates: - description: - - A list of SslCertificate resources that are used to authenticate connections between - users and the load balancer. Currently, exactly one SSL certificate must be specified. - returned: success - type: list - urlMap: - description: - - A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - returned: success - type: dict + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + quicOverride: + description: + - Specifies the QUIC override policy for this resource. This determines whether + the load balancer will attempt to negotiate QUIC with clients or not. Can + specify one of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC + policy with no user overrides, which is equivalent to DISABLE. Not specifying + this field is equivalent to specifying NONE. + returned: success + type: str + sslCertificates: + description: + - A list of SslCertificate resources that are used to authenticate connections + between users and the load balancer. Currently, exactly one SSL certificate + must be specified. + returned: success + type: list + urlMap: + description: + - A reference to the UrlMap resource that defines the mapping from URL to the + BackendService. + returned: success + type: dict ''' ################################################################################ @@ -131,7 +132,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_pool.py b/lib/ansible/modules/cloud/google/gcp_compute_target_pool.py index b6fab8bb0f..012a2de943 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_pool.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_pool.py @@ -32,101 +32,106 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_pool description: - - Represents a TargetPool resource, used for Load Balancing. +- Represents a TargetPool resource, used for Load Balancing. short_description: Creates a GCP TargetPool version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - backup_pool: - description: - - This field is applicable only when the containing target pool is serving a forwarding - rule as the primary pool, and its failoverRatio field is properly set to a value - between [0, 1]. - - 'backupPool and failoverRatio together define the fallback behavior of the primary - target pool: if the ratio of the healthy instances in the primary pool is at or - below failoverRatio, traffic arriving at the load-balanced IP will be directed to - the backup pool.' - - In case where failoverRatio and backupPool are not set, or all the instances in - the backup pool are unhealthy, the traffic will be directed back to the primary - pool in the "force" mode, where traffic will be spread to the healthy instances - with the best effort, or to all instances when no instance is healthy. - - 'This field represents a link to a TargetPool resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_target_pool - task and then set this backup_pool field to "{{ name-of-resource }}" Alternatively, - you can set this backup_pool to a dictionary with the selfLink key where the value - is the selfLink of your TargetPool.' - required: false + state: description: - description: - - An optional description of this resource. - required: false - failover_ratio: - description: - - This field is applicable only when the containing target pool is serving a forwarding - rule as the primary pool (i.e., not as a backup pool to some other target pool). - The value of the field must be in [0, 1]. - - 'If set, backupPool must also be set. They together define the fallback behavior - of the primary target pool: if the ratio of the healthy instances in the primary - pool is at or below this number, traffic arriving at the load-balanced IP will be - directed to the backup pool.' - - In case where failoverRatio is not set or all the instances in the backup pool are - unhealthy, the traffic will be directed back to the primary pool in the "force" - mode, where traffic will be spread to the healthy instances with the best effort, - or to all instances when no instance is healthy. - required: false - health_check: - description: - - A reference to a HttpHealthCheck resource. - - A member instance in this pool is considered healthy if and only if the health checks - pass. If not specified it means all member instances will be considered healthy - at all times. - - 'This field represents a link to a HttpHealthCheck resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_http_health_check - task and then set this health_check field to "{{ name-of-resource }}" Alternatively, - you can set this health_check to a dictionary with the selfLink key where the value - is the selfLink of your HttpHealthCheck.' - required: false - instances: - description: - - A list of virtual machine instances serving this pool. - - They must live in zones contained in the same region as this pool. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - session_affinity: - description: - - 'Session affinity option. Must be one of these values: - NONE: Connections from - the same client IP may go to any instance in the pool.' - - "- CLIENT_IP: Connections from the same client IP will go to the same instance - in the pool while that instance remains healthy." - - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol - will go to the same instance in the pool while that instance remains healthy." - required: false - choices: ['NONE', 'CLIENT_IP', 'CLIENT_IP_PROTO'] - region: - description: - - The region where the target pool resides. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + backup_pool: + description: + - This field is applicable only when the containing target pool is serving a forwarding + rule as the primary pool, and its failoverRatio field is properly set to a value + between [0, 1]. + - 'backupPool and failoverRatio together define the fallback behavior of the primary + target pool: if the ratio of the healthy instances in the primary pool is at + or below failoverRatio, traffic arriving at the load-balanced IP will be directed + to the backup pool.' + - In case where failoverRatio and backupPool are not set, or all the instances + in the backup pool are unhealthy, the traffic will be directed back to the primary + pool in the "force" mode, where traffic will be spread to the healthy instances + with the best effort, or to all instances when no instance is healthy. + - 'This field represents a link to a TargetPool resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_target_pool + task and then set this backup_pool field to "{{ name-of-resource }}" Alternatively, + you can set this backup_pool to a dictionary with the selfLink key where the + value is the selfLink of your TargetPool' + required: false + description: + description: + - An optional description of this resource. + required: false + failover_ratio: + description: + - This field is applicable only when the containing target pool is serving a forwarding + rule as the primary pool (i.e., not as a backup pool to some other target pool). + The value of the field must be in [0, 1]. + - 'If set, backupPool must also be set. They together define the fallback behavior + of the primary target pool: if the ratio of the healthy instances in the primary + pool is at or below this number, traffic arriving at the load-balanced IP will + be directed to the backup pool.' + - In case where failoverRatio is not set or all the instances in the backup pool + are unhealthy, the traffic will be directed back to the primary pool in the + "force" mode, where traffic will be spread to the healthy instances with the + best effort, or to all instances when no instance is healthy. + required: false + health_check: + description: + - A reference to a HttpHealthCheck resource. + - A member instance in this pool is considered healthy if and only if the health + checks pass. If not specified it means all member instances will be considered + healthy at all times. + - 'This field represents a link to a HttpHealthCheck resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a gcp_compute_http_health_check + task and then set this health_check field to "{{ name-of-resource }}" Alternatively, + you can set this health_check to a dictionary with the selfLink key where the + value is the selfLink of your HttpHealthCheck' + required: false + instances: + description: + - A list of virtual machine instances serving this pool. + - They must live in zones contained in the same region as this pool. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + session_affinity: + description: + - 'Session affinity option. Must be one of these values: - NONE: Connections from + the same client IP may go to any instance in the pool.' + - "- CLIENT_IP: Connections from the same client IP will go to the same instance + in the pool while that instance remains healthy." + - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol + will go to the same instance in the pool while that instance remains healthy." + required: false + choices: + - NONE + - CLIENT_IP + - CLIENT_IP_PROTO + region: + description: + - The region where the target pool resides. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/targetPools)" - - "Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/target-pools)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/targetPools)' +- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/target-pools)' ''' EXAMPLES = ''' @@ -141,90 +146,90 @@ EXAMPLES = ''' ''' RETURN = ''' - backupPool: - description: - - This field is applicable only when the containing target pool is serving a forwarding - rule as the primary pool, and its failoverRatio field is properly set to a value - between [0, 1]. - - 'backupPool and failoverRatio together define the fallback behavior of the primary - target pool: if the ratio of the healthy instances in the primary pool is at or - below failoverRatio, traffic arriving at the load-balanced IP will be directed to - the backup pool.' - - In case where failoverRatio and backupPool are not set, or all the instances in - the backup pool are unhealthy, the traffic will be directed back to the primary - pool in the "force" mode, where traffic will be spread to the healthy instances - with the best effort, or to all instances when no instance is healthy. - returned: success - type: dict - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - failoverRatio: - description: - - This field is applicable only when the containing target pool is serving a forwarding - rule as the primary pool (i.e., not as a backup pool to some other target pool). - The value of the field must be in [0, 1]. - - 'If set, backupPool must also be set. They together define the fallback behavior - of the primary target pool: if the ratio of the healthy instances in the primary - pool is at or below this number, traffic arriving at the load-balanced IP will be - directed to the backup pool.' - - In case where failoverRatio is not set or all the instances in the backup pool are - unhealthy, the traffic will be directed back to the primary pool in the "force" - mode, where traffic will be spread to the healthy instances with the best effort, - or to all instances when no instance is healthy. - returned: success - type: str - healthCheck: - description: - - A reference to a HttpHealthCheck resource. - - A member instance in this pool is considered healthy if and only if the health checks - pass. If not specified it means all member instances will be considered healthy - at all times. - returned: success - type: dict - id: - description: - - The unique identifier for the resource. - returned: success - type: int - instances: - description: - - A list of virtual machine instances serving this pool. - - They must live in zones contained in the same region as this pool. - returned: success - type: list - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - sessionAffinity: - description: - - 'Session affinity option. Must be one of these values: - NONE: Connections from - the same client IP may go to any instance in the pool.' - - "- CLIENT_IP: Connections from the same client IP will go to the same instance - in the pool while that instance remains healthy." - - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol - will go to the same instance in the pool while that instance remains healthy." - returned: success - type: str - region: - description: - - The region where the target pool resides. - returned: success - type: str +backupPool: + description: + - This field is applicable only when the containing target pool is serving a forwarding + rule as the primary pool, and its failoverRatio field is properly set to a value + between [0, 1]. + - 'backupPool and failoverRatio together define the fallback behavior of the primary + target pool: if the ratio of the healthy instances in the primary pool is at or + below failoverRatio, traffic arriving at the load-balanced IP will be directed + to the backup pool.' + - In case where failoverRatio and backupPool are not set, or all the instances in + the backup pool are unhealthy, the traffic will be directed back to the primary + pool in the "force" mode, where traffic will be spread to the healthy instances + with the best effort, or to all instances when no instance is healthy. + returned: success + type: dict +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +failoverRatio: + description: + - This field is applicable only when the containing target pool is serving a forwarding + rule as the primary pool (i.e., not as a backup pool to some other target pool). + The value of the field must be in [0, 1]. + - 'If set, backupPool must also be set. They together define the fallback behavior + of the primary target pool: if the ratio of the healthy instances in the primary + pool is at or below this number, traffic arriving at the load-balanced IP will + be directed to the backup pool.' + - In case where failoverRatio is not set or all the instances in the backup pool + are unhealthy, the traffic will be directed back to the primary pool in the "force" + mode, where traffic will be spread to the healthy instances with the best effort, + or to all instances when no instance is healthy. + returned: success + type: str +healthCheck: + description: + - A reference to a HttpHealthCheck resource. + - A member instance in this pool is considered healthy if and only if the health + checks pass. If not specified it means all member instances will be considered + healthy at all times. + returned: success + type: dict +id: + description: + - The unique identifier for the resource. + returned: success + type: int +instances: + description: + - A list of virtual machine instances serving this pool. + - They must live in zones contained in the same region as this pool. + returned: success + type: list +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +sessionAffinity: + description: + - 'Session affinity option. Must be one of these values: - NONE: Connections from + the same client IP may go to any instance in the pool.' + - "- CLIENT_IP: Connections from the same client IP will go to the same instance + in the pool while that instance remains healthy." + - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol + will go to the same instance in the pool while that instance remains healthy." + returned: success + type: str +region: + description: + - The region where the target pool resides. + returned: success + type: str ''' ################################################################################ @@ -418,8 +423,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_pool_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_target_pool_facts.py index a738329041..47db627502 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_pool_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_pool_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_pool_facts description: - - Gather facts for GCP TargetPool +- Gather facts for GCP TargetPool short_description: Gather facts for GCP TargetPool version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - The region where the target pool resides. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - The region where the target pool resides. + required: true extends_documentation_fragment: gcp ''' @@ -67,94 +66,94 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - backupPool: - description: - - This field is applicable only when the containing target pool is serving a forwarding - rule as the primary pool, and its failoverRatio field is properly set to a value - between [0, 1]. - - 'backupPool and failoverRatio together define the fallback behavior of the primary - target pool: if the ratio of the healthy instances in the primary pool is at or - below failoverRatio, traffic arriving at the load-balanced IP will be directed to - the backup pool.' - - In case where failoverRatio and backupPool are not set, or all the instances in - the backup pool are unhealthy, the traffic will be directed back to the primary - pool in the "force" mode, where traffic will be spread to the healthy instances - with the best effort, or to all instances when no instance is healthy. - returned: success - type: dict - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - failoverRatio: - description: - - This field is applicable only when the containing target pool is serving a forwarding - rule as the primary pool (i.e., not as a backup pool to some other target pool). - The value of the field must be in [0, 1]. - - 'If set, backupPool must also be set. They together define the fallback behavior - of the primary target pool: if the ratio of the healthy instances in the primary - pool is at or below this number, traffic arriving at the load-balanced IP will be - directed to the backup pool.' - - In case where failoverRatio is not set or all the instances in the backup pool are - unhealthy, the traffic will be directed back to the primary pool in the "force" - mode, where traffic will be spread to the healthy instances with the best effort, - or to all instances when no instance is healthy. - returned: success - type: str - healthCheck: - description: - - A reference to a HttpHealthCheck resource. - - A member instance in this pool is considered healthy if and only if the health checks - pass. If not specified it means all member instances will be considered healthy - at all times. - returned: success - type: dict - id: - description: - - The unique identifier for the resource. - returned: success - type: int - instances: - description: - - A list of virtual machine instances serving this pool. - - They must live in zones contained in the same region as this pool. - returned: success - type: list - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - sessionAffinity: - description: - - 'Session affinity option. Must be one of these values: - NONE: Connections from - the same client IP may go to any instance in the pool.' - - "- CLIENT_IP: Connections from the same client IP will go to the same instance - in the pool while that instance remains healthy." - - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol - will go to the same instance in the pool while that instance remains healthy." - returned: success - type: str - region: - description: - - The region where the target pool resides. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + backupPool: + description: + - This field is applicable only when the containing target pool is serving a + forwarding rule as the primary pool, and its failoverRatio field is properly + set to a value between [0, 1]. + - 'backupPool and failoverRatio together define the fallback behavior of the + primary target pool: if the ratio of the healthy instances in the primary + pool is at or below failoverRatio, traffic arriving at the load-balanced IP + will be directed to the backup pool.' + - In case where failoverRatio and backupPool are not set, or all the instances + in the backup pool are unhealthy, the traffic will be directed back to the + primary pool in the "force" mode, where traffic will be spread to the healthy + instances with the best effort, or to all instances when no instance is healthy. + returned: success + type: dict + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + failoverRatio: + description: + - This field is applicable only when the containing target pool is serving a + forwarding rule as the primary pool (i.e., not as a backup pool to some other + target pool). The value of the field must be in [0, 1]. + - 'If set, backupPool must also be set. They together define the fallback behavior + of the primary target pool: if the ratio of the healthy instances in the primary + pool is at or below this number, traffic arriving at the load-balanced IP + will be directed to the backup pool.' + - In case where failoverRatio is not set or all the instances in the backup + pool are unhealthy, the traffic will be directed back to the primary pool + in the "force" mode, where traffic will be spread to the healthy instances + with the best effort, or to all instances when no instance is healthy. + returned: success + type: str + healthCheck: + description: + - A reference to a HttpHealthCheck resource. + - A member instance in this pool is considered healthy if and only if the health + checks pass. If not specified it means all member instances will be considered + healthy at all times. + returned: success + type: dict + id: + description: + - The unique identifier for the resource. + returned: success + type: int + instances: + description: + - A list of virtual machine instances serving this pool. + - They must live in zones contained in the same region as this pool. + returned: success + type: list + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + sessionAffinity: + description: + - 'Session affinity option. Must be one of these values: - NONE: Connections + from the same client IP may go to any instance in the pool.' + - "- CLIENT_IP: Connections from the same client IP will go to the same instance + in the pool while that instance remains healthy." + - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol + will go to the same instance in the pool while that instance remains healthy." + returned: success + type: str + region: + description: + - The region where the target pool resides. + returned: success + type: str ''' ################################################################################ @@ -176,7 +175,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py index 6c3b0725f3..2a59d7d062 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py @@ -32,53 +32,63 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_ssl_proxy description: - - Represents a TargetSslProxy resource, which is used by one or more global forwarding - rule to route incoming SSL requests to a backend service. +- Represents a TargetSslProxy resource, which is used by one or more global forwarding + rule to route incoming SSL requests to a backend service. short_description: Creates a GCP TargetSslProxy version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - proxy_header: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - required: false - choices: ['NONE', 'PROXY_V1'] - service: - description: - - A reference to the BackendService resource. - required: true - ssl_certificates: - description: - - A list of SslCertificate resources that are used to authenticate connections between - users and the load balancer. Currently, exactly one SSL certificate must be specified. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + proxy_header: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + required: false + choices: + - NONE + - PROXY_V1 + service: + description: + - A reference to the BackendService resource. + - 'This field represents a link to a BackendService resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service + task and then set this service field to "{{ name-of-resource }}" Alternatively, + you can set this service to a dictionary with the selfLink key where the value + is the selfLink of your BackendService' + required: true + ssl_certificates: + description: + - A list of SslCertificate resources that are used to authenticate connections + between users and the load balancer. Currently, exactly one SSL certificate + must be specified. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetSslProxies)" - - "Setting Up SSL proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetSslProxies)' +- 'Setting Up SSL proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/)' ''' EXAMPLES = ''' @@ -164,54 +174,54 @@ EXAMPLES = ''' - "{{ sslcert }}" service: "{{ backendservice }}" project: "test_project" - auth_kind: "service_account" + auth_kind: "serviceaccount" service_account_file: "/tmp/auth.pem" state: present ''' RETURN = ''' - creation_timestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - proxy_header: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - service: - description: - - A reference to the BackendService resource. - returned: success - type: dict - ssl_certificates: - description: - - A list of SslCertificate resources that are used to authenticate connections between - users and the load balancer. Currently, exactly one SSL certificate must be specified. - returned: success - type: list +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str +service: + description: + - A reference to the BackendService resource. + returned: success + type: dict +sslCertificates: + description: + - A list of SslCertificate resources that are used to authenticate connections between + users and the load balancer. Currently, exactly one SSL certificate must be specified. + returned: success + type: list ''' ################################################################################ @@ -253,7 +263,8 @@ def main(): if fetch: if state == 'present': if is_different(module, fetch): - fetch = update(module, self_link(module), kind) + update(module, self_link(module), kind, fetch) + fetch = fetch_resource(module, self_link(module), kind) changed = True else: delete(module, self_link(module), kind) @@ -276,9 +287,58 @@ def create(module, link, kind): return wait_for_operation(module, auth.post(link, resource_to_request(module))) -def update(module, link, kind): +def update(module, link, kind, fetch): + update_fields(module, resource_to_request(module), + response_to_hash(module, fetch)) + return fetch_resource(module, self_link(module), kind) + + +def update_fields(module, request, response): + if response.get('proxyHeader') != request.get('proxyHeader'): + proxy_header_update(module, request, response) + if response.get('service') != request.get('service'): + service_update(module, request, response) + if response.get('sslCertificates') != request.get('sslCertificates'): + ssl_certificates_update(module, request, response) + + +def proxy_header_update(module, request, response): auth = GcpSession(module, 'compute') - return wait_for_operation(module, auth.put(link, resource_to_request(module))) + auth.post( + ''.join([ + "https://www.googleapis.com/compute/v1/", + "projects/{project}/global/targetSslProxies/{name}/setProxyHeader" + ]).format(**module.params), + { + u'proxyHeader': module.params.get('proxy_header') + } + ) + + +def service_update(module, request, response): + auth = GcpSession(module, 'compute') + auth.post( + ''.join([ + "https://www.googleapis.com/compute/v1/", + "projects/{project}/global/targetSslProxies/{name}/setBackendService" + ]).format(**module.params), + { + u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink') + } + ) + + +def ssl_certificates_update(module, request, response): + auth = GcpSession(module, 'compute') + auth.post( + ''.join([ + "https://www.googleapis.com/compute/v1/", + "projects/{project}/global/targetSslProxies/{name}/setSslCertificates" + ]).format(**module.params), + { + u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink') + } + ) def delete(module, link, kind): @@ -303,9 +363,9 @@ def resource_to_request(module): return return_vals -def fetch_resource(module, link, kind): +def fetch_resource(module, link, kind, allow_not_found=True): auth = GcpSession(module, 'compute') - return return_if_object(module, auth.get(link), kind) + return return_if_object(module, auth.get(link), kind, allow_not_found) def self_link(module): @@ -316,9 +376,9 @@ def collection(module): return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies".format(**module.params) -def return_if_object(module, response, kind): +def return_if_object(module, response, kind, allow_not_found=False): # If not found, return nothing. - if response.status_code == 404: + if allow_not_found and response.status_code == 404: return None # If no content, return nothing. @@ -333,8 +393,6 @@ def return_if_object(module, response, kind): if navigate_hash(result, ['error', 'errors']): module.fail_json(msg=navigate_hash(result, ['error', 'errors'])) - if result['kind'] != kind: - module.fail_json(msg="Incorrect result: {kind}".format(**result)) return result @@ -395,8 +453,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_facts.py index 47c4a707ff..a1374d404a 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_ssl_proxy_facts description: - - Gather facts for GCP TargetSslProxy +- Gather facts for GCP TargetSslProxy short_description: Gather facts for GCP TargetSslProxy version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,52 +61,53 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - service: - description: - - A reference to the BackendService resource. - returned: success - type: dict - sslCertificates: - description: - - A list of SslCertificate resources that are used to authenticate connections between - users and the load balancer. Currently, exactly one SSL certificate must be specified. - returned: success - type: list + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str + service: + description: + - A reference to the BackendService resource. + returned: success + type: dict + sslCertificates: + description: + - A list of SslCertificate resources that are used to authenticate connections + between users and the load balancer. Currently, exactly one SSL certificate + must be specified. + returned: success + type: list ''' ################################################################################ @@ -128,7 +128,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py index fe805985a9..d314629399 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py @@ -32,53 +32,57 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_tcp_proxy description: - - Represents a TargetTcpProxy resource, which is used by one or more global forwarding - rule to route incoming TCP requests to a Backend service. +- Represents a TargetTcpProxy resource, which is used by one or more global forwarding + rule to route incoming TCP requests to a Backend service. short_description: Creates a GCP TargetTcpProxy version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - proxy_header: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - required: false - choices: ['NONE', 'PROXY_V1'] - service: - description: - - A reference to the BackendService resource. - - 'This field represents a link to a BackendService resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service - task and then set this service field to "{{ name-of-resource }}" Alternatively, - you can set this service to a dictionary with the selfLink key where the value is - the selfLink of your BackendService.' - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + proxy_header: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + required: false + choices: + - NONE + - PROXY_V1 + service: + description: + - A reference to the BackendService resource. + - 'This field represents a link to a BackendService resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service + task and then set this service field to "{{ name-of-resource }}" Alternatively, + you can set this service to a dictionary with the selfLink key where the value + is the selfLink of your BackendService' + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetTcpProxies)" - - "Setting Up TCP proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/tcp-proxy)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetTcpProxies)' +- 'Setting Up TCP proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/tcp-proxy)' ''' EXAMPLES = ''' @@ -135,42 +139,42 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - service: - description: - - A reference to the BackendService resource. - returned: success - type: dict +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str +service: + description: + - A reference to the BackendService resource. + returned: success + type: dict ''' ################################################################################ @@ -384,8 +388,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_facts.py index 158198ced7..cf6ca10f8d 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_tcp_proxy_facts description: - - Gather facts for GCP TargetTcpProxy +- Gather facts for GCP TargetTcpProxy short_description: Gather facts for GCP TargetTcpProxy version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,46 +61,46 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - proxyHeader: - description: - - Specifies the type of proxy header to append before sending data to the backend, - either NONE or PROXY_V1. The default is NONE. - returned: success - type: str - service: - description: - - A reference to the BackendService resource. - returned: success - type: dict + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + proxyHeader: + description: + - Specifies the type of proxy header to append before sending data to the backend, + either NONE or PROXY_V1. The default is NONE. + returned: success + type: str + service: + description: + - A reference to the BackendService resource. + returned: success + type: dict ''' ################################################################################ @@ -122,7 +121,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py b/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py index 480c2f02ed..d01d144acb 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py @@ -32,50 +32,52 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_vpn_gateway description: - - Represents a VPN gateway running in GCP. This virtual device is managed by Google, - but used only by you. +- Represents a VPN gateway running in GCP. This virtual device is managed by Google, + but used only by you. short_description: Creates a GCP TargetVpnGateway version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - An optional description of this resource. - required: false - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - required: true - network: - description: - - The network this VPN gateway is accepting traffic for. - - 'This field represents a link to a Network resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_network task - and then set this network field to "{{ name-of-resource }}" Alternatively, you can - set this network to a dictionary with the selfLink key where the value is the selfLink - of your Network.' - required: true - region: - description: - - The region this gateway should sit in. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - An optional description of this resource. + required: false + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + network: + description: + - The network this VPN gateway is accepting traffic for. + - 'This field represents a link to a Network resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_network + task and then set this network field to "{{ name-of-resource }}" Alternatively, + you can set this network to a dictionary with the selfLink key where the value + is the selfLink of your Network' + required: true + region: + description: + - The region this gateway should sit in. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/targetVpnGateways)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/targetVpnGateways)' ''' EXAMPLES = ''' @@ -110,51 +112,51 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - network: - description: - - The network this VPN gateway is accepting traffic for. - returned: success - type: dict - tunnels: - description: - - A list of references to VpnTunnel resources associated to this VPN gateway. - returned: success - type: list - forwardingRules: - description: - - A list of references to the ForwardingRule resources associated to this VPN gateway. - returned: success - type: list - region: - description: - - The region this gateway should sit in. - returned: success - type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +network: + description: + - The network this VPN gateway is accepting traffic for. + returned: success + type: dict +tunnels: + description: + - A list of references to VpnTunnel resources associated to this VPN gateway. + returned: success + type: list +forwardingRules: + description: + - A list of references to the ForwardingRule resources associated to this VPN gateway. + returned: success + type: list +region: + description: + - The region this gateway should sit in. + returned: success + type: str ''' ################################################################################ @@ -333,8 +335,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_facts.py index f2d65dca94..2abbdcc6d4 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_target_vpn_gateway_facts description: - - Gather facts for GCP TargetVpnGateway +- Gather facts for GCP TargetVpnGateway short_description: Gather facts for GCP TargetVpnGateway version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - The region this gateway should sit in. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - The region this gateway should sit in. + required: true extends_documentation_fragment: gcp ''' @@ -67,55 +66,56 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - network: - description: - - The network this VPN gateway is accepting traffic for. - returned: success - type: dict - tunnels: - description: - - A list of references to VpnTunnel resources associated to this VPN gateway. - returned: success - type: list - forwardingRules: - description: - - A list of references to the ForwardingRule resources associated to this VPN gateway. - returned: success - type: list - region: - description: - - The region this gateway should sit in. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + network: + description: + - The network this VPN gateway is accepting traffic for. + returned: success + type: dict + tunnels: + description: + - A list of references to VpnTunnel resources associated to this VPN gateway. + returned: success + type: list + forwardingRules: + description: + - A list of references to the ForwardingRule resources associated to this VPN + gateway. + returned: success + type: list + region: + description: + - The region this gateway should sit in. + returned: success + type: str ''' ################################################################################ @@ -137,7 +137,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_url_map.py b/lib/ansible/modules/cloud/google/gcp_compute_url_map.py index 60753392d9..25a549cc0a 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_url_map.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_url_map.py @@ -32,135 +32,141 @@ DOCUMENTATION = ''' --- module: gcp_compute_url_map description: - - UrlMaps are used to route requests to a backend service based on rules that you - define for the host and path of an incoming URL. +- UrlMaps are used to route requests to a backend service based on rules that you + define for the host and path of an incoming URL. short_description: Creates a GCP UrlMap version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - default_service: - description: - - A reference to BackendService resource if none of the hostRules match. - - 'This field represents a link to a BackendService resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service - task and then set this default_service field to "{{ name-of-resource }}" Alternatively, - you can set this default_service to a dictionary with the selfLink key where the - value is the selfLink of your BackendService.' - required: true + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + default_service: + description: + - A reference to BackendService resource if none of the hostRules match. + - 'This field represents a link to a BackendService resource in GCP. It can be + specified in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service + task and then set this default_service field to "{{ name-of-resource }}" Alternatively, + you can set this default_service to a dictionary with the selfLink key where + the value is the selfLink of your BackendService' + required: true + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + required: false + host_rules: + description: + - The list of HostRules to use against the URL. + required: false + suboptions: + description: description: - - An optional description of this resource. Provide this property when you create - the resource. + - An optional description of this HostRule. Provide this property when you + create the resource. required: false - host_rules: + hosts: description: - - The list of HostRules to use against the URL. - required: false - suboptions: - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - required: false - hosts: - description: - - The list of host patterns to match. They must be valid hostnames, except * will - match any string of ([a-z0-9-.]*). In that case, * must be the first character and - must be followed in the pattern by either - or . - required: true - path_matcher: - description: - - The name of the PathMatcher to use to match the path portion of the URL if the hostRule - matches the URL's host portion. - required: true - name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. + - The list of host patterns to match. They must be valid hostnames, except + * will match any string of ([a-z0-9-.]*). In that case, * must be the first + character and must be followed in the pattern by either - or . required: true - path_matchers: + path_matcher: description: - - The list of named PathMatchers to use against the URL. + - The name of the PathMatcher to use to match the path portion of the URL + if the hostRule matches the URL's host portion. + required: true + name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + required: true + path_matchers: + description: + - The list of named PathMatchers to use against the URL. + required: false + suboptions: + default_service: + description: + - A reference to a BackendService resource. This will be used if none of the + pathRules defined by this PathMatcher is matched by the URL's path portion. + - 'This field represents a link to a BackendService resource in GCP. It can + be specified in two ways. You can add `register: name-of-resource` to a + gcp_compute_backend_service task and then set this default_service field + to "{{ name-of-resource }}" Alternatively, you can set this default_service + to a dictionary with the selfLink key where the value is the selfLink of + your BackendService' + required: true + description: + description: + - An optional description of this resource. + required: false + name: + description: + - The name to which this PathMatcher is referred by the HostRule. + required: true + path_rules: + description: + - The list of path rules. required: false suboptions: - default_service: - description: - - A reference to a BackendService resource. This will be used if none of the pathRules - defined by this PathMatcher is matched by the URL's path portion. - - 'This field represents a link to a BackendService resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service - task and then set this default_service field to "{{ name-of-resource }}" Alternatively, - you can set this default_service to a dictionary with the selfLink key where the - value is the selfLink of your BackendService.' - required: true + paths: description: - description: - - An optional description of this resource. - required: false - name: - description: - - The name to which this PathMatcher is referred by the HostRule. - required: true - path_rules: - description: - - The list of path rules. - required: false - suboptions: - paths: - description: - - 'The list of path patterns to match. Each must start with / and the only place a - * is allowed is at the end following a /. The string fed to the path matcher does - not include any text after the first ? or #, and those chars are not allowed here.' - required: false - service: - description: - - A reference to the BackendService resource if this rule is matched. - - 'This field represents a link to a BackendService resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service - task and then set this service field to "{{ name-of-resource }}" Alternatively, - you can set this service to a dictionary with the selfLink key where the value is - the selfLink of your BackendService.' - required: true - tests: + - 'The list of path patterns to match. Each must start with / and the + only place a * is allowed is at the end following a /. The string fed + to the path matcher does not include any text after the first ? or #, + and those chars are not allowed here.' + required: true + service: + description: + - A reference to the BackendService resource if this rule is matched. + - 'This field represents a link to a BackendService resource in GCP. It + can be specified in two ways. You can add `register: name-of-resource` + to a gcp_compute_backend_service task and then set this service field + to "{{ name-of-resource }}" Alternatively, you can set this service + to a dictionary with the selfLink key where the value is the selfLink + of your BackendService' + required: true + tests: + description: + - The list of expected URL mappings. Requests to update this UrlMap will succeed + only if all of the test cases pass. + required: false + suboptions: + description: description: - - The list of expected URL mappings. Request to update this UrlMap will succeed only - if all of the test cases pass. + - Description of this test case. required: false - suboptions: - description: - description: - - Description of this test case. - required: false - host: - description: - - Host portion of the URL. - required: true - path: - description: - - Path portion of the URL. - required: true - service: - description: - - A reference to expected BackendService resource the given URL should be mapped to. - - 'This field represents a link to a BackendService resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_backend_service - task and then set this service field to "{{ name-of-resource }}" Alternatively, - you can set this service to a dictionary with the selfLink key where the value is - the selfLink of your BackendService.' - required: true + host: + description: + - Host portion of the URL. + required: true + path: + description: + - Path portion of the URL. + required: true + service: + description: + - A reference to expected BackendService resource the given URL should be + mapped to. + - 'This field represents a link to a BackendService resource in GCP. It can + be specified in two ways. You can add `register: name-of-resource` to a + gcp_compute_backend_service task and then set this service field to "{{ + name-of-resource }}" Alternatively, you can set this service to a dictionary + with the selfLink key where the value is the selfLink of your BackendService' + required: true extends_documentation_fragment: gcp ''' @@ -213,135 +219,137 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - defaultService: - description: - - A reference to BackendService resource if none of the hostRules match. - returned: success - type: dict +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +defaultService: + description: + - A reference to BackendService resource if none of the hostRules match. + returned: success + type: dict +description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str +hostRules: + description: + - The list of HostRules to use against the URL. + returned: success + type: complex + contains: description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - hostRules: - description: - - The list of HostRules to use against the URL. - returned: success - type: complex - contains: - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - hosts: - description: - - The list of host patterns to match. They must be valid hostnames, except * will - match any string of ([a-z0-9-.]*). In that case, * must be the first character and - must be followed in the pattern by either - or . - returned: success - type: list - pathMatcher: - description: - - The name of the PathMatcher to use to match the path portion of the URL if the hostRule - matches the URL's host portion. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - fingerprint: - description: - - Fingerprint of this resource. This field is used internally during updates of this - resource. - returned: success - type: str + description: + - An optional description of this HostRule. Provide this property when you create + the resource. + returned: success + type: str + hosts: + description: + - The list of host patterns to match. They must be valid hostnames, except * + will match any string of ([a-z0-9-.]*). In that case, * must be the first + character and must be followed in the pattern by either - or . + returned: success + type: list + pathMatcher: + description: + - The name of the PathMatcher to use to match the path portion of the URL if + the hostRule matches the URL's host portion. + returned: success + type: str +id: + description: + - The unique identifier for the resource. + returned: success + type: int +fingerprint: + description: + - Fingerprint of this resource. This field is used internally during updates of + this resource. + returned: success + type: str +name: + description: + - Name of the resource. Provided by the client when the resource is created. The + name must be 1-63 characters long, and comply with RFC1035. Specifically, the + name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str +pathMatchers: + description: + - The list of named PathMatchers to use against the URL. + returned: success + type: complex + contains: + defaultService: + description: + - A reference to a BackendService resource. This will be used if none of the + pathRules defined by this PathMatcher is matched by the URL's path portion. + returned: success + type: dict + description: + description: + - An optional description of this resource. + returned: success + type: str name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - pathMatchers: - description: - - The list of named PathMatchers to use against the URL. - returned: success - type: complex - contains: - defaultService: - description: - - A reference to a BackendService resource. This will be used if none of the pathRules - defined by this PathMatcher is matched by the URL's path portion. - returned: success - type: dict - description: - description: - - An optional description of this resource. - returned: success - type: str - name: - description: - - The name to which this PathMatcher is referred by the HostRule. - returned: success - type: str - pathRules: - description: - - The list of path rules. - returned: success - type: complex - contains: - paths: - description: - - 'The list of path patterns to match. Each must start with / and the only place a - * is allowed is at the end following a /. The string fed to the path matcher does - not include any text after the first ? or #, and those chars are not allowed here.' - returned: success - type: list - service: - description: - - A reference to the BackendService resource if this rule is matched. - returned: success - type: dict - tests: - description: - - The list of expected URL mappings. Request to update this UrlMap will succeed only - if all of the test cases pass. - returned: success - type: complex - contains: - description: - description: - - Description of this test case. - returned: success - type: str - host: - description: - - Host portion of the URL. - returned: success - type: str - path: - description: - - Path portion of the URL. - returned: success - type: str - service: - description: - - A reference to expected BackendService resource the given URL should be mapped to. - returned: success - type: dict + description: + - The name to which this PathMatcher is referred by the HostRule. + returned: success + type: str + pathRules: + description: + - The list of path rules. + returned: success + type: complex + contains: + paths: + description: + - 'The list of path patterns to match. Each must start with / and the only + place a * is allowed is at the end following a /. The string fed to the + path matcher does not include any text after the first ? or #, and those + chars are not allowed here.' + returned: success + type: list + service: + description: + - A reference to the BackendService resource if this rule is matched. + returned: success + type: dict +tests: + description: + - The list of expected URL mappings. Requests to update this UrlMap will succeed + only if all of the test cases pass. + returned: success + type: complex + contains: + description: + description: + - Description of this test case. + returned: success + type: str + host: + description: + - Host portion of the URL. + returned: success + type: str + path: + description: + - Path portion of the URL. + returned: success + type: str + service: + description: + - A reference to expected BackendService resource the given URL should be mapped + to. + returned: success + type: dict ''' ################################################################################ @@ -376,7 +384,7 @@ def main(): description=dict(type='str'), name=dict(required=True, type='str'), path_rules=dict(type='list', elements='dict', options=dict( - paths=dict(type='list', elements='str'), + paths=dict(required=True, type='list', elements='str'), service=dict(required=True, type='dict') )) )), @@ -440,9 +448,9 @@ def resource_to_request(module): u'kind': 'compute#urlMap', u'defaultService': replace_resource_dict(module.params.get(u'default_service', {}), 'selfLink'), u'description': module.params.get('description'), - u'hostRules': UrlMapHostRulesArray(module.params.get('host_rules', []), module).to_request(), + u'hostRules': UrlMapHostrulesArray(module.params.get('host_rules', []), module).to_request(), u'name': module.params.get('name'), - u'pathMatchers': UrlMapPathMatchersArray(module.params.get('path_matchers', []), module).to_request(), + u'pathMatchers': UrlMapPathmatchersArray(module.params.get('path_matchers', []), module).to_request(), u'tests': UrlMapTestsArray(module.params.get('tests', []), module).to_request() } return_vals = {} @@ -512,11 +520,11 @@ def response_to_hash(module, response): u'creationTimestamp': response.get(u'creationTimestamp'), u'defaultService': response.get(u'defaultService'), u'description': response.get(u'description'), - u'hostRules': UrlMapHostRulesArray(response.get(u'hostRules', []), module).from_response(), + u'hostRules': UrlMapHostrulesArray(response.get(u'hostRules', []), module).from_response(), u'id': response.get(u'id'), u'fingerprint': response.get(u'fingerprint'), u'name': module.params.get('name'), - u'pathMatchers': UrlMapPathMatchersArray(response.get(u'pathMatchers', []), module).from_response(), + u'pathMatchers': UrlMapPathmatchersArray(response.get(u'pathMatchers', []), module).from_response(), u'tests': UrlMapTestsArray(response.get(u'tests', []), module).from_response() } @@ -545,8 +553,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -558,7 +564,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class UrlMapHostRulesArray(object): +class UrlMapHostrulesArray(object): def __init__(self, request, module): self.module = module if request: @@ -593,7 +599,7 @@ class UrlMapHostRulesArray(object): }) -class UrlMapPathMatchersArray(object): +class UrlMapPathmatchersArray(object): def __init__(self, request, module): self.module = module if request: @@ -618,7 +624,7 @@ class UrlMapPathMatchersArray(object): u'defaultService': replace_resource_dict(item.get(u'default_service', {}), 'selfLink'), u'description': item.get('description'), u'name': item.get('name'), - u'pathRules': UrlMapPathRulesArray(item.get('path_rules', []), self.module).to_request() + u'pathRules': UrlMapPathrulesArray(item.get('path_rules', []), self.module).to_request() }) def _response_from_item(self, item): @@ -626,11 +632,11 @@ class UrlMapPathMatchersArray(object): u'defaultService': item.get(u'defaultService'), u'description': item.get(u'description'), u'name': item.get(u'name'), - u'pathRules': UrlMapPathRulesArray(item.get(u'pathRules', []), self.module).from_response() + u'pathRules': UrlMapPathrulesArray(item.get(u'pathRules', []), self.module).from_response() }) -class UrlMapPathRulesArray(object): +class UrlMapPathrulesArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_url_map_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_url_map_facts.py index 55d114e58c..9c9d6c5f3c 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_url_map_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_url_map_facts.py @@ -32,21 +32,20 @@ DOCUMENTATION = ''' --- module: gcp_compute_url_map_facts description: - - Gather facts for GCP UrlMap +- Gather facts for GCP UrlMap short_description: Gather facts for GCP UrlMap version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . extends_documentation_fragment: gcp ''' @@ -62,139 +61,142 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - defaultService: - description: - - A reference to BackendService resource if none of the hostRules match. - returned: success - type: dict + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + defaultService: + description: + - A reference to BackendService resource if none of the hostRules match. + returned: success + type: dict + description: + description: + - An optional description of this resource. Provide this property when you create + the resource. + returned: success + type: str + hostRules: + description: + - The list of HostRules to use against the URL. + returned: success + type: complex + contains: description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - hostRules: - description: - - The list of HostRules to use against the URL. - returned: success - type: complex - contains: - description: - description: - - An optional description of this resource. Provide this property when you create - the resource. - returned: success - type: str - hosts: - description: - - The list of host patterns to match. They must be valid hostnames, except * will - match any string of ([a-z0-9-.]*). In that case, * must be the first character and - must be followed in the pattern by either - or . - returned: success - type: list - pathMatcher: - description: - - The name of the PathMatcher to use to match the path portion of the URL if the hostRule - matches the URL's host portion. - returned: success - type: str - id: - description: - - The unique identifier for the resource. - returned: success - type: int - fingerprint: - description: - - Fingerprint of this resource. This field is used internally during updates of this - resource. - returned: success - type: str + description: + - An optional description of this HostRule. Provide this property when you + create the resource. + returned: success + type: str + hosts: + description: + - The list of host patterns to match. They must be valid hostnames, except + * will match any string of ([a-z0-9-.]*). In that case, * must be the + first character and must be followed in the pattern by either - or . + returned: success + type: list + pathMatcher: + description: + - The name of the PathMatcher to use to match the path portion of the URL + if the hostRule matches the URL's host portion. + returned: success + type: str + id: + description: + - The unique identifier for the resource. + returned: success + type: int + fingerprint: + description: + - Fingerprint of this resource. This field is used internally during updates + of this resource. + returned: success + type: str + name: + description: + - Name of the resource. Provided by the client when the resource is created. + The name must be 1-63 characters long, and comply with RFC1035. Specifically, + the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` + which means the first character must be a lowercase letter, and all following + characters must be a dash, lowercase letter, or digit, except the last character, + which cannot be a dash. + returned: success + type: str + pathMatchers: + description: + - The list of named PathMatchers to use against the URL. + returned: success + type: complex + contains: + defaultService: + description: + - A reference to a BackendService resource. This will be used if none of + the pathRules defined by this PathMatcher is matched by the URL's path + portion. + returned: success + type: dict + description: + description: + - An optional description of this resource. + returned: success + type: str name: - description: - - Name of the resource. Provided by the client when the resource is created. The name - must be 1-63 characters long, and comply with RFC1035. Specifically, the name must - be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` - which means the first character must be a lowercase letter, and all following characters - must be a dash, lowercase letter, or digit, except the last character, which cannot - be a dash. - returned: success - type: str - pathMatchers: - description: - - The list of named PathMatchers to use against the URL. - returned: success - type: complex - contains: - defaultService: - description: - - A reference to a BackendService resource. This will be used if none of the pathRules - defined by this PathMatcher is matched by the URL's path portion. - returned: success - type: dict - description: - description: - - An optional description of this resource. - returned: success - type: str - name: - description: - - The name to which this PathMatcher is referred by the HostRule. - returned: success - type: str - pathRules: - description: - - The list of path rules. - returned: success - type: complex - contains: - paths: - description: - - 'The list of path patterns to match. Each must start with / and the only place a - * is allowed is at the end following a /. The string fed to the path matcher does - not include any text after the first ? or #, and those chars are not allowed here.' - returned: success - type: list - service: - description: - - A reference to the BackendService resource if this rule is matched. - returned: success - type: dict - tests: - description: - - The list of expected URL mappings. Request to update this UrlMap will succeed only - if all of the test cases pass. - returned: success - type: complex - contains: - description: - description: - - Description of this test case. - returned: success - type: str - host: - description: - - Host portion of the URL. - returned: success - type: str - path: - description: - - Path portion of the URL. - returned: success - type: str - service: - description: - - A reference to expected BackendService resource the given URL should be mapped to. - returned: success - type: dict + description: + - The name to which this PathMatcher is referred by the HostRule. + returned: success + type: str + pathRules: + description: + - The list of path rules. + returned: success + type: complex + contains: + paths: + description: + - 'The list of path patterns to match. Each must start with / and the + only place a * is allowed is at the end following a /. The string + fed to the path matcher does not include any text after the first + ? or #, and those chars are not allowed here.' + returned: success + type: list + service: + description: + - A reference to the BackendService resource if this rule is matched. + returned: success + type: dict + tests: + description: + - The list of expected URL mappings. Requests to update this UrlMap will succeed + only if all of the test cases pass. + returned: success + type: complex + contains: + description: + description: + - Description of this test case. + returned: success + type: str + host: + description: + - Host portion of the URL. + returned: success + type: str + path: + description: + - Path portion of the URL. + returned: success + type: str + service: + description: + - A reference to expected BackendService resource the given URL should be + mapped to. + returned: success + type: dict ''' ################################################################################ @@ -215,7 +217,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py b/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py index 1a5ea665d0..b5ae722db1 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py @@ -32,92 +32,94 @@ DOCUMENTATION = ''' --- module: gcp_compute_vpn_tunnel description: - - VPN tunnel resource. +- VPN tunnel resource. short_description: Creates a GCP VpnTunnel version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - required: true + state: description: - description: - - An optional description of this resource. - required: false - target_vpn_gateway: - description: - - URL of the Target VPN gateway with which this VPN tunnel is associated. - - 'This field represents a link to a TargetVpnGateway resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_compute_target_vpn_gateway - task and then set this target_vpn_gateway field to "{{ name-of-resource }}" Alternatively, - you can set this target_vpn_gateway to a dictionary with the selfLink key where - the value is the selfLink of your TargetVpnGateway.' - required: true - router: - description: - - URL of router resource to be used for dynamic routing. - - 'This field represents a link to a Router resource in GCP. It can be specified in - two ways. You can add `register: name-of-resource` to a gcp_compute_router task - and then set this router field to "{{ name-of-resource }}" Alternatively, you can - set this router to a dictionary with the selfLink key where the value is the selfLink - of your Router.' - required: false - peer_ip: - description: - - IP address of the peer VPN gateway. Only IPv4 is supported. - required: true - shared_secret: - description: - - Shared secret used to set the secure session between the Cloud VPN gateway and the - peer VPN gateway. - required: true - ike_version: - description: - - IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway. - - Acceptable IKE versions are 1 or 2. Default version is 2. - required: false - default: 2 - local_traffic_selector: - description: - - Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway. - The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges - should be disjoint. - - Only IPv4 is supported. - required: false - remote_traffic_selector: - description: - - Remote traffic selector to use when establishing the VPN tunnel with peer VPN gateway. - The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges - should be disjoint. - - Only IPv4 is supported. - required: false - labels: - description: - - Labels to apply to this VpnTunnel. - required: false - region: - description: - - The region where the tunnel is located. - required: true + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match the regular + expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must + be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + required: true + description: + description: + - An optional description of this resource. + required: false + target_vpn_gateway: + description: + - URL of the Target VPN gateway with which this VPN tunnel is associated. + - 'This field represents a link to a TargetVpnGateway resource in GCP. It can + be specified in two ways. You can add `register: name-of-resource` to a gcp_compute_target_vpn_gateway + task and then set this target_vpn_gateway field to "{{ name-of-resource }}" + Alternatively, you can set this target_vpn_gateway to a dictionary with the + selfLink key where the value is the selfLink of your TargetVpnGateway' + required: true + router: + description: + - URL of router resource to be used for dynamic routing. + - 'This field represents a link to a Router resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_compute_router + task and then set this router field to "{{ name-of-resource }}" Alternatively, + you can set this router to a dictionary with the selfLink key where the value + is the selfLink of your Router' + required: false + peer_ip: + description: + - IP address of the peer VPN gateway. Only IPv4 is supported. + required: true + shared_secret: + description: + - Shared secret used to set the secure session between the Cloud VPN gateway and + the peer VPN gateway. + required: true + ike_version: + description: + - IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway. + - Acceptable IKE versions are 1 or 2. Default version is 2. + required: false + default: '2' + local_traffic_selector: + description: + - Local traffic selector to use when establishing the VPN tunnel with peer VPN + gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`. + The ranges should be disjoint. + - Only IPv4 is supported. + required: false + remote_traffic_selector: + description: + - Remote traffic selector to use when establishing the VPN tunnel with peer VPN + gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`. + The ranges should be disjoint. + - Only IPv4 is supported. + required: false + labels: + description: + - Labels to apply to this VpnTunnel. + required: false + region: + description: + - The region where the tunnel is located. + required: true extends_documentation_fragment: gcp notes: - - "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/vpnTunnels)" - - "Cloud VPN Overview: U(https://cloud.google.com/vpn/docs/concepts/overview)" - - "Networks and Tunnel Routing: U(https://cloud.google.com/vpn/docs/concepts/choosing-networks-routing)" +- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/vpnTunnels)' +- 'Cloud VPN Overview: U(https://cloud.google.com/vpn/docs/concepts/overview)' +- 'Networks and Tunnel Routing: U(https://cloud.google.com/vpn/docs/concepts/choosing-networks-routing)' ''' EXAMPLES = ''' @@ -174,89 +176,89 @@ EXAMPLES = ''' ''' RETURN = ''' - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - targetVpnGateway: - description: - - URL of the Target VPN gateway with which this VPN tunnel is associated. - returned: success - type: dict - router: - description: - - URL of router resource to be used for dynamic routing. - returned: success - type: dict - peerIp: - description: - - IP address of the peer VPN gateway. Only IPv4 is supported. - returned: success - type: str - sharedSecret: - description: - - Shared secret used to set the secure session between the Cloud VPN gateway and the - peer VPN gateway. - returned: success - type: str - sharedSecretHash: - description: - - Hash of the shared secret. - returned: success - type: str - ikeVersion: - description: - - IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway. - - Acceptable IKE versions are 1 or 2. Default version is 2. - returned: success - type: int - localTrafficSelector: - description: - - Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway. - The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges - should be disjoint. - - Only IPv4 is supported. - returned: success - type: list - remoteTrafficSelector: - description: - - Remote traffic selector to use when establishing the VPN tunnel with peer VPN gateway. - The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges - should be disjoint. - - Only IPv4 is supported. - returned: success - type: list - labels: - description: - - Labels to apply to this VpnTunnel. - returned: success - type: dict - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - region: - description: - - The region where the tunnel is located. - returned: success - type: str +creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str +name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. + Specifically, the name must be 1-63 characters long and match the regular expression + `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase + letter, and all following characters must be a dash, lowercase letter, or digit, + except the last character, which cannot be a dash. + returned: success + type: str +description: + description: + - An optional description of this resource. + returned: success + type: str +targetVpnGateway: + description: + - URL of the Target VPN gateway with which this VPN tunnel is associated. + returned: success + type: dict +router: + description: + - URL of router resource to be used for dynamic routing. + returned: success + type: dict +peerIp: + description: + - IP address of the peer VPN gateway. Only IPv4 is supported. + returned: success + type: str +sharedSecret: + description: + - Shared secret used to set the secure session between the Cloud VPN gateway and + the peer VPN gateway. + returned: success + type: str +sharedSecretHash: + description: + - Hash of the shared secret. + returned: success + type: str +ikeVersion: + description: + - IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway. + - Acceptable IKE versions are 1 or 2. Default version is 2. + returned: success + type: int +localTrafficSelector: + description: + - Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway. + The value should be a CIDR formatted string, for example `192.168.0.0/16`. The + ranges should be disjoint. + - Only IPv4 is supported. + returned: success + type: list +remoteTrafficSelector: + description: + - Remote traffic selector to use when establishing the VPN tunnel with peer VPN + gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`. + The ranges should be disjoint. + - Only IPv4 is supported. + returned: success + type: list +labels: + description: + - Labels to apply to this VpnTunnel. + returned: success + type: dict +labelFingerprint: + description: + - The fingerprint used for optimistic locking of this resource. Used internally + during updates. + returned: success + type: str +region: + description: + - The region where the tunnel is located. + returned: success + type: str ''' ################################################################################ @@ -477,8 +479,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'compute#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_facts.py b/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_facts.py index f1f479205d..0141d1a82f 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_facts.py @@ -32,25 +32,24 @@ DOCUMENTATION = ''' --- module: gcp_compute_vpn_tunnel_facts description: - - Gather facts for GCP VpnTunnel +- Gather facts for GCP VpnTunnel short_description: Gather facts for GCP VpnTunnel version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - filters: - description: - A list of filter value pairs. Available filters are listed here - U(https://cloud.google.com/sdk/gcloud/reference/topic/filters). - Each additional filter in the list will act be added as an AND condition - (filter1 and filter2) - region: - description: - - The region where the tunnel is located. - required: true + filters: + description: + - A list of filter value pairs. Available filters are listed here U(U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).) + - Each additional filter in the list will act be added as an AND condition (filter1 + and filter2) . + region: + description: + - The region where the tunnel is located. + required: true extends_documentation_fragment: gcp ''' @@ -67,93 +66,94 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - creationTimestamp: - description: - - Creation timestamp in RFC3339 text format. - returned: success - type: str - name: - description: - - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035. - Specifically, the name must be 1-63 characters long and match the regular expression - `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase - letter, and all following characters must be a dash, lowercase letter, or digit, - except the last character, which cannot be a dash. - returned: success - type: str - description: - description: - - An optional description of this resource. - returned: success - type: str - targetVpnGateway: - description: - - URL of the Target VPN gateway with which this VPN tunnel is associated. - returned: success - type: dict - router: - description: - - URL of router resource to be used for dynamic routing. - returned: success - type: dict - peerIp: - description: - - IP address of the peer VPN gateway. Only IPv4 is supported. - returned: success - type: str - sharedSecret: - description: - - Shared secret used to set the secure session between the Cloud VPN gateway and the - peer VPN gateway. - returned: success - type: str - sharedSecretHash: - description: - - Hash of the shared secret. - returned: success - type: str - ikeVersion: - description: - - IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway. - - Acceptable IKE versions are 1 or 2. Default version is 2. - returned: success - type: int - localTrafficSelector: - description: - - Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway. - The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges - should be disjoint. - - Only IPv4 is supported. - returned: success - type: list - remoteTrafficSelector: - description: - - Remote traffic selector to use when establishing the VPN tunnel with peer VPN gateway. - The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges - should be disjoint. - - Only IPv4 is supported. - returned: success - type: list - labels: - description: - - Labels to apply to this VpnTunnel. - returned: success - type: dict - labelFingerprint: - description: - - The fingerprint used for optimistic locking of this resource. Used internally during - updates. - returned: success - type: str - region: - description: - - The region where the tunnel is located. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + creationTimestamp: + description: + - Creation timestamp in RFC3339 text format. + returned: success + type: str + name: + description: + - Name of the resource. The name must be 1-63 characters long, and comply with + RFC1035. Specifically, the name must be 1-63 characters long and match the + regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character + must be a lowercase letter, and all following characters must be a dash, lowercase + letter, or digit, except the last character, which cannot be a dash. + returned: success + type: str + description: + description: + - An optional description of this resource. + returned: success + type: str + targetVpnGateway: + description: + - URL of the Target VPN gateway with which this VPN tunnel is associated. + returned: success + type: dict + router: + description: + - URL of router resource to be used for dynamic routing. + returned: success + type: dict + peerIp: + description: + - IP address of the peer VPN gateway. Only IPv4 is supported. + returned: success + type: str + sharedSecret: + description: + - Shared secret used to set the secure session between the Cloud VPN gateway + and the peer VPN gateway. + returned: success + type: str + sharedSecretHash: + description: + - Hash of the shared secret. + returned: success + type: str + ikeVersion: + description: + - IKE protocol version to use when establishing the VPN tunnel with peer VPN + gateway. + - Acceptable IKE versions are 1 or 2. Default version is 2. + returned: success + type: int + localTrafficSelector: + description: + - Local traffic selector to use when establishing the VPN tunnel with peer VPN + gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`. + The ranges should be disjoint. + - Only IPv4 is supported. + returned: success + type: list + remoteTrafficSelector: + description: + - Remote traffic selector to use when establishing the VPN tunnel with peer + VPN gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`. + The ranges should be disjoint. + - Only IPv4 is supported. + returned: success + type: list + labels: + description: + - Labels to apply to this VpnTunnel. + returned: success + type: dict + labelFingerprint: + description: + - The fingerprint used for optimistic locking of this resource. Used internally + during updates. + returned: success + type: str + region: + description: + - The region where the tunnel is located. + returned: success + type: str ''' ################################################################################ @@ -175,7 +175,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/compute'] items = fetch_list(module, collection(module), query_options(module.params['filters'])) diff --git a/lib/ansible/modules/cloud/google/gcp_container_cluster.py b/lib/ansible/modules/cloud/google/gcp_container_cluster.py index d0677315eb..5555ea5880 100644 --- a/lib/ansible/modules/cloud/google/gcp_container_cluster.py +++ b/lib/ansible/modules/cloud/google/gcp_container_cluster.py @@ -32,233 +32,245 @@ DOCUMENTATION = ''' --- module: gcp_container_cluster description: - - A Google Container Engine cluster. +- A Google Container Engine cluster. short_description: Creates a GCP Cluster version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - The name of this cluster. The name must be unique within this project and zone, - and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens - only. Must start with a letter. Must end with a number or a letter. - required: false + state: description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - The name of this cluster. The name must be unique within this project and zone, + and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens + only. Must start with a letter. Must end with a number or a letter. + required: false + description: + description: + - An optional description of this cluster. + required: false + initial_node_count: + description: + - The number of nodes to create in this cluster. You must ensure that your Compute + Engine resource quota is sufficient for this number of instances. You must also + have available firewall and routes quota. For requests, this field should only + be used in lieu of a "nodePool" object, since this configuration (along with + the "nodeConfig") will be used to create a "NodePool" object with an auto-generated + name. Do not use this and a nodePool at the same time. + required: true + node_config: + description: + - Parameters used in creating the cluster's nodes. + - For requests, this field should only be used in lieu of a "nodePool" object, + since this configuration (along with the "initialNodeCount") will be used to + create a "NodePool" object with an auto-generated name. Do not use this and + a nodePool at the same time. For responses, this field will be populated with + the node configuration of the first node pool. If unspecified, the defaults + are used. + required: false + suboptions: + machine_type: description: - - An optional description of this cluster. + - The name of a Google Compute Engine machine type (e.g. + - n1-standard-1). If unspecified, the default machine type is n1-standard-1. required: false - initial_node_count: + disk_size_gb: description: - - The number of nodes to create in this cluster. You must ensure that your Compute - Engine resource quota is sufficient for this number of instances. You must also - have available firewall and routes quota. For requests, this field should only be - used in lieu of a "nodePool" object, since this configuration (along with the "nodeConfig") - will be used to create a "NodePool" object with an auto-generated name. Do not use - this and a nodePool at the same time. - required: true - node_config: + - Size of the disk attached to each node, specified in GB. The smallest allowed + disk size is 10GB. If unspecified, the default disk size is 100GB. + required: false + oauth_scopes: description: - - Parameters used in creating the cluster's nodes. - - For requests, this field should only be used in lieu of a "nodePool" object, since - this configuration (along with the "initialNodeCount") will be used to create a - "NodePool" object with an auto-generated name. Do not use this and a nodePool at - the same time. For responses, this field will be populated with the node configuration - of the first node pool. If unspecified, the defaults are used. + - The set of Google API scopes to be made available on all of the node VMs + under the "default" service account. + - 'The following scopes are recommended, but not required, and by default + are not included: U(https://www.googleapis.com/auth/compute) is required + for mounting persistent storage on your nodes.' + - U(https://www.googleapis.com/auth/devstorage.read_only) is required for + communicating with gcr.io (the Google Container Registry). + - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring + are enabled, in which case their required scopes will be added. + required: false + service_account: + description: + - The Google Cloud Platform Service Account to be used by the node VMs. If + no Service Account is specified, the "default" service account is used. + required: false + metadata: + description: + - The metadata key/value pairs assigned to instances in the cluster. + - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes + in length. These are reflected as part of a URL in the metadata server. + Additionally, to avoid ambiguity, keys must not conflict with any other + metadata keys for the project or be one of the four reserved keys: "instance-template", + "kube-env", "startup-script", and "user-data" Values are free-form strings, + and only have meaning as interpreted by the image running in the instance. + The only restriction placed on them is that each value''s size must be less + than or equal to 32 KB.' + - The total size of all keys and values must be less than 512 KB. + - 'An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + required: false + image_type: + description: + - The image type to use for this node. Note that for a given image type, the + latest version of it will be used. + required: false + labels: + description: + - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. + These will added in addition to any default label(s) that Kubernetes may + apply to the node. In case of conflict in label keys, the applied set may + differ depending on the Kubernetes version -- it''s best to assume the behavior + is undefined and conflicts should be avoided. For more information, including + usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) + An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + required: false + local_ssd_count: + description: + - The number of local SSD disks to be attached to the node. + - 'The limit for this value is dependant upon the maximum number of disks + available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) + for more information.' + required: false + tags: + description: + - The list of instance tags applied to all nodes. Tags are used to identify + valid sources or targets for network firewalls and are specified by the + client during cluster or node pool creation. Each tag within the list must + comply with RFC1035. + required: false + preemptible: + description: + - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) + for more inforamtion about preemptible VM instances.' + required: false + type: bool + master_auth: + description: + - The authentication information for accessing the master endpoint. + required: false + suboptions: + username: + description: + - The username to use for HTTP basic authentication to the master endpoint. + required: false + password: + description: + - The password to use for HTTP basic authentication to the master endpoint. + Because the master endpoint is open to the Internet, you should create a + strong password. + required: false + cluster_ca_certificate: + description: + - Base64-encoded public certificate that is the root of trust for the cluster. + required: false + client_certificate: + description: + - Base64-encoded public certificate used by clients to authenticate to the + cluster endpoint. + required: false + client_key: + description: + - Base64-encoded private key used by clients to authenticate to the cluster + endpoint. + required: false + logging_service: + description: + - 'The logging service the cluster should use to write logs. Currently available + options: logging.googleapis.com - the Google Cloud Logging service.' + - none - no logs will be exported from the cluster. + - if left as an empty string,logging.googleapis.com will be used. + required: false + choices: + - logging.googleapis.com + - none + monitoring_service: + description: + - The monitoring service the cluster should use to write metrics. + - 'Currently available options: monitoring.googleapis.com - the Google Cloud Monitoring + service.' + - none - no metrics will be exported from the cluster. + - if left as an empty string, monitoring.googleapis.com will be used. + required: false + choices: + - monitoring.googleapis.com + - none + network: + description: + - The name of the Google Compute Engine network to which the cluster is connected. + If left unspecified, the default network will be used. + - To ensure it exists and it is operations, configure the network using 'gcompute_network' + resource. + required: false + cluster_ipv4_cidr: + description: + - The IP address range of the container pods in this cluster, in CIDR notation + (e.g. 10.96.0.0/14). Leave blank to have one automatically chosen or specify + a /14 block in 10.0.0.0/8. + required: false + addons_config: + description: + - Configurations for the various addons available to run in the cluster. + required: false + suboptions: + http_load_balancing: + description: + - Configuration for the HTTP (L7) load balancing controller addon, which makes + it easy to set up HTTP load balancers for services in a cluster. required: false suboptions: - machine_type: - description: - - The name of a Google Compute Engine machine type (e.g. - - n1-standard-1). If unspecified, the default machine type is n1-standard-1. - required: false - disk_size_gb: - description: - - Size of the disk attached to each node, specified in GB. The smallest allowed disk - size is 10GB. If unspecified, the default disk size is 100GB. - required: false - oauth_scopes: - description: - - The set of Google API scopes to be made available on all of the node VMs under the - "default" service account. - - 'The following scopes are recommended, but not required, and by default are not - included: U(https://www.googleapis.com/auth/compute) is required for mounting persistent - storage on your nodes.' - - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating - with gcr.io (the Google Container Registry). - - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are - enabled, in which case their required scopes will be added. - required: false - service_account: - description: - - The Google Cloud Platform Service Account to be used by the node VMs. If no Service - Account is specified, the "default" service account is used. - required: false - metadata: - description: - - The metadata key/value pairs assigned to instances in the cluster. - - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length. - These are reflected as part of a URL in the metadata server. Additionally, to avoid - ambiguity, keys must not conflict with any other metadata keys for the project or - be one of the four reserved keys: "instance-template", "kube-env", "startup-script", - and "user-data" Values are free-form strings, and only have meaning as interpreted - by the image running in the instance. The only restriction placed on them is that - each value''s size must be less than or equal to 32 KB.' - - The total size of all keys and values must be less than 512 KB. - - 'An object containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - required: false - image_type: - description: - - The image type to use for this node. Note that for a given image type, the latest - version of it will be used. - required: false - labels: - description: - - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. - These will added in addition to any default label(s) that Kubernetes may apply to - the node. In case of conflict in label keys, the applied set may differ depending - on the Kubernetes version -- it''s best to assume the behavior is undefined and - conflicts should be avoided. For more information, including usage and the valid - values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object - containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - required: false - local_ssd_count: - description: - - The number of local SSD disks to be attached to the node. - - 'The limit for this value is dependant upon the maximum number of disks available - on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) for - more information.' - required: false - tags: - description: - - The list of instance tags applied to all nodes. Tags are used to identify valid - sources or targets for network firewalls and are specified by the client during - cluster or node pool creation. Each tag within the list must comply with RFC1035. - required: false - preemptible: - description: - - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) - for more inforamtion about preemptible VM instances.' - required: false - type: bool - master_auth: + disabled: + description: + - Whether the HTTP Load Balancing controller is enabled in the cluster. + When enabled, it runs a small pod in the cluster that manages the load + balancers. + required: false + type: bool + horizontal_pod_autoscaling: description: - - The authentication information for accessing the master endpoint. + - Configuration for the horizontal pod autoscaling feature, which increases + or decreases the number of replica pods a replication controller has based + on the resource usage of the existing pods. required: false suboptions: - username: - description: - - The username to use for HTTP basic authentication to the master endpoint. - required: false - password: - description: - - The password to use for HTTP basic authentication to the master endpoint. Because - the master endpoint is open to the Internet, you should create a strong password. - required: false - cluster_ca_certificate: - description: - - Base64-encoded public certificate that is the root of trust for the cluster. - required: false - client_certificate: - description: - - Base64-encoded public certificate used by clients to authenticate to the cluster - endpoint. - required: false - client_key: - description: - - Base64-encoded private key used by clients to authenticate to the cluster endpoint. - required: false - logging_service: - description: - - 'The logging service the cluster should use to write logs. Currently available options: logging.googleapis.com - - the Google Cloud Logging service.' - - none - no logs will be exported from the cluster. - - if left as an empty string,logging.googleapis.com will be used. - required: false - choices: ['logging.googleapis.com', 'none'] - monitoring_service: - description: - - The monitoring service the cluster should use to write metrics. - - 'Currently available options: monitoring.googleapis.com - the Google Cloud Monitoring - service.' - - none - no metrics will be exported from the cluster. - - if left as an empty string, monitoring.googleapis.com will be used. - required: false - choices: ['monitoring.googleapis.com', 'none'] - network: - description: - - The name of the Google Compute Engine network to which the cluster is connected. - If left unspecified, the default network will be used. - - To ensure it exists and it is operations, configure the network using 'gcompute_network' - resource. - required: false - cluster_ipv4_cidr: - description: - - The IP address range of the container pods in this cluster, in CIDR notation (e.g. - 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block - in 10.0.0.0/8. - required: false - addons_config: - description: - - Configurations for the various addons available to run in the cluster. - required: false - suboptions: - http_load_balancing: - description: - - Configuration for the HTTP (L7) load balancing controller addon, which makes it - easy to set up HTTP load balancers for services in a cluster. - required: false - suboptions: - disabled: - description: - - Whether the HTTP Load Balancing controller is enabled in the cluster. When enabled, - it runs a small pod in the cluster that manages the load balancers. - required: false - type: bool - horizontal_pod_autoscaling: - description: - - Configuration for the horizontal pod autoscaling feature, which increases or decreases - the number of replica pods a replication controller has based on the resource usage - of the existing pods. - required: false - suboptions: - disabled: - description: - - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. When enabled, - it ensures that a Heapster pod is running in the cluster, which is also used by - the Cloud Monitoring service. - required: false - type: bool - subnetwork: - description: - - The name of the Google Compute Engine subnetwork to which the cluster is connected. - required: false - location: - description: - - The list of Google Compute Engine locations in which the cluster's nodes should - be located. - required: false - zone: - description: - - The zone where the cluster is deployed. - required: true + disabled: + description: + - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. + When enabled, it ensures that a Heapster pod is running in the cluster, + which is also used by the Cloud Monitoring service. + required: false + type: bool + subnetwork: + description: + - The name of the Google Compute Engine subnetwork to which the cluster is connected. + required: false + location: + description: + - The list of Google Compute Engine locations in which the cluster's nodes should + be located. + required: false + zone: + description: + - The zone where the cluster is deployed. + required: true extends_documentation_fragment: gcp ''' EXAMPLES = ''' - name: create a cluster gcp_container_cluster: - name: "test_object" + name: my-cluster initial_node_count: 2 master_auth: username: cluster_admin @@ -274,292 +286,297 @@ EXAMPLES = ''' ''' RETURN = ''' - name: - description: - - The name of this cluster. The name must be unique within this project and zone, - and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens - only. Must start with a letter. Must end with a number or a letter. - returned: success - type: str - description: - description: - - An optional description of this cluster. - returned: success - type: str - initialNodeCount: - description: - - The number of nodes to create in this cluster. You must ensure that your Compute - Engine resource quota is sufficient for this number of instances. You must also - have available firewall and routes quota. For requests, this field should only be - used in lieu of a "nodePool" object, since this configuration (along with the "nodeConfig") - will be used to create a "NodePool" object with an auto-generated name. Do not use - this and a nodePool at the same time. - returned: success - type: int - nodeConfig: - description: - - Parameters used in creating the cluster's nodes. - - For requests, this field should only be used in lieu of a "nodePool" object, since - this configuration (along with the "initialNodeCount") will be used to create a - "NodePool" object with an auto-generated name. Do not use this and a nodePool at - the same time. For responses, this field will be populated with the node configuration - of the first node pool. If unspecified, the defaults are used. - returned: success - type: complex - contains: - machineType: - description: - - The name of a Google Compute Engine machine type (e.g. - - n1-standard-1). If unspecified, the default machine type is n1-standard-1. - returned: success - type: str - diskSizeGb: - description: - - Size of the disk attached to each node, specified in GB. The smallest allowed disk - size is 10GB. If unspecified, the default disk size is 100GB. - returned: success - type: int - oauthScopes: - description: - - The set of Google API scopes to be made available on all of the node VMs under the - "default" service account. - - 'The following scopes are recommended, but not required, and by default are not - included: U(https://www.googleapis.com/auth/compute) is required for mounting persistent - storage on your nodes.' - - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating - with gcr.io (the Google Container Registry). - - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are - enabled, in which case their required scopes will be added. - returned: success - type: list - serviceAccount: - description: - - The Google Cloud Platform Service Account to be used by the node VMs. If no Service - Account is specified, the "default" service account is used. - returned: success - type: str - metadata: - description: - - The metadata key/value pairs assigned to instances in the cluster. - - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length. - These are reflected as part of a URL in the metadata server. Additionally, to avoid - ambiguity, keys must not conflict with any other metadata keys for the project or - be one of the four reserved keys: "instance-template", "kube-env", "startup-script", - and "user-data" Values are free-form strings, and only have meaning as interpreted - by the image running in the instance. The only restriction placed on them is that - each value''s size must be less than or equal to 32 KB.' - - The total size of all keys and values must be less than 512 KB. - - 'An object containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - returned: success - type: dict - imageType: - description: - - The image type to use for this node. Note that for a given image type, the latest - version of it will be used. - returned: success - type: str - labels: - description: - - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. - These will added in addition to any default label(s) that Kubernetes may apply to - the node. In case of conflict in label keys, the applied set may differ depending - on the Kubernetes version -- it''s best to assume the behavior is undefined and - conflicts should be avoided. For more information, including usage and the valid - values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object - containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - returned: success - type: dict - localSsdCount: - description: - - The number of local SSD disks to be attached to the node. - - 'The limit for this value is dependant upon the maximum number of disks available - on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) for - more information.' - returned: success - type: int - tags: - description: - - The list of instance tags applied to all nodes. Tags are used to identify valid - sources or targets for network firewalls and are specified by the client during - cluster or node pool creation. Each tag within the list must comply with RFC1035. - returned: success - type: list - preemptible: - description: - - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) - for more inforamtion about preemptible VM instances.' - returned: success - type: bool - masterAuth: - description: - - The authentication information for accessing the master endpoint. - returned: success - type: complex - contains: - username: - description: - - The username to use for HTTP basic authentication to the master endpoint. - returned: success - type: str - password: - description: - - The password to use for HTTP basic authentication to the master endpoint. Because - the master endpoint is open to the Internet, you should create a strong password. - returned: success - type: str - clusterCaCertificate: - description: - - Base64-encoded public certificate that is the root of trust for the cluster. - returned: success - type: str - clientCertificate: - description: - - Base64-encoded public certificate used by clients to authenticate to the cluster - endpoint. - returned: success - type: str - clientKey: - description: - - Base64-encoded private key used by clients to authenticate to the cluster endpoint. - returned: success - type: str - loggingService: - description: - - 'The logging service the cluster should use to write logs. Currently available options: logging.googleapis.com - - the Google Cloud Logging service.' - - none - no logs will be exported from the cluster. - - if left as an empty string,logging.googleapis.com will be used. - returned: success - type: str - monitoringService: - description: - - The monitoring service the cluster should use to write metrics. - - 'Currently available options: monitoring.googleapis.com - the Google Cloud Monitoring - service.' - - none - no metrics will be exported from the cluster. - - if left as an empty string, monitoring.googleapis.com will be used. - returned: success - type: str - network: - description: - - The name of the Google Compute Engine network to which the cluster is connected. - If left unspecified, the default network will be used. - - To ensure it exists and it is operations, configure the network using 'gcompute_network' - resource. - returned: success - type: str - clusterIpv4Cidr: - description: - - The IP address range of the container pods in this cluster, in CIDR notation (e.g. - 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block - in 10.0.0.0/8. - returned: success - type: str - addonsConfig: - description: - - Configurations for the various addons available to run in the cluster. - returned: success - type: complex - contains: - httpLoadBalancing: - description: - - Configuration for the HTTP (L7) load balancing controller addon, which makes it - easy to set up HTTP load balancers for services in a cluster. - returned: success - type: complex - contains: - disabled: - description: - - Whether the HTTP Load Balancing controller is enabled in the cluster. When enabled, - it runs a small pod in the cluster that manages the load balancers. - returned: success - type: bool - horizontalPodAutoscaling: - description: - - Configuration for the horizontal pod autoscaling feature, which increases or decreases - the number of replica pods a replication controller has based on the resource usage - of the existing pods. - returned: success - type: complex - contains: - disabled: - description: - - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. When enabled, - it ensures that a Heapster pod is running in the cluster, which is also used by - the Cloud Monitoring service. - returned: success - type: bool - subnetwork: - description: - - The name of the Google Compute Engine subnetwork to which the cluster is connected. - returned: success - type: str - location: - description: - - The list of Google Compute Engine locations in which the cluster's nodes should - be located. - returned: success - type: list - endpoint: - description: - - The IP address of this cluster's master endpoint. - - The endpoint can be accessed from the internet at https://username:password@endpoint/ See - the masterAuth property of this resource for username and password information. - returned: success - type: str - initialClusterVersion: - description: - - The software version of the master endpoint and kubelets used in the cluster when - it was first created. The version can be upgraded over time. - returned: success - type: str - currentMasterVersion: - description: - - The current software version of the master endpoint. - returned: success - type: str - currentNodeVersion: - description: - - The current version of the node software components. If they are currently at multiple - versions because they're in the process of being upgraded, this reflects the minimum - version of all nodes. - returned: success - type: str - createTime: - description: - - The time the cluster was created, in RFC3339 text format. - returned: success - type: str - nodeIpv4CidrSize: - description: - - The size of the address space on each node for hosting containers. - - This is provisioned from within the container_ipv4_cidr range. - returned: success - type: int - servicesIpv4Cidr: - description: - - The IP address range of the Kubernetes services in this cluster, in CIDR notation - (e.g. 1.2.3.4/29). Service addresses are typically put in the last /16 from the - container CIDR. - returned: success - type: str - currentNodeCount: - description: - - The number of nodes currently in the cluster. - returned: success - type: int - expireTime: - description: - - The time the cluster will be automatically deleted in RFC3339 text format. - returned: success - type: str - zone: - description: - - The zone where the cluster is deployed. - returned: success - type: str +name: + description: + - The name of this cluster. The name must be unique within this project and zone, + and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens + only. Must start with a letter. Must end with a number or a letter. + returned: success + type: str +description: + description: + - An optional description of this cluster. + returned: success + type: str +initialNodeCount: + description: + - The number of nodes to create in this cluster. You must ensure that your Compute + Engine resource quota is sufficient for this number of instances. You must also + have available firewall and routes quota. For requests, this field should only + be used in lieu of a "nodePool" object, since this configuration (along with the + "nodeConfig") will be used to create a "NodePool" object with an auto-generated + name. Do not use this and a nodePool at the same time. + returned: success + type: int +nodeConfig: + description: + - Parameters used in creating the cluster's nodes. + - For requests, this field should only be used in lieu of a "nodePool" object, since + this configuration (along with the "initialNodeCount") will be used to create + a "NodePool" object with an auto-generated name. Do not use this and a nodePool + at the same time. For responses, this field will be populated with the node configuration + of the first node pool. If unspecified, the defaults are used. + returned: success + type: complex + contains: + machineType: + description: + - The name of a Google Compute Engine machine type (e.g. + - n1-standard-1). If unspecified, the default machine type is n1-standard-1. + returned: success + type: str + diskSizeGb: + description: + - Size of the disk attached to each node, specified in GB. The smallest allowed + disk size is 10GB. If unspecified, the default disk size is 100GB. + returned: success + type: int + oauthScopes: + description: + - The set of Google API scopes to be made available on all of the node VMs under + the "default" service account. + - 'The following scopes are recommended, but not required, and by default are + not included: U(https://www.googleapis.com/auth/compute) is required for mounting + persistent storage on your nodes.' + - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating + with gcr.io (the Google Container Registry). + - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring + are enabled, in which case their required scopes will be added. + returned: success + type: list + serviceAccount: + description: + - The Google Cloud Platform Service Account to be used by the node VMs. If no + Service Account is specified, the "default" service account is used. + returned: success + type: str + metadata: + description: + - The metadata key/value pairs assigned to instances in the cluster. + - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes + in length. These are reflected as part of a URL in the metadata server. Additionally, + to avoid ambiguity, keys must not conflict with any other metadata keys for + the project or be one of the four reserved keys: "instance-template", "kube-env", + "startup-script", and "user-data" Values are free-form strings, and only have + meaning as interpreted by the image running in the instance. The only restriction + placed on them is that each value''s size must be less than or equal to 32 + KB.' + - The total size of all keys and values must be less than 512 KB. + - 'An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + returned: success + type: dict + imageType: + description: + - The image type to use for this node. Note that for a given image type, the + latest version of it will be used. + returned: success + type: str + labels: + description: + - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. + These will added in addition to any default label(s) that Kubernetes may apply + to the node. In case of conflict in label keys, the applied set may differ + depending on the Kubernetes version -- it''s best to assume the behavior is + undefined and conflicts should be avoided. For more information, including + usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) + An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + returned: success + type: dict + localSsdCount: + description: + - The number of local SSD disks to be attached to the node. + - 'The limit for this value is dependant upon the maximum number of disks available + on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) + for more information.' + returned: success + type: int + tags: + description: + - The list of instance tags applied to all nodes. Tags are used to identify + valid sources or targets for network firewalls and are specified by the client + during cluster or node pool creation. Each tag within the list must comply + with RFC1035. + returned: success + type: list + preemptible: + description: + - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) + for more inforamtion about preemptible VM instances.' + returned: success + type: bool +masterAuth: + description: + - The authentication information for accessing the master endpoint. + returned: success + type: complex + contains: + username: + description: + - The username to use for HTTP basic authentication to the master endpoint. + returned: success + type: str + password: + description: + - The password to use for HTTP basic authentication to the master endpoint. + Because the master endpoint is open to the Internet, you should create a strong + password. + returned: success + type: str + clusterCaCertificate: + description: + - Base64-encoded public certificate that is the root of trust for the cluster. + returned: success + type: str + clientCertificate: + description: + - Base64-encoded public certificate used by clients to authenticate to the cluster + endpoint. + returned: success + type: str + clientKey: + description: + - Base64-encoded private key used by clients to authenticate to the cluster + endpoint. + returned: success + type: str +loggingService: + description: + - 'The logging service the cluster should use to write logs. Currently available + options: logging.googleapis.com - the Google Cloud Logging service.' + - none - no logs will be exported from the cluster. + - if left as an empty string,logging.googleapis.com will be used. + returned: success + type: str +monitoringService: + description: + - The monitoring service the cluster should use to write metrics. + - 'Currently available options: monitoring.googleapis.com - the Google Cloud Monitoring + service.' + - none - no metrics will be exported from the cluster. + - if left as an empty string, monitoring.googleapis.com will be used. + returned: success + type: str +network: + description: + - The name of the Google Compute Engine network to which the cluster is connected. + If left unspecified, the default network will be used. + - To ensure it exists and it is operations, configure the network using 'gcompute_network' + resource. + returned: success + type: str +clusterIpv4Cidr: + description: + - The IP address range of the container pods in this cluster, in CIDR notation (e.g. + 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block + in 10.0.0.0/8. + returned: success + type: str +addonsConfig: + description: + - Configurations for the various addons available to run in the cluster. + returned: success + type: complex + contains: + httpLoadBalancing: + description: + - Configuration for the HTTP (L7) load balancing controller addon, which makes + it easy to set up HTTP load balancers for services in a cluster. + returned: success + type: complex + contains: + disabled: + description: + - Whether the HTTP Load Balancing controller is enabled in the cluster. + When enabled, it runs a small pod in the cluster that manages the load + balancers. + returned: success + type: bool + horizontalPodAutoscaling: + description: + - Configuration for the horizontal pod autoscaling feature, which increases + or decreases the number of replica pods a replication controller has based + on the resource usage of the existing pods. + returned: success + type: complex + contains: + disabled: + description: + - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. + When enabled, it ensures that a Heapster pod is running in the cluster, + which is also used by the Cloud Monitoring service. + returned: success + type: bool +subnetwork: + description: + - The name of the Google Compute Engine subnetwork to which the cluster is connected. + returned: success + type: str +location: + description: + - The list of Google Compute Engine locations in which the cluster's nodes should + be located. + returned: success + type: list +endpoint: + description: + - The IP address of this cluster's master endpoint. + - The endpoint can be accessed from the internet at https://username:password@endpoint/ + See the masterAuth property of this resource for username and password information. + returned: success + type: str +initialClusterVersion: + description: + - The software version of the master endpoint and kubelets used in the cluster when + it was first created. The version can be upgraded over time. + returned: success + type: str +currentMasterVersion: + description: + - The current software version of the master endpoint. + returned: success + type: str +currentNodeVersion: + description: + - The current version of the node software components. If they are currently at + multiple versions because they're in the process of being upgraded, this reflects + the minimum version of all nodes. + returned: success + type: str +createTime: + description: + - The time the cluster was created, in RFC3339 text format. + returned: success + type: str +nodeIpv4CidrSize: + description: + - The size of the address space on each node for hosting containers. + - This is provisioned from within the container_ipv4_cidr range. + returned: success + type: int +servicesIpv4Cidr: + description: + - The IP address range of the Kubernetes services in this cluster, in CIDR notation + (e.g. 1.2.3.4/29). Service addresses are typically put in the last /16 from the + container CIDR. + returned: success + type: str +currentNodeCount: + description: + - The number of nodes currently in the cluster. + returned: success + type: int +expireTime: + description: + - The time the cluster will be automatically deleted in RFC3339 text format. + returned: success + type: str +zone: + description: + - The zone where the cluster is deployed. + returned: success + type: str ''' ################################################################################ @@ -671,13 +688,13 @@ def resource_to_request(module): u'name': module.params.get('name'), u'description': module.params.get('description'), u'initialNodeCount': module.params.get('initial_node_count'), - u'nodeConfig': ClusterNodeConfig(module.params.get('node_config', {}), module).to_request(), - u'masterAuth': ClusterMasterAuth(module.params.get('master_auth', {}), module).to_request(), + u'nodeConfig': ClusterNodeconfig(module.params.get('node_config', {}), module).to_request(), + u'masterAuth': ClusterMasterauth(module.params.get('master_auth', {}), module).to_request(), u'loggingService': module.params.get('logging_service'), u'monitoringService': module.params.get('monitoring_service'), u'network': module.params.get('network'), u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'), - u'addonsConfig': ClusterAddonsConfig(module.params.get('addons_config', {}), module).to_request(), + u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(), u'subnetwork': module.params.get('subnetwork'), u'location': module.params.get('location') } @@ -749,13 +766,13 @@ def response_to_hash(module, response): u'name': response.get(u'name'), u'description': response.get(u'description'), u'initialNodeCount': module.params.get('initial_node_count'), - u'nodeConfig': ClusterNodeConfig(module.params.get('node_config', {}), module).to_request(), - u'masterAuth': ClusterMasterAuth(response.get(u'masterAuth', {}), module).from_response(), + u'nodeConfig': ClusterNodeconfig(module.params.get('node_config', {}), module).to_request(), + u'masterAuth': ClusterMasterauth(response.get(u'masterAuth', {}), module).from_response(), u'loggingService': response.get(u'loggingService'), u'monitoringService': response.get(u'monitoringService'), u'network': response.get(u'network'), u'clusterIpv4Cidr': response.get(u'clusterIpv4Cidr'), - u'addonsConfig': ClusterAddonsConfig(response.get(u'addonsConfig', {}), module).from_response(), + u'addonsConfig': ClusterAddonsconfig(response.get(u'addonsConfig', {}), module).from_response(), u'subnetwork': response.get(u'subnetwork'), u'location': response.get(u'location'), u'endpoint': response.get(u'endpoint'), @@ -794,8 +811,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE', 'ABORTING']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri) status = navigate_hash(op_result, ['status']) return op_result @@ -823,7 +838,7 @@ def encode_request(resource_request, module): } -class ClusterNodeConfig(object): +class ClusterNodeconfig(object): def __init__(self, request, module): self.module = module if request: @@ -860,7 +875,7 @@ class ClusterNodeConfig(object): }) -class ClusterMasterAuth(object): +class ClusterMasterauth(object): def __init__(self, request, module): self.module = module if request: @@ -887,7 +902,7 @@ class ClusterMasterAuth(object): }) -class ClusterAddonsConfig(object): +class ClusterAddonsconfig(object): def __init__(self, request, module): self.module = module if request: @@ -897,18 +912,18 @@ class ClusterAddonsConfig(object): def to_request(self): return remove_nones_from_dict({ - u'httpLoadBalancing': ClusterHttpLoadBalancing(self.request.get('http_load_balancing', {}), self.module).to_request(), - u'horizontalPodAutoscaling': ClusterHorizontalPodAutoscaling(self.request.get('horizontal_pod_autoscaling', {}), self.module).to_request() + u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get('http_load_balancing', {}), self.module).to_request(), + u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get('horizontal_pod_autoscaling', {}), self.module).to_request() }) def from_response(self): return remove_nones_from_dict({ - u'httpLoadBalancing': ClusterHttpLoadBalancing(self.request.get(u'httpLoadBalancing', {}), self.module).from_response(), - u'horizontalPodAutoscaling': ClusterHorizontalPodAutoscaling(self.request.get(u'horizontalPodAutoscaling', {}), self.module).from_response() + u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get(u'httpLoadBalancing', {}), self.module).from_response(), + u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get(u'horizontalPodAutoscaling', {}), self.module).from_response() }) -class ClusterHttpLoadBalancing(object): +class ClusterHttploadbalancing(object): def __init__(self, request, module): self.module = module if request: @@ -927,7 +942,7 @@ class ClusterHttpLoadBalancing(object): }) -class ClusterHorizontalPodAutoscaling(object): +class ClusterHorizontalpodautoscaling(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_container_node_pool.py b/lib/ansible/modules/cloud/google/gcp_container_node_pool.py index 68b267a133..d3196ff18a 100644 --- a/lib/ansible/modules/cloud/google/gcp_container_node_pool.py +++ b/lib/ansible/modules/cloud/google/gcp_container_node_pool.py @@ -32,182 +32,187 @@ DOCUMENTATION = ''' --- module: gcp_container_node_pool description: - - NodePool contains the name and configuration for a cluster's node pool. - - Node pools are a set of nodes (i.e. VM's), with a common configuration and specification, - under the control of the cluster master. They may have a set of Kubernetes labels - applied to them, which may be used to reference them during pod scheduling. They - may also be resized up or down, to accommodate the workload. +- NodePool contains the name and configuration for a cluster's node pool. +- Node pools are a set of nodes (i.e. VM's), with a common configuration and specification, + under the control of the cluster master. They may have a set of Kubernetes labels + applied to them, which may be used to reference them during pod scheduling. They + may also be resized up or down, to accommodate the workload. short_description: Creates a GCP NodePool version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - The name of the node pool. + required: false + config: + description: + - The node configuration of the pool. + required: false + suboptions: + machine_type: description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - The name of the node pool. + - The name of a Google Compute Engine machine type (e.g. + - n1-standard-1). If unspecified, the default machine type is n1-standard-1. required: false - config: + disk_size_gb: description: - - The node configuration of the pool. + - Size of the disk attached to each node, specified in GB. The smallest allowed + disk size is 10GB. If unspecified, the default disk size is 100GB. + required: false + oauth_scopes: + description: + - The set of Google API scopes to be made available on all of the node VMs + under the "default" service account. + - 'The following scopes are recommended, but not required, and by default + are not included: U(https://www.googleapis.com/auth/compute) is required + for mounting persistent storage on your nodes.' + - U(https://www.googleapis.com/auth/devstorage.read_only) is required for + communicating with gcr.io (the Google Container Registry). + - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring + are enabled, in which case their required scopes will be added. + required: false + service_account: + description: + - The Google Cloud Platform Service Account to be used by the node VMs. If + no Service Account is specified, the "default" service account is used. + required: false + metadata: + description: + - The metadata key/value pairs assigned to instances in the cluster. + - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes + in length. These are reflected as part of a URL in the metadata server. + Additionally, to avoid ambiguity, keys must not conflict with any other + metadata keys for the project or be one of the four reserved keys: "instance-template", + "kube-env", "startup-script", and "user-data" Values are free-form strings, + and only have meaning as interpreted by the image running in the instance. + The only restriction placed on them is that each value''s size must be less + than or equal to 32 KB.' + - The total size of all keys and values must be less than 512 KB. + - 'An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + required: false + image_type: + description: + - The image type to use for this node. Note that for a given image type, the + latest version of it will be used. + required: false + labels: + description: + - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. + These will added in addition to any default label(s) that Kubernetes may + apply to the node. In case of conflict in label keys, the applied set may + differ depending on the Kubernetes version -- it''s best to assume the behavior + is undefined and conflicts should be avoided. For more information, including + usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) + An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + required: false + local_ssd_count: + description: + - The number of local SSD disks to be attached to the node. + - 'The limit for this value is dependant upon the maximum number of disks + available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) + for more information.' + required: false + tags: + description: + - The list of instance tags applied to all nodes. Tags are used to identify + valid sources or targets for network firewalls and are specified by the + client during cluster or node pool creation. Each tag within the list must + comply with RFC1035. + required: false + preemptible: + description: + - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) + for more inforamtion about preemptible VM instances.' + required: false + type: bool + initial_node_count: + description: + - The initial node count for the pool. You must ensure that your Compute Engine + resource quota is sufficient for this number of instances. You must also have + available firewall and routes quota. + required: true + autoscaling: + description: + - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a + valid configuration is present. + required: false + suboptions: + enabled: + description: + - Is autoscaling enabled for this node pool. + required: false + type: bool + min_node_count: + description: + - Minimum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount. + required: false + max_node_count: + description: + - Maximum number of nodes in the NodePool. Must be >= minNodeCount. + - There has to enough quota to scale up the cluster. + required: false + management: + description: + - Management configuration for this NodePool. + required: false + suboptions: + auto_upgrade: + description: + - A flag that specifies whether node auto-upgrade is enabled for the node + pool. If enabled, node auto-upgrade helps keep the nodes in your node pool + up to date with the latest release version of Kubernetes. + required: false + type: bool + auto_repair: + description: + - A flag that specifies whether the node auto-repair is enabled for the node + pool. If enabled, the nodes in this node pool will be monitored and, if + they fail health checks too many times, an automatic repair action will + be triggered. + required: false + type: bool + upgrade_options: + description: + - Specifies the Auto Upgrade knobs for the node pool. required: false suboptions: - machine_type: - description: - - The name of a Google Compute Engine machine type (e.g. - - n1-standard-1). If unspecified, the default machine type is n1-standard-1. - required: false - disk_size_gb: - description: - - Size of the disk attached to each node, specified in GB. The smallest allowed disk - size is 10GB. If unspecified, the default disk size is 100GB. - required: false - oauth_scopes: - description: - - The set of Google API scopes to be made available on all of the node VMs under the - "default" service account. - - 'The following scopes are recommended, but not required, and by default are not - included: U(https://www.googleapis.com/auth/compute) is required for mounting persistent - storage on your nodes.' - - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating - with gcr.io (the Google Container Registry). - - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are - enabled, in which case their required scopes will be added. - required: false - service_account: - description: - - The Google Cloud Platform Service Account to be used by the node VMs. If no Service - Account is specified, the "default" service account is used. - required: false - metadata: - description: - - The metadata key/value pairs assigned to instances in the cluster. - - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length. - These are reflected as part of a URL in the metadata server. Additionally, to avoid - ambiguity, keys must not conflict with any other metadata keys for the project or - be one of the four reserved keys: "instance-template", "kube-env", "startup-script", - and "user-data" Values are free-form strings, and only have meaning as interpreted - by the image running in the instance. The only restriction placed on them is that - each value''s size must be less than or equal to 32 KB.' - - The total size of all keys and values must be less than 512 KB. - - 'An object containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - required: false - image_type: - description: - - The image type to use for this node. Note that for a given image type, the latest - version of it will be used. - required: false - labels: - description: - - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. - These will added in addition to any default label(s) that Kubernetes may apply to - the node. In case of conflict in label keys, the applied set may differ depending - on the Kubernetes version -- it''s best to assume the behavior is undefined and - conflicts should be avoided. For more information, including usage and the valid - values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object - containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - required: false - local_ssd_count: - description: - - The number of local SSD disks to be attached to the node. - - 'The limit for this value is dependant upon the maximum number of disks available - on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) for - more information.' - required: false - tags: - description: - - The list of instance tags applied to all nodes. Tags are used to identify valid - sources or targets for network firewalls and are specified by the client during - cluster or node pool creation. Each tag within the list must comply with RFC1035. - required: false - preemptible: - description: - - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) - for more inforamtion about preemptible VM instances.' - required: false - type: bool - initial_node_count: - description: - - The initial node count for the pool. You must ensure that your Compute Engine resource - quota is sufficient for this number of instances. You must also have available firewall - and routes quota. - required: true - autoscaling: - description: - - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a valid - configuration is present. - required: false - suboptions: - enabled: - description: - - Is autoscaling enabled for this node pool. - required: false - type: bool - min_node_count: - description: - - Minimum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount. - required: false - max_node_count: - description: - - Maximum number of nodes in the NodePool. Must be >= minNodeCount. - - There has to enough quota to scale up the cluster. - required: false - management: - description: - - Management configuration for this NodePool. - required: false - suboptions: - auto_upgrade: - description: - - A flag that specifies whether node auto-upgrade is enabled for the node pool. If - enabled, node auto-upgrade helps keep the nodes in your node pool up to date with - the latest release version of Kubernetes. - required: false - type: bool - auto_repair: - description: - - A flag that specifies whether the node auto-repair is enabled for the node pool. - If enabled, the nodes in this node pool will be monitored and, if they fail health - checks too many times, an automatic repair action will be triggered. - required: false - type: bool - upgrade_options: - description: - - Specifies the Auto Upgrade knobs for the node pool. - required: false - suboptions: - auto_upgrade_start_time: - description: - - This field is set when upgrades are about to commence with the approximate start - time for the upgrades, in RFC3339 text format. - required: false - description: - description: - - This field is set when upgrades are about to commence with the description of the - upgrade. - required: false - cluster: - description: - - The cluster this node pool belongs to. - - 'This field represents a link to a Cluster resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_container_cluster - task and then set this cluster field to "{{ name-of-resource }}" Alternatively, - you can set this cluster to a dictionary with the name key where the value is the - name of your Cluster.' - required: true - zone: - description: - - The zone where the node pool is deployed. - required: true + auto_upgrade_start_time: + description: + - This field is set when upgrades are about to commence with the approximate + start time for the upgrades, in RFC3339 text format. + required: false + description: + description: + - This field is set when upgrades are about to commence with the description + of the upgrade. + required: false + cluster: + description: + - The cluster this node pool belongs to. + - 'This field represents a link to a Cluster resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_container_cluster + task and then set this cluster field to "{{ name-of-resource }}" Alternatively, + you can set this cluster to a dictionary with the name key where the value is + the name of your Cluster' + required: true + zone: + description: + - The zone where the node pool is deployed. + required: true extends_documentation_fragment: gcp ''' @@ -225,7 +230,7 @@ EXAMPLES = ''' - name: create a node pool gcp_container_node_pool: - name: "test_object" + name: my-pool initial_node_count: 4 cluster: "{{ cluster }}" zone: us-central1-a @@ -236,185 +241,187 @@ EXAMPLES = ''' ''' RETURN = ''' - name: +name: + description: + - The name of the node pool. + returned: success + type: str +config: + description: + - The node configuration of the pool. + returned: success + type: complex + contains: + machineType: + description: + - The name of a Google Compute Engine machine type (e.g. + - n1-standard-1). If unspecified, the default machine type is n1-standard-1. + returned: success + type: str + diskSizeGb: + description: + - Size of the disk attached to each node, specified in GB. The smallest allowed + disk size is 10GB. If unspecified, the default disk size is 100GB. + returned: success + type: int + oauthScopes: + description: + - The set of Google API scopes to be made available on all of the node VMs under + the "default" service account. + - 'The following scopes are recommended, but not required, and by default are + not included: U(https://www.googleapis.com/auth/compute) is required for mounting + persistent storage on your nodes.' + - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating + with gcr.io (the Google Container Registry). + - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring + are enabled, in which case their required scopes will be added. + returned: success + type: list + serviceAccount: + description: + - The Google Cloud Platform Service Account to be used by the node VMs. If no + Service Account is specified, the "default" service account is used. + returned: success + type: str + metadata: + description: + - The metadata key/value pairs assigned to instances in the cluster. + - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes + in length. These are reflected as part of a URL in the metadata server. Additionally, + to avoid ambiguity, keys must not conflict with any other metadata keys for + the project or be one of the four reserved keys: "instance-template", "kube-env", + "startup-script", and "user-data" Values are free-form strings, and only have + meaning as interpreted by the image running in the instance. The only restriction + placed on them is that each value''s size must be less than or equal to 32 + KB.' + - The total size of all keys and values must be less than 512 KB. + - 'An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + returned: success + type: dict + imageType: + description: + - The image type to use for this node. Note that for a given image type, the + latest version of it will be used. + returned: success + type: str + labels: + description: + - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. + These will added in addition to any default label(s) that Kubernetes may apply + to the node. In case of conflict in label keys, the applied set may differ + depending on the Kubernetes version -- it''s best to assume the behavior is + undefined and conflicts should be avoided. For more information, including + usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) + An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + returned: success + type: dict + localSsdCount: + description: + - The number of local SSD disks to be attached to the node. + - 'The limit for this value is dependant upon the maximum number of disks available + on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) + for more information.' + returned: success + type: int + tags: + description: + - The list of instance tags applied to all nodes. Tags are used to identify + valid sources or targets for network firewalls and are specified by the client + during cluster or node pool creation. Each tag within the list must comply + with RFC1035. + returned: success + type: list + preemptible: + description: + - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) + for more inforamtion about preemptible VM instances.' + returned: success + type: bool +initialNodeCount: + description: + - The initial node count for the pool. You must ensure that your Compute Engine + resource quota is sufficient for this number of instances. You must also have + available firewall and routes quota. + returned: success + type: int +version: + description: + - The version of the Kubernetes of this node. + returned: success + type: str +autoscaling: + description: + - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a valid + configuration is present. + returned: success + type: complex + contains: + enabled: + description: + - Is autoscaling enabled for this node pool. + returned: success + type: bool + minNodeCount: + description: + - Minimum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount. + returned: success + type: int + maxNodeCount: + description: + - Maximum number of nodes in the NodePool. Must be >= minNodeCount. + - There has to enough quota to scale up the cluster. + returned: success + type: int +management: + description: + - Management configuration for this NodePool. + returned: success + type: complex + contains: + autoUpgrade: + description: + - A flag that specifies whether node auto-upgrade is enabled for the node pool. + If enabled, node auto-upgrade helps keep the nodes in your node pool up to + date with the latest release version of Kubernetes. + returned: success + type: bool + autoRepair: + description: + - A flag that specifies whether the node auto-repair is enabled for the node + pool. If enabled, the nodes in this node pool will be monitored and, if they + fail health checks too many times, an automatic repair action will be triggered. + returned: success + type: bool + upgradeOptions: + description: + - Specifies the Auto Upgrade knobs for the node pool. + returned: success + type: complex + contains: + autoUpgradeStartTime: + description: + - This field is set when upgrades are about to commence with the approximate + start time for the upgrades, in RFC3339 text format. + returned: success + type: str description: - - The name of the node pool. - returned: success - type: str - config: - description: - - The node configuration of the pool. - returned: success - type: complex - contains: - machineType: - description: - - The name of a Google Compute Engine machine type (e.g. - - n1-standard-1). If unspecified, the default machine type is n1-standard-1. - returned: success - type: str - diskSizeGb: - description: - - Size of the disk attached to each node, specified in GB. The smallest allowed disk - size is 10GB. If unspecified, the default disk size is 100GB. - returned: success - type: int - oauthScopes: - description: - - The set of Google API scopes to be made available on all of the node VMs under the - "default" service account. - - 'The following scopes are recommended, but not required, and by default are not - included: U(https://www.googleapis.com/auth/compute) is required for mounting persistent - storage on your nodes.' - - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating - with gcr.io (the Google Container Registry). - - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are - enabled, in which case their required scopes will be added. - returned: success - type: list - serviceAccount: - description: - - The Google Cloud Platform Service Account to be used by the node VMs. If no Service - Account is specified, the "default" service account is used. - returned: success - type: str - metadata: - description: - - The metadata key/value pairs assigned to instances in the cluster. - - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length. - These are reflected as part of a URL in the metadata server. Additionally, to avoid - ambiguity, keys must not conflict with any other metadata keys for the project or - be one of the four reserved keys: "instance-template", "kube-env", "startup-script", - and "user-data" Values are free-form strings, and only have meaning as interpreted - by the image running in the instance. The only restriction placed on them is that - each value''s size must be less than or equal to 32 KB.' - - The total size of all keys and values must be less than 512 KB. - - 'An object containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - returned: success - type: dict - imageType: - description: - - The image type to use for this node. Note that for a given image type, the latest - version of it will be used. - returned: success - type: str - labels: - description: - - 'The map of Kubernetes labels (key/value pairs) to be applied to each node. - These will added in addition to any default label(s) that Kubernetes may apply to - the node. In case of conflict in label keys, the applied set may differ depending - on the Kubernetes version -- it''s best to assume the behavior is undefined and - conflicts should be avoided. For more information, including usage and the valid - values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object - containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - returned: success - type: dict - localSsdCount: - description: - - The number of local SSD disks to be attached to the node. - - 'The limit for this value is dependant upon the maximum number of disks available - on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) for - more information.' - returned: success - type: int - tags: - description: - - The list of instance tags applied to all nodes. Tags are used to identify valid - sources or targets for network firewalls and are specified by the client during - cluster or node pool creation. Each tag within the list must comply with RFC1035. - returned: success - type: list - preemptible: - description: - - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) - for more inforamtion about preemptible VM instances.' - returned: success - type: bool - initialNodeCount: - description: - - The initial node count for the pool. You must ensure that your Compute Engine resource - quota is sufficient for this number of instances. You must also have available firewall - and routes quota. - returned: success - type: int - version: - description: - - The version of the Kubernetes of this node. - returned: success - type: str - autoscaling: - description: - - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a valid - configuration is present. - returned: success - type: complex - contains: - enabled: - description: - - Is autoscaling enabled for this node pool. - returned: success - type: bool - minNodeCount: - description: - - Minimum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount. - returned: success - type: int - maxNodeCount: - description: - - Maximum number of nodes in the NodePool. Must be >= minNodeCount. - - There has to enough quota to scale up the cluster. - returned: success - type: int - management: - description: - - Management configuration for this NodePool. - returned: success - type: complex - contains: - autoUpgrade: - description: - - A flag that specifies whether node auto-upgrade is enabled for the node pool. If - enabled, node auto-upgrade helps keep the nodes in your node pool up to date with - the latest release version of Kubernetes. - returned: success - type: bool - autoRepair: - description: - - A flag that specifies whether the node auto-repair is enabled for the node pool. - If enabled, the nodes in this node pool will be monitored and, if they fail health - checks too many times, an automatic repair action will be triggered. - returned: success - type: bool - upgradeOptions: - description: - - Specifies the Auto Upgrade knobs for the node pool. - returned: success - type: complex - contains: - autoUpgradeStartTime: - description: - - This field is set when upgrades are about to commence with the approximate start - time for the upgrades, in RFC3339 text format. - returned: success - type: str - description: - description: - - This field is set when upgrades are about to commence with the description of the - upgrade. - returned: success - type: str - cluster: - description: - - The cluster this node pool belongs to. - returned: success - type: dict - zone: - description: - - The zone where the node pool is deployed. - returned: success - type: str + description: + - This field is set when upgrades are about to commence with the description + of the upgrade. + returned: success + type: str +cluster: + description: + - The cluster this node pool belongs to. + returned: success + type: dict +zone: + description: + - The zone where the node pool is deployed. + returned: success + type: str ''' ################################################################################ @@ -630,8 +637,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE', 'ABORTING']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri) status = navigate_hash(op_result, ['status']) return op_result @@ -731,18 +736,18 @@ class NodePoolManagement(object): return remove_nones_from_dict({ u'autoUpgrade': self.request.get('auto_upgrade'), u'autoRepair': self.request.get('auto_repair'), - u'upgradeOptions': NodePoolUpgradeOptions(self.request.get('upgrade_options', {}), self.module).to_request() + u'upgradeOptions': NodePoolUpgradeoptions(self.request.get('upgrade_options', {}), self.module).to_request() }) def from_response(self): return remove_nones_from_dict({ u'autoUpgrade': self.request.get(u'autoUpgrade'), u'autoRepair': self.request.get(u'autoRepair'), - u'upgradeOptions': NodePoolUpgradeOptions(self.request.get(u'upgradeOptions', {}), self.module).from_response() + u'upgradeOptions': NodePoolUpgradeoptions(self.request.get(u'upgradeOptions', {}), self.module).from_response() }) -class NodePoolUpgradeOptions(object): +class NodePoolUpgradeoptions(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py index 08fdc31ead..6a8ed21bf3 100644 --- a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py +++ b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py @@ -32,41 +32,43 @@ DOCUMENTATION = ''' --- module: gcp_dns_managed_zone description: - - A zone is a subtree of the DNS namespace under one administrative responsibility. - A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service. +- A zone is a subtree of the DNS namespace under one administrative responsibility. + A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service. short_description: Creates a GCP ManagedZone version_added: 2.5 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' + state: description: - description: - - A mutable string of at most 1024 characters associated with this resource for the - user's convenience. Has no effect on the managed zone's function. - required: false - dns_name: - description: - - The DNS name of this managed zone, for instance "example.com.". - required: false - name: - description: - - User assigned name for this resource. - - Must be unique within the project. - required: true - name_server_set: - description: - - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is - a set of DNS name servers that all host the same ManagedZones. Most users will leave - this field unset. - required: false + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + description: + description: + - A mutable string of at most 1024 characters associated with this resource for + the user's convenience. Has no effect on the managed zone's function. + required: false + dns_name: + description: + - The DNS name of this managed zone, for instance "example.com.". + required: false + name: + description: + - User assigned name for this resource. + - Must be unique within the project. + required: true + name_server_set: + description: + - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet + is a set of DNS name servers that all host the same ManagedZones. Most users + will leave this field unset. + required: false extends_documentation_fragment: gcp ''' @@ -83,47 +85,47 @@ EXAMPLES = ''' ''' RETURN = ''' - description: - description: - - A mutable string of at most 1024 characters associated with this resource for the - user's convenience. Has no effect on the managed zone's function. - returned: success - type: str - dnsName: - description: - - The DNS name of this managed zone, for instance "example.com.". - returned: success - type: str - id: - description: - - Unique identifier for the resource; defined by the server. - returned: success - type: int - name: - description: - - User assigned name for this resource. - - Must be unique within the project. - returned: success - type: str - nameServers: - description: - - Delegate your managed_zone to these virtual name servers; defined by the server - . - returned: success - type: list - nameServerSet: - description: - - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is - a set of DNS name servers that all host the same ManagedZones. Most users will leave - this field unset. - returned: success - type: list - creationTime: - description: - - The time that this resource was created on the server. - - This is in RFC3339 text format. - returned: success - type: str +description: + description: + - A mutable string of at most 1024 characters associated with this resource for + the user's convenience. Has no effect on the managed zone's function. + returned: success + type: str +dnsName: + description: + - The DNS name of this managed zone, for instance "example.com.". + returned: success + type: str +id: + description: + - Unique identifier for the resource; defined by the server. + returned: success + type: int +name: + description: + - User assigned name for this resource. + - Must be unique within the project. + returned: success + type: str +nameServers: + description: + - Delegate your managed_zone to these virtual name servers; defined by the server + . + returned: success + type: list +nameServerSet: + description: + - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is + a set of DNS name servers that all host the same ManagedZones. Most users will + leave this field unset. + returned: success + type: list +creationTime: + description: + - The time that this resource was created on the server. + - This is in RFC3339 text format. + returned: success + type: str ''' ################################################################################ diff --git a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone_facts.py b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone_facts.py index d795b80216..6a7e8205f1 100644 --- a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone_facts.py @@ -32,18 +32,18 @@ DOCUMENTATION = ''' --- module: gcp_dns_managed_zone_facts description: - - Gather facts for GCP ManagedZone +- Gather facts for GCP ManagedZone short_description: Gather facts for GCP ManagedZone version_added: 2.8 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - dns_name: - description: - Restricts the list to return only zones with this domain name. + dns_name: + description: + - Restricts the list to return only zones with this domain name. extends_documentation_fragment: gcp ''' @@ -58,51 +58,51 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - description: - description: - - A mutable string of at most 1024 characters associated with this resource for the - user's convenience. Has no effect on the managed zone's function. - returned: success - type: str - dnsName: - description: - - The DNS name of this managed zone, for instance "example.com.". - returned: success - type: str - id: - description: - - Unique identifier for the resource; defined by the server. - returned: success - type: int - name: - description: - - User assigned name for this resource. - - Must be unique within the project. - returned: success - type: str - nameServers: - description: - - Delegate your managed_zone to these virtual name servers; defined by the server - . - returned: success - type: list - nameServerSet: - description: - - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is - a set of DNS name servers that all host the same ManagedZones. Most users will leave - this field unset. - returned: success - type: list - creationTime: - description: - - The time that this resource was created on the server. - - This is in RFC3339 text format. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + description: + description: + - A mutable string of at most 1024 characters associated with this resource + for the user's convenience. Has no effect on the managed zone's function. + returned: success + type: str + dnsName: + description: + - The DNS name of this managed zone, for instance "example.com.". + returned: success + type: str + id: + description: + - Unique identifier for the resource; defined by the server. + returned: success + type: int + name: + description: + - User assigned name for this resource. + - Must be unique within the project. + returned: success + type: str + nameServers: + description: + - Delegate your managed_zone to these virtual name servers; defined by the server + . + returned: success + type: list + nameServerSet: + description: + - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet + is a set of DNS name servers that all host the same ManagedZones. Most users + will leave this field unset. + returned: success + type: list + creationTime: + description: + - The time that this resource was created on the server. + - This is in RFC3339 text format. + returned: success + type: str ''' ################################################################################ @@ -123,7 +123,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite'] items = fetch_list(module, collection(module), module.params['dns_name']) diff --git a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py index 2b0491534b..936bbd361d 100644 --- a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py +++ b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py @@ -32,51 +32,65 @@ DOCUMENTATION = ''' --- module: gcp_dns_resource_record_set description: - - A single DNS record that exists on a domain name (i.e. in a managed zone). - - This record defines the information about the domain and where the domain / subdomains - direct to. - - The record will include the domain/subdomain name, a type (i.e. A, AAA, CAA, MX, - CNAME, NS, etc) . +- A single DNS record that exists on a domain name (i.e. in a managed zone). +- This record defines the information about the domain and where the domain / subdomains + direct to. +- The record will include the domain/subdomain name, a type (i.e. A, AAA, CAA, MX, + CNAME, NS, etc) . short_description: Creates a GCP ResourceRecordSet version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - For example, U(www.example.com.) - required: true - type: - description: - - One of valid DNS resource types. - required: true - choices: ['A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS', 'PTR', 'SOA', 'SPF', 'SRV', 'TXT'] - ttl: - description: - - Number of seconds that this ResourceRecordSet can be cached by resolvers. - required: false - target: - description: - - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) . - required: false - managed_zone: - description: - - Identifies the managed zone addressed by this request. - - Can be the managed zone name or id. - - 'This field represents a link to a ManagedZone resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_dns_managed_zone - task and then set this managed_zone field to "{{ name-of-resource }}" Alternatively, - you can set this managed_zone to a dictionary with the name key where the value - is the name of your ManagedZone.' - required: true + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - For example, U(www.example.com.) + required: true + type: + description: + - One of valid DNS resource types. + required: true + choices: + - A + - AAAA + - CAA + - CNAME + - MX + - NAPTR + - NS + - PTR + - SOA + - SPF + - SRV + - TXT + ttl: + description: + - Number of seconds that this ResourceRecordSet can be cached by resolvers. + required: false + target: + description: + - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) . + required: false + managed_zone: + description: + - Identifies the managed zone addressed by this request. + - Can be the managed zone name or id. + - 'This field represents a link to a ManagedZone resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_dns_managed_zone + task and then set this managed_zone field to "{{ name-of-resource }}" Alternatively, + you can set this managed_zone to a dictionary with the name key where the value + is the name of your ManagedZone' + required: true extends_documentation_fragment: gcp ''' @@ -108,32 +122,32 @@ EXAMPLES = ''' ''' RETURN = ''' - name: - description: - - For example, U(www.example.com.) - returned: success - type: str - type: - description: - - One of valid DNS resource types. - returned: success - type: str - ttl: - description: - - Number of seconds that this ResourceRecordSet can be cached by resolvers. - returned: success - type: int - target: - description: - - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) . - returned: success - type: list - managed_zone: - description: - - Identifies the managed zone addressed by this request. - - Can be the managed zone name or id. - returned: success - type: dict +name: + description: + - For example, U(www.example.com.) + returned: success + type: str +type: + description: + - One of valid DNS resource types. + returned: success + type: str +ttl: + description: + - Number of seconds that this ResourceRecordSet can be cached by resolvers. + returned: success + type: int +target: + description: + - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) . + returned: success + type: list +managed_zone: + description: + - Identifies the managed zone addressed by this request. + - Can be the managed zone name or id. + returned: success + type: dict ''' ################################################################################ diff --git a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_facts.py b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_facts.py index edafba4cfc..f5fd0c37cf 100644 --- a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_facts.py @@ -32,25 +32,25 @@ DOCUMENTATION = ''' --- module: gcp_dns_resource_record_set_facts description: - - Gather facts for GCP ResourceRecordSet +- Gather facts for GCP ResourceRecordSet short_description: Gather facts for GCP ResourceRecordSet version_added: 2.8 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - managed_zone: - description: - - Identifies the managed zone addressed by this request. - - Can be the managed zone name or id. - - 'This field represents a link to a ManagedZone resource in GCP. It can be specified - in two ways. You can add `register: name-of-resource` to a gcp_dns_managed_zone - task and then set this managed_zone field to "{{ name-of-resource }}" Alternatively, - you can set this managed_zone to a dictionary with the name key where the value - is the name of your ManagedZone.' - required: true + managed_zone: + description: + - Identifies the managed zone addressed by this request. + - Can be the managed zone name or id. + - 'This field represents a link to a ManagedZone resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_dns_managed_zone + task and then set this managed_zone field to "{{ name-of-resource }}" Alternatively, + you can set this managed_zone to a dictionary with the name key where the value + is the name of your ManagedZone' + required: true extends_documentation_fragment: gcp ''' @@ -65,36 +65,36 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - name: - description: - - For example, U(www.example.com.) - returned: success - type: str - type: - description: - - One of valid DNS resource types. - returned: success - type: str - ttl: - description: - - Number of seconds that this ResourceRecordSet can be cached by resolvers. - returned: success - type: int - target: - description: - - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) . - returned: success - type: list - managed_zone: - description: - - Identifies the managed zone addressed by this request. - - Can be the managed zone name or id. - returned: success - type: dict + description: List of items + returned: always + type: complex + contains: + name: + description: + - For example, U(www.example.com.) + returned: success + type: str + type: + description: + - One of valid DNS resource types. + returned: success + type: str + ttl: + description: + - Number of seconds that this ResourceRecordSet can be cached by resolvers. + returned: success + type: int + target: + description: + - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) . + returned: success + type: list + managed_zone: + description: + - Identifies the managed zone addressed by this request. + - Can be the managed zone name or id. + returned: success + type: dict ''' ################################################################################ @@ -115,7 +115,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite'] items = fetch_list(module, collection(module)) diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py index d5eeeee253..dea237fef1 100644 --- a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py +++ b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py @@ -32,63 +32,65 @@ DOCUMENTATION = ''' --- module: gcp_pubsub_subscription description: - - A named resource representing the stream of messages from a single, specific topic, - to be delivered to the subscribing application. +- A named resource representing the stream of messages from a single, specific topic, + to be delivered to the subscribing application. short_description: Creates a GCP Subscription version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - Name of the subscription. + required: false + topic: + description: + - A reference to a Topic resource. + - 'This field represents a link to a Topic resource in GCP. It can be specified + in two ways. You can add `register: name-of-resource` to a gcp_pubsub_topic + task and then set this topic field to "{{ name-of-resource }}" Alternatively, + you can set this topic to a dictionary with the name key where the value is + the name of your Topic' + required: false + push_config: + description: + - If push delivery is used with this subscription, this field is used to configure + it. An empty pushConfig signifies that the subscriber will pull and ack messages + using API methods. + required: false + suboptions: + push_endpoint: description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - Name of the subscription. - required: false - topic: - description: - - A reference to a Topic resource. - - 'This field represents a link to a Topic resource in GCP. It can be specified in - two ways. You can add `register: name-of-resource` to a gcp_pubsub_topic task and - then set this topic field to "{{ name-of-resource }}" Alternatively, you can set - this topic to a dictionary with the name key where the value is the name of your - Topic.' - required: false - push_config: - description: - - If push delivery is used with this subscription, this field is used to configure - it. An empty pushConfig signifies that the subscriber will pull and ack messages - using API methods. - required: false - suboptions: - push_endpoint: - description: - - A URL locating the endpoint to which messages should be pushed. - - For example, a Webhook endpoint might use "U(https://example.com/push".) - required: false - ack_deadline_seconds: - description: - - This value is the maximum time after a subscriber receives a message before the - subscriber should acknowledge the message. After message delivery but before the - ack deadline expires and before the message is acknowledged, it is an outstanding - message and will not be delivered again during that time (on a best-effort basis). - - For pull subscriptions, this value is used as the initial value for the ack deadline. - To override this value for a given message, call subscriptions.modifyAckDeadline - with the corresponding ackId if using pull. The minimum custom deadline you can - specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds - (10 minutes). - - If this parameter is 0, a default value of 10 seconds is used. - - For push delivery, this value is also used to set the request timeout for the call - to the push endpoint. - - If the subscriber never acknowledges the message, the Pub/Sub system will eventually - redeliver the message. + - A URL locating the endpoint to which messages should be pushed. + - For example, a Webhook endpoint might use "U(https://example.com/push".) required: false + ack_deadline_seconds: + description: + - This value is the maximum time after a subscriber receives a message before + the subscriber should acknowledge the message. After message delivery but before + the ack deadline expires and before the message is acknowledged, it is an outstanding + message and will not be delivered again during that time (on a best-effort basis). + - For pull subscriptions, this value is used as the initial value for the ack + deadline. To override this value for a given message, call subscriptions.modifyAckDeadline + with the corresponding ackId if using pull. The minimum custom deadline you + can specify is 10 seconds. The maximum custom deadline you can specify is 600 + seconds (10 minutes). + - If this parameter is 0, a default value of 10 seconds is used. + - For push delivery, this value is also used to set the request timeout for the + call to the push endpoint. + - If the subscriber never acknowledges the message, the Pub/Sub system will eventually + redeliver the message. + required: false extends_documentation_fragment: gcp ''' @@ -116,48 +118,48 @@ EXAMPLES = ''' ''' RETURN = ''' - name: - description: - - Name of the subscription. - returned: success - type: str - topic: - description: - - A reference to a Topic resource. - returned: success - type: dict - pushConfig: - description: - - If push delivery is used with this subscription, this field is used to configure - it. An empty pushConfig signifies that the subscriber will pull and ack messages - using API methods. - returned: success - type: complex - contains: - pushEndpoint: - description: - - A URL locating the endpoint to which messages should be pushed. - - For example, a Webhook endpoint might use "U(https://example.com/push".) - returned: success - type: str - ackDeadlineSeconds: - description: - - This value is the maximum time after a subscriber receives a message before the - subscriber should acknowledge the message. After message delivery but before the - ack deadline expires and before the message is acknowledged, it is an outstanding - message and will not be delivered again during that time (on a best-effort basis). - - For pull subscriptions, this value is used as the initial value for the ack deadline. - To override this value for a given message, call subscriptions.modifyAckDeadline - with the corresponding ackId if using pull. The minimum custom deadline you can - specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds - (10 minutes). - - If this parameter is 0, a default value of 10 seconds is used. - - For push delivery, this value is also used to set the request timeout for the call - to the push endpoint. - - If the subscriber never acknowledges the message, the Pub/Sub system will eventually - redeliver the message. - returned: success - type: int +name: + description: + - Name of the subscription. + returned: success + type: str +topic: + description: + - A reference to a Topic resource. + returned: success + type: dict +pushConfig: + description: + - If push delivery is used with this subscription, this field is used to configure + it. An empty pushConfig signifies that the subscriber will pull and ack messages + using API methods. + returned: success + type: complex + contains: + pushEndpoint: + description: + - A URL locating the endpoint to which messages should be pushed. + - For example, a Webhook endpoint might use "U(https://example.com/push".) + returned: success + type: str +ackDeadlineSeconds: + description: + - This value is the maximum time after a subscriber receives a message before the + subscriber should acknowledge the message. After message delivery but before the + ack deadline expires and before the message is acknowledged, it is an outstanding + message and will not be delivered again during that time (on a best-effort basis). + - For pull subscriptions, this value is used as the initial value for the ack deadline. + To override this value for a given message, call subscriptions.modifyAckDeadline + with the corresponding ackId if using pull. The minimum custom deadline you can + specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds + (10 minutes). + - If this parameter is 0, a default value of 10 seconds is used. + - For push delivery, this value is also used to set the request timeout for the + call to the push endpoint. + - If the subscriber never acknowledges the message, the Pub/Sub system will eventually + redeliver the message. + returned: success + type: int ''' ################################################################################ @@ -235,7 +237,7 @@ def resource_to_request(module): request = { u'name': module.params.get('name'), u'topic': replace_resource_dict(module.params.get(u'topic', {}), 'name'), - u'pushConfig': SubscriptionPushConfig(module.params.get('push_config', {}), module).to_request(), + u'pushConfig': SubscriptionPushconfig(module.params.get('push_config', {}), module).to_request(), u'ackDeadlineSeconds': module.params.get('ack_deadline_seconds') } request = encode_request(request, module) @@ -308,7 +310,7 @@ def response_to_hash(module, response): return { u'name': response.get(u'name'), u'topic': response.get(u'topic'), - u'pushConfig': SubscriptionPushConfig(response.get(u'pushConfig', {}), module).from_response(), + u'pushConfig': SubscriptionPushconfig(response.get(u'pushConfig', {}), module).from_response(), u'ackDeadlineSeconds': response.get(u'ackDeadlineSeconds') } @@ -332,7 +334,7 @@ def encode_request(request, module): return request -class SubscriptionPushConfig(object): +class SubscriptionPushconfig(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py index 244d6a4fa8..ea1f16dd7d 100644 --- a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_facts.py @@ -32,14 +32,15 @@ DOCUMENTATION = ''' --- module: gcp_pubsub_subscription_facts description: - - Gather facts for GCP Subscription +- Gather facts for GCP Subscription short_description: Gather facts for GCP Subscription version_added: 2.8 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 +options: {} extends_documentation_fragment: gcp ''' @@ -53,52 +54,53 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - name: - description: - - Name of the subscription. - returned: success - type: str - topic: - description: - - A reference to a Topic resource. - returned: success - type: dict - pushConfig: - description: - - If push delivery is used with this subscription, this field is used to configure - it. An empty pushConfig signifies that the subscriber will pull and ack messages - using API methods. - returned: success - type: complex - contains: - pushEndpoint: - description: - - A URL locating the endpoint to which messages should be pushed. - - For example, a Webhook endpoint might use "U(https://example.com/push".) - returned: success - type: str - ackDeadlineSeconds: - description: - - This value is the maximum time after a subscriber receives a message before the - subscriber should acknowledge the message. After message delivery but before the - ack deadline expires and before the message is acknowledged, it is an outstanding - message and will not be delivered again during that time (on a best-effort basis). - - For pull subscriptions, this value is used as the initial value for the ack deadline. - To override this value for a given message, call subscriptions.modifyAckDeadline - with the corresponding ackId if using pull. The minimum custom deadline you can - specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds - (10 minutes). - - If this parameter is 0, a default value of 10 seconds is used. - - For push delivery, this value is also used to set the request timeout for the call - to the push endpoint. - - If the subscriber never acknowledges the message, the Pub/Sub system will eventually - redeliver the message. - returned: success - type: int + description: List of items + returned: always + type: complex + contains: + name: + description: + - Name of the subscription. + returned: success + type: str + topic: + description: + - A reference to a Topic resource. + returned: success + type: dict + pushConfig: + description: + - If push delivery is used with this subscription, this field is used to configure + it. An empty pushConfig signifies that the subscriber will pull and ack messages + using API methods. + returned: success + type: complex + contains: + pushEndpoint: + description: + - A URL locating the endpoint to which messages should be pushed. + - For example, a Webhook endpoint might use "U(https://example.com/push".) + returned: success + type: str + ackDeadlineSeconds: + description: + - This value is the maximum time after a subscriber receives a message before + the subscriber should acknowledge the message. After message delivery but + before the ack deadline expires and before the message is acknowledged, it + is an outstanding message and will not be delivered again during that time + (on a best-effort basis). + - For pull subscriptions, this value is used as the initial value for the ack + deadline. To override this value for a given message, call subscriptions.modifyAckDeadline + with the corresponding ackId if using pull. The minimum custom deadline you + can specify is 10 seconds. The maximum custom deadline you can specify is + 600 seconds (10 minutes). + - If this parameter is 0, a default value of 10 seconds is used. + - For push delivery, this value is also used to set the request timeout for + the call to the push endpoint. + - If the subscriber never acknowledges the message, the Pub/Sub system will + eventually redeliver the message. + returned: success + type: int ''' ################################################################################ @@ -118,7 +120,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub'] items = fetch_list(module, collection(module)) diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py b/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py index 1a266d46eb..a5d6027cbf 100644 --- a/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py +++ b/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py @@ -32,24 +32,26 @@ DOCUMENTATION = ''' --- module: gcp_pubsub_topic description: - - A named resource to which messages are sent by publishers. +- A named resource to which messages are sent by publishers. short_description: Creates a GCP Topic version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - Name of the topic. - required: false + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - Name of the topic. + required: false extends_documentation_fragment: gcp ''' @@ -64,11 +66,11 @@ EXAMPLES = ''' ''' RETURN = ''' - name: - description: - - Name of the topic. - returned: success - type: str +name: + description: + - Name of the topic. + returned: success + type: str ''' ################################################################################ diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py b/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py index 14e4b0d60a..b9f42cdf2c 100644 --- a/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py +++ b/lib/ansible/modules/cloud/google/gcp_pubsub_topic_facts.py @@ -32,14 +32,15 @@ DOCUMENTATION = ''' --- module: gcp_pubsub_topic_facts description: - - Gather facts for GCP Topic +- Gather facts for GCP Topic short_description: Gather facts for GCP Topic version_added: 2.8 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 +options: {} extends_documentation_fragment: gcp ''' @@ -53,15 +54,15 @@ EXAMPLES = ''' RETURN = ''' items: - description: List of items - returned: always - type: complex - contains: - name: - description: - - Name of the topic. - returned: success - type: str + description: List of items + returned: always + type: complex + contains: + name: + description: + - Name of the topic. + returned: success + type: str ''' ################################################################################ @@ -81,7 +82,7 @@ def main(): ) ) - if 'scopes' not in module.params: + if not module.params['scopes']: module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub'] items = fetch_list(module, collection(module)) diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_database.py b/lib/ansible/modules/cloud/google/gcp_spanner_database.py index 3b23cef1dc..f3f84f411d 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_database.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_database.py @@ -32,41 +32,44 @@ DOCUMENTATION = ''' --- module: gcp_spanner_database description: - - A Cloud Spanner Database which is hosted on a Spanner instance. +- A Cloud Spanner Database which is hosted on a Spanner instance. short_description: Creates a GCP Database version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - A unique identifier for the database, which cannot be changed after the instance - is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. - The final segment of the name must be between 6 and 30 characters in length. - required: false - extra_statements: - description: - - 'An optional list of DDL statements to run inside the newly created database. Statements - can create tables, indexes, etc. These statements execute atomically with the creation - of the database: if there is an error in any statement, the database is not created.' - required: false - instance: - 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.' - required: true + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - A unique identifier for the database, which cannot be changed after the instance + is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. + The final segment of the name must be between 6 and 30 characters in length. + required: false + extra_statements: + description: + - 'An optional list of DDL statements to run inside the newly created database. + Statements can create tables, indexes, etc. These statements execute atomically + with the creation of the database: if there is an error in any statement, the + database is not created.' + required: false + instance: + 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' + required: true extends_documentation_fragment: gcp ''' @@ -96,25 +99,26 @@ EXAMPLES = ''' ''' RETURN = ''' - name: - description: - - A unique identifier for the database, which cannot be changed after the instance - is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. - The final segment of the name must be between 6 and 30 characters in length. - returned: success - type: str - extraStatements: - description: - - 'An optional list of DDL statements to run inside the newly created database. Statements - can create tables, indexes, etc. These statements execute atomically with the creation - of the database: if there is an error in any statement, the database is not created.' - returned: success - type: list - instance: - description: - - The instance to create the database on. - returned: success - type: dict +name: + description: + - A unique identifier for the database, which cannot be changed after the instance + is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. + The final segment of the name must be between 6 and 30 characters in length. + returned: success + type: str +extraStatements: + description: + - 'An optional list of DDL statements to run inside the newly created database. + Statements can create tables, indexes, etc. These statements execute atomically + with the creation of the database: if there is an error in any statement, the + database is not created.' + returned: success + type: list +instance: + description: + - The instance to create the database on. + returned: success + type: dict ''' ################################################################################ diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py b/lib/ansible/modules/cloud/google/gcp_spanner_instance.py index dcac37f969..1d4fe334d7 100644 --- a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_spanner_instance.py @@ -32,60 +32,62 @@ DOCUMENTATION = ''' --- module: gcp_spanner_instance description: - - An isolated set of Cloud Spanner resources on which databases can be hosted. +- An isolated set of Cloud Spanner resources on which databases can be hosted. short_description: Creates a GCP Instance version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - name: - description: - - A unique identifier for the instance, which cannot be changed after the instance - is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. - The final segment of the name must be between 6 and 30 characters in length. - required: false - config: - description: - - A reference to the instance configuration. - required: false - display_name: - description: - - The descriptive name for this instance as it appears in UIs. Must be unique per - project and between 4 and 30 characters in length. - required: true - node_count: - description: - - The number of nodes allocated to this instance. - required: false - labels: - description: - - Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources - into groups that reflect a customer's organizational needs and deployment strategies. - Cloud Labels can be used to filter collections of resources. They can be used to - control how resource metrics are aggregated. And they can be used as arguments to - policy management rules (e.g. route, firewall, load balancing, etc.). - - 'Label keys must be between 1 and 63 characters long and must conform to the following - regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.' - - Label values must be between 0 and 63 characters long and must conform to the regular - expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. - - No more than 64 labels can be associated with a given resource. - - See U(https://goo.gl/xmQnxf) for more information on and examples of labels. - - 'If you plan to use labels in your own code, please note that additional characters - may be allowed in the future. And so you are advised to use an internal label representation, - such as JSON, which doesn''t rely upon specific characters being disallowed. For - example, representing labels as the string: name + "_" + value would prove problematic - if we were to allow "_" in a future release.' - - 'An object containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - required: false + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + name: + description: + - A unique identifier for the instance, which cannot be changed after the instance + is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. + The final segment of the name must be between 6 and 30 characters in length. + required: false + config: + description: + - A reference to the instance configuration. + required: false + display_name: + description: + - The descriptive name for this instance as it appears in UIs. Must be unique + per project and between 4 and 30 characters in length. + required: true + node_count: + description: + - The number of nodes allocated to this instance. + required: false + labels: + description: + - Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources + into groups that reflect a customer's organizational needs and deployment strategies. + Cloud Labels can be used to filter collections of resources. They can be used + to control how resource metrics are aggregated. And they can be used as arguments + to policy management rules (e.g. route, firewall, load balancing, etc.). + - 'Label keys must be between 1 and 63 characters long and must conform to the + following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.' + - Label values must be between 0 and 63 characters long and must conform to the + regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. + - No more than 64 labels can be associated with a given resource. + - See U(https://goo.gl/xmQnxf) for more information on and examples of labels. + - 'If you plan to use labels in your own code, please note that additional characters + may be allowed in the future. And so you are advised to use an internal label + representation, such as JSON, which doesn''t rely upon specific characters being + disallowed. For example, representing labels as the string: name + "_" + value + would prove problematic if we were to allow "_" in a future release.' + - 'An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + required: false extends_documentation_fragment: gcp ''' @@ -105,51 +107,51 @@ EXAMPLES = ''' ''' RETURN = ''' - name: - description: - - A unique identifier for the instance, which cannot be changed after the instance - is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. - The final segment of the name must be between 6 and 30 characters in length. - returned: success - type: str - config: - description: - - A reference to the instance configuration. - returned: success - type: str - displayName: - description: - - The descriptive name for this instance as it appears in UIs. Must be unique per - project and between 4 and 30 characters in length. - returned: success - type: str - nodeCount: - description: - - The number of nodes allocated to this instance. - returned: success - type: int - labels: - description: - - Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources - into groups that reflect a customer's organizational needs and deployment strategies. - Cloud Labels can be used to filter collections of resources. They can be used to - control how resource metrics are aggregated. And they can be used as arguments to - policy management rules (e.g. route, firewall, load balancing, etc.). - - 'Label keys must be between 1 and 63 characters long and must conform to the following - regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.' - - Label values must be between 0 and 63 characters long and must conform to the regular - expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. - - No more than 64 labels can be associated with a given resource. - - See U(https://goo.gl/xmQnxf) for more information on and examples of labels. - - 'If you plan to use labels in your own code, please note that additional characters - may be allowed in the future. And so you are advised to use an internal label representation, - such as JSON, which doesn''t rely upon specific characters being disallowed. For - example, representing labels as the string: name + "_" + value would prove problematic - if we were to allow "_" in a future release.' - - 'An object containing a list of "key": value pairs.' - - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - returned: success - type: dict +name: + description: + - A unique identifier for the instance, which cannot be changed after the instance + is created. Values are of the form projects//instances/[a-z][-a-z0-9]*[a-z0-9]. + The final segment of the name must be between 6 and 30 characters in length. + returned: success + type: str +config: + description: + - A reference to the instance configuration. + returned: success + type: str +displayName: + description: + - The descriptive name for this instance as it appears in UIs. Must be unique per + project and between 4 and 30 characters in length. + returned: success + type: str +nodeCount: + description: + - The number of nodes allocated to this instance. + returned: success + type: int +labels: + description: + - Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources + into groups that reflect a customer's organizational needs and deployment strategies. + Cloud Labels can be used to filter collections of resources. They can be used + to control how resource metrics are aggregated. And they can be used as arguments + to policy management rules (e.g. route, firewall, load balancing, etc.). + - 'Label keys must be between 1 and 63 characters long and must conform to the following + regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.' + - Label values must be between 0 and 63 characters long and must conform to the + regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. + - No more than 64 labels can be associated with a given resource. + - See U(https://goo.gl/xmQnxf) for more information on and examples of labels. + - 'If you plan to use labels in your own code, please note that additional characters + may be allowed in the future. And so you are advised to use an internal label + representation, such as JSON, which doesn''t rely upon specific characters being + disallowed. For example, representing labels as the string: name + "_" + value + would prove problematic if we were to allow "_" in a future release.' + - 'An object containing a list of "key": value pairs.' + - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' + returned: success + type: dict ''' ################################################################################ diff --git a/lib/ansible/modules/cloud/google/gcp_sql_database.py b/lib/ansible/modules/cloud/google/gcp_sql_database.py index 2069aeded4..e1d0832edc 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_database.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_database.py @@ -32,42 +32,44 @@ DOCUMENTATION = ''' --- module: gcp_sql_database description: - - Represents a SQL database inside the Cloud SQL instance, hosted in Google's cloud. +- Represents a SQL database inside the Cloud SQL instance, hosted in Google's cloud. short_description: Creates a GCP Database version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - charset: - description: - - The MySQL charset value. - required: false - collation: - description: - - The MySQL collation value. - required: false - name: - description: - - The name of the database in the Cloud SQL instance. - - This does not include the project ID or instance name. - required: false - instance: - 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.' - required: true + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + charset: + description: + - The MySQL charset value. + required: false + collation: + description: + - The MySQL collation value. + required: false + name: + description: + - The name of the database in the Cloud SQL instance. + - This does not include the project ID or instance name. + required: false + instance: + 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' + required: true extends_documentation_fragment: gcp ''' @@ -100,27 +102,27 @@ EXAMPLES = ''' ''' RETURN = ''' - charset: - description: - - The MySQL charset value. - returned: success - type: str - collation: - description: - - The MySQL collation value. - returned: success - type: str - name: - description: - - The name of the database in the Cloud SQL instance. - - This does not include the project ID or instance name. - returned: success - type: str - instance: - description: - - The name of the Cloud SQL instance. This does not include the project ID. - returned: success - type: dict +charset: + description: + - The MySQL charset value. + returned: success + type: str +collation: + description: + - The MySQL collation value. + returned: success + type: str +name: + description: + - The name of the database in the Cloud SQL instance. + - This does not include the project ID or instance name. + returned: success + type: str +instance: + description: + - The name of the Cloud SQL instance. This does not include the project ID. + returned: success + type: dict ''' ################################################################################ @@ -234,7 +236,7 @@ def collection(module): def return_if_object(module, response, kind, allow_not_found=False): # If not found, return nothing. - if response.status_code == 404: + if allow_not_found and response.status_code == 404: return None # If no content, return nothing. @@ -242,7 +244,7 @@ def return_if_object(module, response, kind, allow_not_found=False): return None # SQL only: return on 403 if not exist - if response.status_code == 403: + if allow_not_found and response.status_code == 403: return None try: @@ -252,8 +254,6 @@ def return_if_object(module, response, kind, allow_not_found=False): if navigate_hash(result, ['error', 'errors']): module.fail_json(msg=navigate_hash(result, ['error', 'errors'])) - if result['kind'] != kind: - module.fail_json(msg="Incorrect result: {kind}".format(**result)) return result @@ -310,8 +310,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'sql#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_sql_instance.py b/lib/ansible/modules/cloud/google/gcp_sql_instance.py index e298130935..2a9938f3a3 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_instance.py @@ -32,226 +32,241 @@ DOCUMENTATION = ''' --- module: gcp_sql_instance description: - - Represents a Cloud SQL instance. Cloud SQL instances are SQL databases hosted in - Google's cloud. The Instances resource provides methods for common configuration - and management tasks. +- Represents a Cloud SQL instance. Cloud SQL instances are SQL databases hosted in + Google's cloud. The Instances resource provides methods for common configuration + and management tasks. short_description: Creates a GCP Instance version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + backend_type: + description: + - "* 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." + required: false + choices: + - FIRST_GEN + - SECOND_GEN + - EXTERNAL + connection_name: + description: + - Connection name of the Cloud SQL instance used in connection strings. + required: false + database_version: + description: + - The database engine type and version. For First Generation instances, can be + MYSQL_5_5, or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or + MYSQL_5_7. Defaults to MYSQL_5_6. + - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be + changed after instance creation.' + 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 + to Second Generation instances. + required: false + suboptions: + available: description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - backend_type: - description: - - "* 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." + - 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. required: false - choices: ['FIRST_GEN', 'SECOND_GEN', 'EXTERNAL'] - connection_name: + type: bool + name: description: - - Connection name of the Cloud SQL instance used in connection strings. + - The name of the failover replica. If specified at instance creation, a failover + replica is created for the instance. The name doesn't include the project + ID. This property is applicable only to Second Generation instances. required: false - database_version: + instance_type: + description: + - The instance type. This can be one of the following. + - "* 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." + 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 + to First Generation instances. + required: false + master_instance_name: + description: + - The name of the instance which will act as master in the replication setup. + required: false + max_disk_size: + description: + - The maximum disk size of the instance in bytes. + required: false + name: + description: + - Name of the Cloud SQL instance. This does not include the project ID. + required: true + region: + description: + - The geographical region. Defaults to us-central or us-central1 depending on + the instance type (First Generation or Second Generation/PostgreSQL). + required: false + replica_configuration: + description: + - Configuration specific to failover replicas and read replicas. + required: false + suboptions: + failover_target: description: - - The database engine type and version. For First Generation instances, can be MYSQL_5_5, - or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or MYSQL_5_7. Defaults - to MYSQL_5_6. - - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be changed - after instance creation.' + - Specifies if the replica is the failover target. If the field is set to + true the replica will be designated as a failover replica. + - In case the master instance fails, the replica instance will be promoted + as the new master instance. + - Only one replica can be specified as failover target, and the replica has + to be in different zone with the master instance. required: false - choices: ['MYSQL_5_5', 'MYSQL_5_6', 'MYSQL_5_7', 'POSTGRES_9_6'] - failover_replica: + type: bool + mysql_replica_configuration: description: - - The name and status of the failover replica. This property is applicable only to - Second Generation instances. + - MySQL specific configuration when replicating from a MySQL on-premises master. + Replication configuration information such as the username, password, certificates, + and keys are not stored in the instance metadata. The configuration information + is used only to set up the replication connection and is stored by MySQL + in a file named master.info in the data directory. required: false suboptions: - available: - 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. - required: false - type: bool - name: - description: - - The name of the failover replica. If specified at instance creation, a failover - replica is created for the instance. The name doesn't include the project ID. This - property is applicable only to Second Generation instances. - required: false - instance_type: + ca_certificate: + description: + - PEM representation of the trusted CA's x509 certificate. + required: false + client_certificate: + description: + - PEM representation of the slave's x509 certificate . + 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. + required: false + connect_retry_interval: + description: + - Seconds to wait between connect retries. MySQL's default is 60 seconds. + required: false + dump_file_path: + description: + - Path to a SQL dump file in Google Cloud Storage from which the slave + instance is to be created. The URI is in the form gs://bucketName/fileName. + Compressed gzip files (.gz) are also supported. Dumps should have the + binlog co-ordinates from which replication should begin. This can be + accomplished by setting --master-data to 1 when using mysqldump. + required: false + master_heartbeat_period: + description: + - Interval in milliseconds between replication heartbeats. + required: false + password: + description: + - The password for the replication connection. + required: false + ssl_cipher: + description: + - A list of permissible ciphers to use for SSL encryption. + required: false + username: + description: + - The username for the replication connection. + required: false + verify_server_certificate: + description: + - Whether or not to check the master's Common Name value in the certificate + that it sends during the SSL handshake. + required: false + type: bool + replica_names: description: - - The instance type. This can be one of the following. - - "* 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." + - The replicas of the instance. required: false - choices: ['CLOUD_SQL_INSTANCE', 'ON_PREMISES_INSTANCE', 'READ_REPLICA_INSTANCE'] - ipv6_address: + service_account_email_address: description: - - The IPv6 address assigned to the instance. This property is applicable only to First - Generation instances. + - The service account email address assigned to the instance. This property + is applicable only to Second Generation instances. required: false - master_instance_name: + settings: + description: + - The user settings. + required: false + suboptions: + ip_configuration: description: - - The name of the instance which will act as master in the replication setup. - required: false - max_disk_size: - description: - - The maximum disk size of the instance in bytes. - required: false - name: - description: - - Name of the Cloud SQL instance. This does not include the project ID. - required: true - region: - description: - - The geographical region. Defaults to us-central or us-central1 depending on the - instance type (First Generation or Second Generation/PostgreSQL). - required: false - replica_configuration: - description: - - Configuration specific to failover replicas and read replicas. + - The settings for IP Management. This allows to enable or disable the instance + IP and manage which external networks can connect to the instance. The IPv4 + address cannot be disabled for Second Generation instances. required: false suboptions: - failover_target: + ipv4_enabled: + description: + - Whether the instance should be assigned an IP address or not. + required: false + type: bool + authorized_networks: + description: + - The list of external networks that are allowed to connect to the instance + using the IP. In CIDR notation, also known as 'slash' notation (e.g. + 192.168.100.0/24). + required: false + suboptions: + expiration_time: description: - - Specifies if the replica is the failover target. If the field is set to true the - replica will be designated as a failover replica. - - In case the master instance fails, the replica instance will be promoted as the - new master instance. - - Only one replica can be specified as failover target, and the replica has to be - in different zone with the master instance. + - The time when this access control entry expires in RFC 3339 format, + for example 2012-11-15T16:19:00.094Z. required: false - type: bool - mysql_replica_configuration: + name: description: - - MySQL specific configuration when replicating from a MySQL on-premises master. Replication - configuration information such as the username, password, certificates, and keys - are not stored in the instance metadata. The configuration information is used - only to set up the replication connection and is stored by MySQL in a file named - master.info in the data directory. + - An optional label to identify this entry. required: false - suboptions: - ca_certificate: - description: - - PEM representation of the trusted CA's x509 certificate. - required: false - client_certificate: - description: - - PEM representation of the slave's x509 certificate . - 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. - required: false - connect_retry_interval: - description: - - Seconds to wait between connect retries. MySQL's default is 60 seconds. - required: false - dump_file_path: - description: - - Path to a SQL dump file in Google Cloud Storage from which the slave instance is - to be created. The URI is in the form gs://bucketName/fileName. Compressed gzip - files (.gz) are also supported. Dumps should have the binlog co-ordinates from which - replication should begin. This can be accomplished by setting --master-data to 1 - when using mysqldump. - required: false - master_heartbeat_period: - description: - - Interval in milliseconds between replication heartbeats. - required: false - password: - description: - - The password for the replication connection. - required: false - ssl_cipher: - description: - - A list of permissible ciphers to use for SSL encryption. - required: false - username: - description: - - The username for the replication connection. - required: false - verify_server_certificate: - description: - - Whether or not to check the master's Common Name value in the certificate that it - sends during the SSL handshake. - required: false - type: bool - replica_names: + value: description: - - The replicas of the instance. + - The whitelisted value for the access control list. For example, + to grant access to a client from an external IP (IPv4 or IPv6) address + or subnet, use that address or subnet here. required: false - service_account_email_address: - description: - - The service account email address assigned to the instance. This property is applicable - only to Second Generation instances. - required: false - settings: + require_ssl: + description: + - Whether the mysqld should default to 'REQUIRE X509' for users connecting + over IP. + required: false + type: bool + tier: description: - - The user settings. + - The tier or machine type for this instance, for example db-n1-standard-1. + For MySQL instances, this field determines whether the instance is Second + Generation (recommended) or First Generation. + required: false + settings_version: + description: + - The version of instance settings. This is a required field for update method + to make sure concurrent updates are handled properly. During update, use + the most recent settingsVersion value for this instance and do not try to + update this value. required: false - suboptions: - ip_configuration: - description: - - The settings for IP Management. This allows to enable or disable the instance IP - and manage which external networks can connect to the instance. The IPv4 address - cannot be disabled for Second Generation instances. - required: false - suboptions: - ipv4_enabled: - description: - - Whether the instance should be assigned an IP address or not. - required: false - type: bool - authorized_networks: - description: - - The list of external networks that are allowed to connect to the instance using - the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24). - required: false - suboptions: - expiration_time: - description: - - The time when this access control entry expires in RFC 3339 format, for example - 2012-11-15T16:19:00.094Z. - required: false - name: - description: - - An optional label to identify this entry. - required: false - value: - description: - - The whitelisted value for the access control list. For example, to grant access - to a client from an external IP (IPv4 or IPv6) address or subnet, use that address - or subnet here. - required: false - require_ssl: - description: - - Whether the mysqld should default to 'REQUIRE X509' for users connecting over IP. - required: false - type: bool - tier: - description: - - The tier or machine type for this instance, for example db-n1-standard-1. For MySQL - instances, this field determines whether the instance is Second Generation (recommended) - or First Generation. - required: false - settings_version: - description: - - The version of instance settings. This is a required field for update method to - make sure concurrent updates are handled properly. During update, use the most - recent settingsVersion value for this instance and do not try to update this value. - required: false extends_documentation_fragment: gcp ''' @@ -273,263 +288,265 @@ EXAMPLES = ''' ''' RETURN = ''' - backendType: - description: - - "* 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." - returned: success - type: str - connectionName: - description: - - Connection name of the Cloud SQL instance used in connection strings. - returned: success - type: str - databaseVersion: - description: - - The database engine type and version. For First Generation instances, can be MYSQL_5_5, - or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or MYSQL_5_7. Defaults - to MYSQL_5_6. - - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be changed - after instance creation.' - returned: success - type: str - failoverReplica: - description: - - The name and status of the failover replica. This property is applicable only to - Second Generation instances. - returned: success - type: complex - contains: - available: - 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. - returned: success - type: bool - name: - description: - - The name of the failover replica. If specified at instance creation, a failover - replica is created for the instance. The name doesn't include the project ID. This - property is applicable only to Second Generation instances. - returned: success - type: str - instanceType: - description: - - The instance type. This can be one of the following. - - "* 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." - returned: success - type: str - ipAddresses: - description: - - The assigned IP addresses for the instance. - returned: success - type: complex - contains: - ipAddress: - description: - - The IP address assigned. - returned: success - type: str - timeToRetire: - description: - - The due time for this IP to be retired in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. - This field is only available when the IP is scheduled to be retired. - returned: success - type: str - type: - description: - - The type of this IP address. A PRIMARY address is an address that can accept incoming - connections. An OUTGOING address is the source address of connections originating - from the instance, if supported. - returned: success - type: str - ipv6Address: - description: - - The IPv6 address assigned to the instance. This property is applicable only to First - Generation instances. - returned: success - type: str - masterInstanceName: - description: - - The name of the instance which will act as master in the replication setup. - returned: success - type: str - maxDiskSize: - description: - - The maximum disk size of the instance in bytes. - returned: success - type: int +backendType: + description: + - "* 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." + returned: success + type: str +connectionName: + description: + - Connection name of the Cloud SQL instance used in connection strings. + returned: success + type: str +databaseVersion: + description: + - The database engine type and version. For First Generation instances, can be MYSQL_5_5, + or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or MYSQL_5_7. + Defaults to MYSQL_5_6. + - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be changed + after instance creation.' + returned: success + type: str +failoverReplica: + description: + - The name and status of the failover replica. This property is applicable only + to Second Generation instances. + returned: success + type: complex + contains: + available: + 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. + returned: success + type: bool name: - description: - - Name of the Cloud SQL instance. This does not include the project ID. - returned: success - type: str - region: - description: - - The geographical region. Defaults to us-central or us-central1 depending on the - instance type (First Generation or Second Generation/PostgreSQL). - returned: success - type: str - replicaConfiguration: - description: - - Configuration specific to failover replicas and read replicas. - returned: success - type: complex - contains: - failoverTarget: - description: - - Specifies if the replica is the failover target. If the field is set to true the - replica will be designated as a failover replica. - - In case the master instance fails, the replica instance will be promoted as the - new master instance. - - Only one replica can be specified as failover target, and the replica has to be - in different zone with the master instance. - returned: success - type: bool - mysqlReplicaConfiguration: - description: - - MySQL specific configuration when replicating from a MySQL on-premises master. Replication - configuration information such as the username, password, certificates, and keys - are not stored in the instance metadata. The configuration information is used - only to set up the replication connection and is stored by MySQL in a file named - master.info in the data directory. - returned: success - type: complex - contains: - caCertificate: - description: - - PEM representation of the trusted CA's x509 certificate. - returned: success - type: str - clientCertificate: - description: - - PEM representation of the slave's x509 certificate . - returned: success - 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. - returned: success - type: str - connectRetryInterval: - description: - - Seconds to wait between connect retries. MySQL's default is 60 seconds. - returned: success - type: int - dumpFilePath: - description: - - Path to a SQL dump file in Google Cloud Storage from which the slave instance is - to be created. The URI is in the form gs://bucketName/fileName. Compressed gzip - files (.gz) are also supported. Dumps should have the binlog co-ordinates from which - replication should begin. This can be accomplished by setting --master-data to 1 - when using mysqldump. - returned: success - type: str - masterHeartbeatPeriod: - description: - - Interval in milliseconds between replication heartbeats. - returned: success - type: int - password: - description: - - The password for the replication connection. - returned: success - type: str - sslCipher: - description: - - A list of permissible ciphers to use for SSL encryption. - returned: success - type: str - username: - description: - - The username for the replication connection. - returned: success - type: str - verifyServerCertificate: - description: - - Whether or not to check the master's Common Name value in the certificate that it - sends during the SSL handshake. - returned: success - type: bool - replicaNames: - description: - - The replicas of the instance. - returned: success - type: list - serviceAccountEmailAddress: - description: - - The service account email address assigned to the instance. This property is applicable - only to Second Generation instances. - returned: success - type: str - settings: - description: - - The user settings. - returned: success - type: complex - contains: - ipConfiguration: - description: - - The settings for IP Management. This allows to enable or disable the instance IP - and manage which external networks can connect to the instance. The IPv4 address - cannot be disabled for Second Generation instances. - returned: success - type: complex - contains: - ipv4Enabled: - description: - - Whether the instance should be assigned an IP address or not. - returned: success - type: bool - authorizedNetworks: - description: - - The list of external networks that are allowed to connect to the instance using - the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24). - returned: success - type: complex - contains: - expirationTime: - description: - - The time when this access control entry expires in RFC 3339 format, for example - 2012-11-15T16:19:00.094Z. - returned: success - type: str - name: - description: - - An optional label to identify this entry. - returned: success - type: str - value: - description: - - The whitelisted value for the access control list. For example, to grant access - to a client from an external IP (IPv4 or IPv6) address or subnet, use that address - or subnet here. - returned: success - type: str - requireSsl: - description: - - Whether the mysqld should default to 'REQUIRE X509' for users connecting over IP. - returned: success - type: bool - tier: - description: - - The tier or machine type for this instance, for example db-n1-standard-1. For MySQL - instances, this field determines whether the instance is Second Generation (recommended) - or First Generation. - returned: success - type: str - settingsVersion: - description: - - The version of instance settings. This is a required field for update method to - make sure concurrent updates are handled properly. During update, use the most - recent settingsVersion value for this instance and do not try to update this value. - returned: success - type: int + description: + - The name of the failover replica. If specified at instance creation, a failover + replica is created for the instance. The name doesn't include the project + ID. This property is applicable only to Second Generation instances. + returned: success + type: str +instanceType: + description: + - The instance type. This can be one of the following. + - "* 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." + returned: success + type: str +ipAddresses: + description: + - The assigned IP addresses for the instance. + returned: success + type: complex + contains: + ipAddress: + description: + - The IP address assigned. + returned: success + type: str + timeToRetire: + description: + - The due time for this IP to be retired in RFC 3339 format, for example 2012-11-15T16:19:00.094Z. + This field is only available when the IP is scheduled to be retired. + returned: success + type: str + type: + description: + - The type of this IP address. A PRIMARY address is an address that can accept + incoming connections. An OUTGOING address is the source address of connections + originating from the instance, if supported. + returned: success + type: str +ipv6Address: + description: + - The IPv6 address assigned to the instance. This property is applicable only to + First Generation instances. + returned: success + type: str +masterInstanceName: + description: + - The name of the instance which will act as master in the replication setup. + returned: success + type: str +maxDiskSize: + description: + - The maximum disk size of the instance in bytes. + returned: success + type: int +name: + description: + - Name of the Cloud SQL instance. This does not include the project ID. + returned: success + type: str +region: + description: + - The geographical region. Defaults to us-central or us-central1 depending on the + instance type (First Generation or Second Generation/PostgreSQL). + returned: success + type: str +replicaConfiguration: + description: + - Configuration specific to failover replicas and read replicas. + returned: success + type: complex + contains: + failoverTarget: + description: + - Specifies if the replica is the failover target. If the field is set to true + the replica will be designated as a failover replica. + - In case the master instance fails, the replica instance will be promoted as + the new master instance. + - Only one replica can be specified as failover target, and the replica has + to be in different zone with the master instance. + returned: success + type: bool + mysqlReplicaConfiguration: + description: + - MySQL specific configuration when replicating from a MySQL on-premises master. + Replication configuration information such as the username, password, certificates, + and keys are not stored in the instance metadata. The configuration information + is used only to set up the replication connection and is stored by MySQL in + a file named master.info in the data directory. + returned: success + type: complex + contains: + caCertificate: + description: + - PEM representation of the trusted CA's x509 certificate. + returned: success + type: str + clientCertificate: + description: + - PEM representation of the slave's x509 certificate . + returned: success + 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. + returned: success + type: str + connectRetryInterval: + description: + - Seconds to wait between connect retries. MySQL's default is 60 seconds. + returned: success + type: int + dumpFilePath: + description: + - Path to a SQL dump file in Google Cloud Storage from which the slave instance + is to be created. The URI is in the form gs://bucketName/fileName. Compressed + gzip files (.gz) are also supported. Dumps should have the binlog co-ordinates + from which replication should begin. This can be accomplished by setting + --master-data to 1 when using mysqldump. + returned: success + type: str + masterHeartbeatPeriod: + description: + - Interval in milliseconds between replication heartbeats. + returned: success + type: int + password: + description: + - The password for the replication connection. + returned: success + type: str + sslCipher: + description: + - A list of permissible ciphers to use for SSL encryption. + returned: success + type: str + username: + description: + - The username for the replication connection. + returned: success + type: str + verifyServerCertificate: + description: + - Whether or not to check the master's Common Name value in the certificate + that it sends during the SSL handshake. + returned: success + type: bool + replicaNames: + description: + - The replicas of the instance. + returned: success + type: list + serviceAccountEmailAddress: + description: + - The service account email address assigned to the instance. This property + is applicable only to Second Generation instances. + returned: success + type: str +settings: + description: + - The user settings. + returned: success + type: complex + contains: + ipConfiguration: + description: + - The settings for IP Management. This allows to enable or disable the instance + IP and manage which external networks can connect to the instance. The IPv4 + address cannot be disabled for Second Generation instances. + returned: success + type: complex + contains: + ipv4Enabled: + description: + - Whether the instance should be assigned an IP address or not. + returned: success + type: bool + authorizedNetworks: + description: + - The list of external networks that are allowed to connect to the instance + using the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24). + returned: success + type: complex + contains: + expirationTime: + description: + - The time when this access control entry expires in RFC 3339 format, + for example 2012-11-15T16:19:00.094Z. + returned: success + type: str + name: + description: + - An optional label to identify this entry. + returned: success + type: str + value: + description: + - The whitelisted value for the access control list. For example, to + grant access to a client from an external IP (IPv4 or IPv6) address + or subnet, use that address or subnet here. + returned: success + type: str + requireSsl: + description: + - Whether the mysqld should default to 'REQUIRE X509' for users connecting + over IP. + returned: success + type: bool + tier: + description: + - The tier or machine type for this instance, for example db-n1-standard-1. + For MySQL instances, this field determines whether the instance is Second + Generation (recommended) or First Generation. + returned: success + type: str + settingsVersion: + description: + - The version of instance settings. This is a required field for update method + to make sure concurrent updates are handled properly. During update, use the + most recent settingsVersion value for this instance and do not try to update + this value. + returned: success + type: int ''' ################################################################################ @@ -649,14 +666,14 @@ def resource_to_request(module): u'backendType': module.params.get('backend_type'), u'connectionName': module.params.get('connection_name'), u'databaseVersion': module.params.get('database_version'), - u'failoverReplica': InstanceFailoverReplica(module.params.get('failover_replica', {}), module).to_request(), + u'failoverReplica': InstanceFailoverreplica(module.params.get('failover_replica', {}), module).to_request(), u'instanceType': module.params.get('instance_type'), u'ipv6Address': module.params.get('ipv6_address'), u'masterInstanceName': module.params.get('master_instance_name'), u'maxDiskSize': module.params.get('max_disk_size'), u'name': module.params.get('name'), u'region': module.params.get('region'), - u'replicaConfiguration': InstanceReplicaConfiguration(module.params.get('replica_configuration', {}), module).to_request(), + u'replicaConfiguration': InstanceReplicaconfiguration(module.params.get('replica_configuration', {}), module).to_request(), u'settings': InstanceSettings(module.params.get('settings', {}), module).to_request() } return_vals = {} @@ -682,7 +699,7 @@ def collection(module): def return_if_object(module, response, kind, allow_not_found=False): # If not found, return nothing. - if response.status_code == 404: + if allow_not_found and response.status_code == 404: return None # If no content, return nothing. @@ -690,7 +707,7 @@ def return_if_object(module, response, kind, allow_not_found=False): return None # SQL only: return on 403 if not exist - if response.status_code == 403: + if allow_not_found and response.status_code == 403: return None try: @@ -700,8 +717,6 @@ def return_if_object(module, response, kind, allow_not_found=False): if navigate_hash(result, ['error', 'errors']): module.fail_json(msg=navigate_hash(result, ['error', 'errors'])) - if result['kind'] != kind: - module.fail_json(msg="Incorrect result: {kind}".format(**result)) return result @@ -731,15 +746,15 @@ def response_to_hash(module, response): u'backendType': response.get(u'backendType'), u'connectionName': response.get(u'connectionName'), u'databaseVersion': response.get(u'databaseVersion'), - u'failoverReplica': InstanceFailoverReplica(response.get(u'failoverReplica', {}), module).from_response(), + u'failoverReplica': InstanceFailoverreplica(response.get(u'failoverReplica', {}), module).from_response(), u'instanceType': response.get(u'instanceType'), - u'ipAddresses': InstanceIpAddressesArray(response.get(u'ipAddresses', []), module).from_response(), + u'ipAddresses': InstanceIpaddressesArray(response.get(u'ipAddresses', []), module).from_response(), u'ipv6Address': response.get(u'ipv6Address'), u'masterInstanceName': response.get(u'masterInstanceName'), u'maxDiskSize': response.get(u'maxDiskSize'), u'name': response.get(u'name'), u'region': response.get(u'region'), - u'replicaConfiguration': InstanceReplicaConfiguration(response.get(u'replicaConfiguration', {}), module).from_response(), + u'replicaConfiguration': InstanceReplicaconfiguration(response.get(u'replicaConfiguration', {}), module).from_response(), u'settings': InstanceSettings(response.get(u'settings', {}), module).from_response() } @@ -768,8 +783,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'sql#operation') status = navigate_hash(op_result, ['status']) return op_result @@ -781,7 +794,7 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) -class InstanceFailoverReplica(object): +class InstanceFailoverreplica(object): def __init__(self, request, module): self.module = module if request: @@ -802,7 +815,7 @@ class InstanceFailoverReplica(object): }) -class InstanceIpAddressesArray(object): +class InstanceIpaddressesArray(object): def __init__(self, request, module): self.module = module if request: @@ -837,7 +850,7 @@ class InstanceIpAddressesArray(object): }) -class InstanceReplicaConfiguration(object): +class InstanceReplicaconfiguration(object): def __init__(self, request, module): self.module = module if request: @@ -848,7 +861,7 @@ class InstanceReplicaConfiguration(object): def to_request(self): return remove_nones_from_dict({ u'failoverTarget': self.request.get('failover_target'), - u'mysqlReplicaConfiguration': InstanceMysqlReplicaConfiguration(self.request.get('mysql_replica_configuration', {}), self.module).to_request(), + u'mysqlReplicaConfiguration': InstanceMysqlreplicaconfiguration(self.request.get('mysql_replica_configuration', {}), self.module).to_request(), u'replicaNames': self.request.get('replica_names'), u'serviceAccountEmailAddress': self.request.get('service_account_email_address') }) @@ -856,13 +869,13 @@ class InstanceReplicaConfiguration(object): def from_response(self): return remove_nones_from_dict({ u'failoverTarget': self.request.get(u'failoverTarget'), - u'mysqlReplicaConfiguration': InstanceMysqlReplicaConfiguration(self.request.get(u'mysqlReplicaConfiguration', {}), self.module).from_response(), + u'mysqlReplicaConfiguration': InstanceMysqlreplicaconfiguration(self.request.get(u'mysqlReplicaConfiguration', {}), self.module).from_response(), u'replicaNames': self.request.get(u'replicaNames'), u'serviceAccountEmailAddress': self.request.get(u'serviceAccountEmailAddress') }) -class InstanceMysqlReplicaConfiguration(object): +class InstanceMysqlreplicaconfiguration(object): def __init__(self, request, module): self.module = module if request: @@ -909,20 +922,20 @@ class InstanceSettings(object): def to_request(self): return remove_nones_from_dict({ - u'ipConfiguration': InstanceIpConfiguration(self.request.get('ip_configuration', {}), self.module).to_request(), + u'ipConfiguration': InstanceIpconfiguration(self.request.get('ip_configuration', {}), self.module).to_request(), u'tier': self.request.get('tier'), u'settingsVersion': self.request.get('settings_version') }) def from_response(self): return remove_nones_from_dict({ - u'ipConfiguration': InstanceIpConfiguration(self.request.get(u'ipConfiguration', {}), self.module).from_response(), + u'ipConfiguration': InstanceIpconfiguration(self.request.get(u'ipConfiguration', {}), self.module).from_response(), u'tier': self.request.get(u'tier'), u'settingsVersion': self.request.get(u'settingsVersion') }) -class InstanceIpConfiguration(object): +class InstanceIpconfiguration(object): def __init__(self, request, module): self.module = module if request: @@ -933,19 +946,19 @@ class InstanceIpConfiguration(object): def to_request(self): return remove_nones_from_dict({ u'ipv4Enabled': self.request.get('ipv4_enabled'), - u'authorizedNetworks': InstanceAuthorizedNetworksArray(self.request.get('authorized_networks', []), self.module).to_request(), + u'authorizedNetworks': InstanceAuthorizednetworksArray(self.request.get('authorized_networks', []), self.module).to_request(), u'requireSsl': self.request.get('require_ssl') }) def from_response(self): return remove_nones_from_dict({ u'ipv4Enabled': self.request.get(u'ipv4Enabled'), - u'authorizedNetworks': InstanceAuthorizedNetworksArray(self.request.get(u'authorizedNetworks', []), self.module).from_response(), + u'authorizedNetworks': InstanceAuthorizednetworksArray(self.request.get(u'authorizedNetworks', []), self.module).from_response(), u'requireSsl': self.request.get(u'requireSsl') }) -class InstanceAuthorizedNetworksArray(object): +class InstanceAuthorizednetworksArray(object): def __init__(self, request, module): self.module = module if request: diff --git a/lib/ansible/modules/cloud/google/gcp_sql_user.py b/lib/ansible/modules/cloud/google/gcp_sql_user.py index d0ab9e7ac1..566352420f 100644 --- a/lib/ansible/modules/cloud/google/gcp_sql_user.py +++ b/lib/ansible/modules/cloud/google/gcp_sql_user.py @@ -32,43 +32,45 @@ DOCUMENTATION = ''' --- module: gcp_sql_user description: - - The Users resource represents a database user in a Cloud SQL instance. +- The Users resource represents a database user in a Cloud SQL instance. short_description: Creates a GCP User version_added: 2.7 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: - description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - host: - description: - - The host name from which the user can connect. For insert operations, host defaults - to an empty string. For update operations, host is specified as part of the request - URL. The host name cannot be updated after insertion. - required: true - name: - description: - - The name of the user in the Cloud SQL instance. - required: true - instance: - 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.' - required: true - password: - description: - - The password for the user. - required: false + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + host: + description: + - The host name from which the user can connect. For insert operations, host defaults + to an empty string. For update operations, host is specified as part of the + request URL. The host name cannot be updated after insertion. + required: true + name: + description: + - The name of the user in the Cloud SQL instance. + required: true + instance: + 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' + required: true + password: + description: + - The password for the user. + required: false extends_documentation_fragment: gcp ''' @@ -102,28 +104,28 @@ EXAMPLES = ''' ''' RETURN = ''' - host: - description: - - The host name from which the user can connect. For insert operations, host defaults - to an empty string. For update operations, host is specified as part of the request - URL. The host name cannot be updated after insertion. - returned: success - type: str - name: - description: - - The name of the user in the Cloud SQL instance. - returned: success - type: str - instance: - description: - - The name of the Cloud SQL instance. This does not include the project ID. - returned: success - type: dict - password: - description: - - The password for the user. - returned: success - type: str +host: + description: + - The host name from which the user can connect. For insert operations, host defaults + to an empty string. For update operations, host is specified as part of the request + URL. The host name cannot be updated after insertion. + returned: success + type: str +name: + description: + - The name of the user in the Cloud SQL instance. + returned: success + type: str +instance: + description: + - The name of the Cloud SQL instance. This does not include the project ID. + returned: success + type: dict +password: + description: + - The password for the user. + returned: success + type: str ''' ################################################################################ @@ -278,7 +280,7 @@ def collection(module): def return_if_object(module, response, kind, allow_not_found=False): # If not found, return nothing. - if response.status_code == 404: + if allow_not_found and response.status_code == 404: return None # If no content, return nothing. @@ -286,7 +288,7 @@ def return_if_object(module, response, kind, allow_not_found=False): return None # SQL only: return on 403 if not exist - if response.status_code == 403: + if allow_not_found and response.status_code == 403: return None try: @@ -296,8 +298,6 @@ def return_if_object(module, response, kind, allow_not_found=False): if navigate_hash(result, ['error', 'errors']): module.fail_json(msg=navigate_hash(result, ['error', 'errors'])) - if result['kind'] != kind: - module.fail_json(msg="Incorrect result: {kind}".format(**result)) return result @@ -353,8 +353,6 @@ def wait_for_completion(status, op_result, module): while status != 'DONE': raise_if_errors(op_result, ['error', 'errors'], 'message') time.sleep(1.0) - if status not in ['PENDING', 'RUNNING', 'DONE']: - module.fail_json(msg="Invalid result %s" % status) op_result = fetch_resource(module, op_uri, 'sql#operation') status = navigate_hash(op_result, ['status']) return op_result diff --git a/lib/ansible/modules/cloud/google/gcp_storage_bucket.py b/lib/ansible/modules/cloud/google/gcp_storage_bucket.py index 644f6a8d02..f26361ef9a 100644 --- a/lib/ansible/modules/cloud/google/gcp_storage_bucket.py +++ b/lib/ansible/modules/cloud/google/gcp_storage_bucket.py @@ -32,334 +32,365 @@ DOCUMENTATION = ''' --- module: gcp_storage_bucket description: - - The Buckets resource represents a bucket in Google Cloud Storage. There is a single - global namespace shared by all buckets. For more information, see Bucket Name Requirements. - - Buckets contain objects which can be accessed by their own methods. In addition - to the acl property, buckets contain bucketAccessControls, for use in fine-grained - manipulation of an existing bucket's access controls. - - A bucket is always owned by the project team owners group. +- The Buckets resource represents a bucket in Google Cloud Storage. There is a single + global namespace shared by all buckets. For more information, see Bucket Name Requirements. +- Buckets contain objects which can be accessed by their own methods. In addition + to the acl property, buckets contain bucketAccessControls, for use in fine-grained + manipulation of an existing bucket's access controls. +- A bucket is always owned by the project team owners group. short_description: Creates a GCP Bucket version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + acl: + description: + - Access controls on the bucket. + required: false + suboptions: + bucket: description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - acl: + - 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' + required: true + domain: description: - - Access controls on the bucket. + - The domain associated with the entity. + required: false + email: + description: + - The email address associated with the entity. + required: false + entity: + description: + - 'The entity holding the permission, in one of the following forms: user-userId + user-email group-groupId group-email domain-domain project-team-projectId + allUsers allAuthenticatedUsers Examples: The user liz@example.com would + be user-liz@example.com.' + - The group example@googlegroups.com would be group-example@googlegroups.com. + - To refer to all members of the Google Apps for Business domain example.com, + the entity would be domain-example.com. + required: true + entity_id: + description: + - The ID for the entity. + required: false + id: + description: + - The ID of the access-control entry. + required: false + project_team: + description: + - The project team associated with the entity. required: false suboptions: - bucket: - 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.' - required: true - domain: - description: - - The domain associated with the entity. - required: false - email: - description: - - The email address associated with the entity. - required: false - entity: - description: - - 'The entity holding the permission, in one of the following forms: user-userId - user-email group-groupId group-email domain-domain project-team-projectId allUsers - allAuthenticatedUsers Examples: The user liz@example.com would be - user-liz@example.com.' - - The group example@googlegroups.com would be group-example@googlegroups.com. - - To refer to all members of the Google Apps for Business domain example.com, the - entity would be domain-example.com. - required: true - entity_id: - description: - - The ID for the entity. - required: false - id: - description: - - The ID of the access-control entry. - required: false - project_team: - description: - - The project team associated with the entity. - required: false - suboptions: - project_number: - description: - - The project team associated with the entity. - required: false - team: - description: - - The team. - required: false - choices: ['editors', 'owners', 'viewers'] - role: - description: - - The access permission for the entity. - required: false - choices: ['OWNER', 'READER', 'WRITER'] - cors: + project_number: + description: + - The project team associated with the entity. + required: false + team: + description: + - The team. + required: false + choices: + - editors + - owners + - viewers + role: description: - - The bucket's Cross-Origin Resource Sharing (CORS) configuration. + - The access permission for the entity. + required: false + choices: + - OWNER + - READER + - WRITER + cors: + description: + - The bucket's Cross-Origin Resource Sharing (CORS) configuration. + required: false + suboptions: + max_age_seconds: + description: + - The value, in seconds, to return in the Access-Control-Max-Age header used + in preflight responses. + required: false + method: + description: + - 'The list of HTTP methods on which to include CORS response headers, (GET, + OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means + "any method".' + required: false + origin: + description: + - The list of Origins eligible to receive CORS response headers. + - 'Note: "*" is permitted in the list of origins, and means "any Origin".' + required: false + response_header: + description: + - The list of HTTP headers other than the simple response headers to give + permission for the user-agent to share across domains. + required: false + default_object_acl: + description: + - Default access controls to apply to new objects when no ACL is provided. + required: false + version_added: 2.7 + suboptions: + bucket: + 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' + required: true + domain: + description: + - The domain associated with the entity. + required: false + email: + description: + - The email address associated with the entity. + required: false + entity: + description: + - 'The entity holding the permission, in one of the following forms: * user-{{userId}} + * user-{{email}} (such as "user-liz@example.com") * group-{{groupId}} * + group-{{email}} (such as "group-example@googlegroups.com") * domain-{{domain}} + (such as "domain-example.com") * project-team-{{projectId}} * allUsers * + allAuthenticatedUsers .' + required: true + entity_id: + description: + - The ID for the entity. + required: false + generation: + description: + - The content generation of the object, if applied to an object. + required: false + id: + description: + - The ID of the access-control entry. + required: false + object: + description: + - The name of the object, if applied to an object. + required: false + project_team: + description: + - The project team associated with the entity. required: false suboptions: - max_age_seconds: - description: - - The value, in seconds, to return in the Access-Control-Max-Age header used in preflight - responses. - required: false - method: - description: - - 'The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, - POST, etc) Note: "*" is permitted in the list of methods, and means "any method".' - required: false - origin: - description: - - The list of Origins eligible to receive CORS response headers. - - 'Note: "*" is permitted in the list of origins, and means "any Origin".' - required: false - response_header: - description: - - The list of HTTP headers other than the simple response headers to give permission - for the user-agent to share across domains. - required: false - default_object_acl: + project_number: + description: + - The project team associated with the entity. + required: false + team: + description: + - The team. + required: false + choices: + - editors + - owners + - viewers + role: description: - - Default access controls to apply to new objects when no ACL is provided. - required: false - version_added: 2.7 - suboptions: - bucket: - 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.' - required: true - domain: - description: - - The domain associated with the entity. - required: false - email: - description: - - The email address associated with the entity. - required: false - entity: - description: - - 'The entity holding the permission, in one of the following forms: user-userId - user-email group-groupId group-email domain-domain project-team-projectId allUsers - allAuthenticatedUsers Examples: The user liz@example.com would be - user-liz@example.com.' - - The group example@googlegroups.com would be group-example@googlegroups.com. - - To refer to all members of the Google Apps for Business domain example.com, the - entity would be domain-example.com. - required: true - entity_id: - description: - - The ID for the entity. - required: false - generation: - description: - - The content generation of the object, if applied to an object. - required: false - id: - description: - - The ID of the access-control entry. - required: false - object: - description: - - The name of the object, if applied to an object. - required: false - project_team: - description: - - The project team associated with the entity. - required: false - suboptions: - project_number: - description: - - The project team associated with the entity. - required: false - team: - description: - - The team. - required: false - choices: ['editors', 'owners', 'viewers'] - role: - description: - - The access permission for the entity. - required: false - choices: ['OWNER', 'READER'] - lifecycle: + - The access permission for the entity. + required: true + choices: + - OWNER + - READER + lifecycle: + description: + - The bucket's lifecycle configuration. + - See U(https://developers.google.com/storage/docs/lifecycle) for more information. + required: false + suboptions: + rule: description: - - The bucket's lifecycle configuration. - - See U(https://developers.google.com/storage/docs/lifecycle) for more information. + - A lifecycle management rule, which is made of an action to take and the + condition(s) under which the action will be taken. required: false suboptions: - rule: + action: + description: + - The action to take. + required: false + suboptions: + storage_class: description: - - A lifecycle management rule, which is made of an action to take and the condition(s) - under which the action will be taken. + - Target storage class. Required iff the type of the action is SetStorageClass. required: false - suboptions: - action: - description: - - The action to take. - required: false - suboptions: - storage_class: - description: - - Target storage class. Required iff the type of the action is SetStorageClass. - required: false - type: - description: - - Type of the action. Currently, only Delete and SetStorageClass are supported. - required: false - choices: ['Delete', 'SetStorageClass'] - condition: - description: - - The condition(s) under which the action will be taken. - required: false - suboptions: - age_days: - description: - - Age of an object (in days). This condition is satisfied when an object reaches the - specified age. - required: false - created_before: - description: - - A date in RFC 3339 format with only the date part (for instance, "2013-01-15"). - This condition is satisfied when an object is created before midnight of the specified - date in UTC. - required: false - is_live: - description: - - Relevant only for versioned objects. If the value is true, this condition matches - live objects; if the value is false, it matches archived objects. - required: false - type: bool - matches_storage_class: - description: - - Objects having any of the storage classes specified by this condition will be matched. - Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. - required: false - num_newer_versions: - description: - - Relevant only for versioned objects. If the value is N, this condition is satisfied - when there are at least N versions (including the live version) newer than this - version of the object. - required: false - location: - description: - - The location of the bucket. Object data for objects in the bucket resides in physical - storage within this region. Defaults to US. See the developer's guide for the authoritative - list. - required: false - logging: - description: - - The bucket's logging configuration, which defines the destination bucket and optional - name prefix for the current bucket's logs. - required: false - suboptions: - log_bucket: + type: description: - - The destination bucket where the current bucket's logs should be placed. + - Type of the action. Currently, only Delete and SetStorageClass are + supported. required: false - log_object_prefix: + choices: + - Delete + - SetStorageClass + condition: + description: + - The condition(s) under which the action will be taken. + required: false + suboptions: + age_days: description: - - A prefix for log object names. + - Age of an object (in days). This condition is satisfied when an + object reaches the specified age. required: false - metageneration: - description: - - The metadata generation of this bucket. - required: false - name: - description: - - The name of the bucket. - required: false - owner: - description: - - The owner of the bucket. This is always the project team's owner group. - required: false - suboptions: - entity: + created_before: description: - - The entity, in the form project-owner-projectId. + - A date in RFC 3339 format with only the date part (for instance, + "2013-01-15"). This condition is satisfied when an object is created + before midnight of the specified date in UTC. required: false - entity_id: + is_live: description: - - The ID for the entity. - required: false - storage_class: - description: - - The bucket's default storage class, used whenever no storageClass is specified for - a newly-created object. This defines how objects in the bucket are stored and determines - the SLA and the cost of storage. - - 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. - required: false - choices: ['MULTI_REGIONAL', 'REGIONAL', 'STANDARD', 'NEARLINE', 'COLDLINE', 'DURABLE_REDUCED_AVAILABILITY'] - versioning: - description: - - The bucket's versioning configuration. - required: false - suboptions: - enabled: - description: - - While set to true, versioning is fully enabled for this bucket. + - Relevant only for versioned objects. If the value is true, this + condition matches live objects; if the value is false, it matches + archived objects. required: false type: bool - website: - description: - - The bucket's website configuration, controlling how the service behaves when accessing - bucket contents as a web site. See the Static Website Examples for more information. - required: false - suboptions: - main_page_suffix: + matches_storage_class: description: - - If the requested object path is missing, the service will ensure the path has a - trailing '/', append this suffix, and attempt to retrieve the resulting object. - This allows the creation of index.html objects to represent directory pages. + - Objects having any of the storage classes specified by this condition + will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, + COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. required: false - not_found_page: + num_newer_versions: description: - - If the requested object path is missing, and any mainPageSuffix object is missing, - if applicable, the service will return the named object from this bucket as the - content for a 404 Not Found result. + - Relevant only for versioned objects. If the value is N, this condition + is satisfied when there are at least N versions (including the live + version) newer than this version of the object. required: false - project: + location: + description: + - The location of the bucket. Object data for objects in the bucket resides in + physical storage within this region. Defaults to US. See the developer's guide + for the authoritative list. + required: false + logging: + description: + - The bucket's logging configuration, which defines the destination bucket and + optional name prefix for the current bucket's logs. + required: false + suboptions: + log_bucket: description: - - A valid API project identifier. + - The destination bucket where the current bucket's logs should be placed. required: false - predefined_default_object_acl: + log_object_prefix: description: - - Apply a predefined set of default object access controls to this bucket. - - 'Acceptable values are: - "authenticatedRead": Object owner gets OWNER access, - and allAuthenticatedUsers get READER access.' - - '- "bucketOwnerFullControl": Object owner gets OWNER access, and project team - owners get OWNER access.' - - '- "bucketOwnerRead": Object owner gets OWNER access, and project team owners - get READER access.' - - '- "private": Object owner gets OWNER access.' - - '- "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.' + - A prefix for log object names. required: false - choices: ['authenticatedRead', 'bucketOwnerFullControl', 'bucketOwnerRead', 'private', 'projectPrivate', 'publicRead'] + metageneration: + description: + - The metadata generation of this bucket. + required: false + name: + description: + - The name of the bucket. + required: false + owner: + description: + - The owner of the bucket. This is always the project team's owner group. + required: false + suboptions: + entity: + description: + - The entity, in the form project-owner-projectId. + required: false + entity_id: + description: + - The ID for the entity. + required: false + storage_class: + description: + - The bucket's default storage class, used whenever no storageClass is specified + for a newly-created object. This defines how objects in the bucket are stored + and determines the SLA and the cost of storage. + - 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. + required: false + choices: + - MULTI_REGIONAL + - REGIONAL + - STANDARD + - NEARLINE + - COLDLINE + - DURABLE_REDUCED_AVAILABILITY + versioning: + description: + - The bucket's versioning configuration. + required: false + suboptions: + enabled: + description: + - While set to true, versioning is fully enabled for this bucket. + required: false + type: bool + website: + description: + - The bucket's website configuration, controlling how the service behaves when + accessing bucket contents as a web site. See the Static Website Examples for + more information. + required: false + suboptions: + main_page_suffix: + description: + - If the requested object path is missing, the service will ensure the path + has a trailing '/', append this suffix, and attempt to retrieve the resulting + object. This allows the creation of index.html objects to represent directory + pages. + required: false + not_found_page: + description: + - If the requested object path is missing, and any mainPageSuffix object is + missing, if applicable, the service will return the named object from this + bucket as the content for a 404 Not Found result. + required: false + project: + description: + - A valid API project identifier. + required: false + predefined_default_object_acl: + description: + - Apply a predefined set of default object access controls to this bucket. + - 'Acceptable values are: - "authenticatedRead": Object owner gets OWNER access, + and allAuthenticatedUsers get READER access.' + - '- "bucketOwnerFullControl": Object owner gets OWNER access, and project team + owners get OWNER access.' + - '- "bucketOwnerRead": Object owner gets OWNER access, and project team owners + get READER access.' + - '- "private": Object owner gets OWNER access.' + - '- "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.' + required: false + choices: + - authenticatedRead + - bucketOwnerFullControl + - bucketOwnerRead + - private + - projectPrivate + - publicRead extends_documentation_fragment: gcp ''' @@ -374,372 +405,373 @@ EXAMPLES = ''' ''' RETURN = ''' - acl: - description: - - Access controls on the bucket. - returned: success - type: complex - contains: - bucket: - description: - - The name of the bucket. - returned: success - type: dict - domain: - description: - - The domain associated with the entity. - returned: success - type: str - email: - description: - - The email address associated with the entity. - returned: success - type: str - entity: - description: - - 'The entity holding the permission, in one of the following forms: user-userId - user-email group-groupId group-email domain-domain project-team-projectId allUsers - allAuthenticatedUsers Examples: The user liz@example.com would be - user-liz@example.com.' - - The group example@googlegroups.com would be group-example@googlegroups.com. - - To refer to all members of the Google Apps for Business domain example.com, the - entity would be domain-example.com. - returned: success - type: str - entityId: - description: - - The ID for the entity. - returned: success - type: str - id: - description: - - The ID of the access-control entry. - returned: success - type: str - projectTeam: - description: - - The project team associated with the entity. - returned: success - type: complex - contains: - projectNumber: - description: - - The project team associated with the entity. - returned: success - type: str - team: - description: - - The team. - returned: success - type: str - role: - description: - - The access permission for the entity. - returned: success - type: str - cors: - description: - - The bucket's Cross-Origin Resource Sharing (CORS) configuration. - returned: success - type: complex - contains: - maxAgeSeconds: - description: - - The value, in seconds, to return in the Access-Control-Max-Age header used in preflight - responses. - returned: success - type: int - method: - description: - - 'The list of HTTP methods on which to include CORS response headers, (GET, OPTIONS, - POST, etc) Note: "*" is permitted in the list of methods, and means "any method".' - returned: success - type: list - origin: - description: - - The list of Origins eligible to receive CORS response headers. - - 'Note: "*" is permitted in the list of origins, and means "any Origin".' - returned: success - type: list - responseHeader: - description: - - The list of HTTP headers other than the simple response headers to give permission - for the user-agent to share across domains. - returned: success - type: list - defaultObjectAcl: - description: - - Default access controls to apply to new objects when no ACL is provided. - returned: success - type: complex - contains: - bucket: - description: - - The name of the bucket. - returned: success - type: dict - domain: - description: - - The domain associated with the entity. - returned: success - type: str - email: - description: - - The email address associated with the entity. - returned: success - type: str - entity: - description: - - 'The entity holding the permission, in one of the following forms: user-userId - user-email group-groupId group-email domain-domain project-team-projectId allUsers - allAuthenticatedUsers Examples: The user liz@example.com would be - user-liz@example.com.' - - The group example@googlegroups.com would be group-example@googlegroups.com. - - To refer to all members of the Google Apps for Business domain example.com, the - entity would be domain-example.com. - returned: success - type: str - entityId: - description: - - The ID for the entity. - returned: success - type: str - generation: - description: - - The content generation of the object, if applied to an object. - returned: success - type: int - id: - description: - - The ID of the access-control entry. - returned: success - type: str - object: - description: - - The name of the object, if applied to an object. - returned: success - type: str - projectTeam: - description: - - The project team associated with the entity. - returned: success - type: complex - contains: - projectNumber: - description: - - The project team associated with the entity. - returned: success - type: str - team: - description: - - The team. - returned: success - type: str - role: - description: - - The access permission for the entity. - returned: success - type: str +acl: + description: + - Access controls on the bucket. + returned: success + type: complex + contains: + bucket: + description: + - The name of the bucket. + returned: success + type: dict + domain: + description: + - The domain associated with the entity. + returned: success + type: str + email: + description: + - The email address associated with the entity. + returned: success + type: str + entity: + description: + - 'The entity holding the permission, in one of the following forms: user-userId + user-email group-groupId group-email domain-domain project-team-projectId + allUsers allAuthenticatedUsers Examples: The user liz@example.com would be + user-liz@example.com.' + - The group example@googlegroups.com would be group-example@googlegroups.com. + - To refer to all members of the Google Apps for Business domain example.com, + the entity would be domain-example.com. + returned: success + type: str + entityId: + description: + - The ID for the entity. + returned: success + type: str id: - description: - - The ID of the bucket. For buckets, the id and name properities are the same. - returned: success - type: str - lifecycle: - description: - - The bucket's lifecycle configuration. - - See U(https://developers.google.com/storage/docs/lifecycle) for more information. - returned: success - type: complex - contains: - rule: - description: - - A lifecycle management rule, which is made of an action to take and the condition(s) - under which the action will be taken. - returned: success - type: complex - contains: - action: - description: - - The action to take. - returned: success - type: complex - contains: - storageClass: - description: - - Target storage class. Required iff the type of the action is SetStorageClass. - returned: success - type: str - type: - description: - - Type of the action. Currently, only Delete and SetStorageClass are supported. - returned: success - type: str - condition: - description: - - The condition(s) under which the action will be taken. - returned: success - type: complex - contains: - ageDays: - description: - - Age of an object (in days). This condition is satisfied when an object reaches the - specified age. - returned: success - type: int - createdBefore: - description: - - A date in RFC 3339 format with only the date part (for instance, "2013-01-15"). - This condition is satisfied when an object is created before midnight of the specified - date in UTC. - returned: success - type: str - isLive: - description: - - Relevant only for versioned objects. If the value is true, this condition matches - live objects; if the value is false, it matches archived objects. - returned: success - type: bool - matchesStorageClass: - description: - - Objects having any of the storage classes specified by this condition will be matched. - Values include MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. - returned: success - type: list - numNewerVersions: - description: - - Relevant only for versioned objects. If the value is N, this condition is satisfied - when there are at least N versions (including the live version) newer than this - version of the object. - returned: success - type: int - location: - description: - - The location of the bucket. Object data for objects in the bucket resides in physical - storage within this region. Defaults to US. See the developer's guide for the authoritative - list. - returned: success - type: str - logging: - description: - - The bucket's logging configuration, which defines the destination bucket and optional - name prefix for the current bucket's logs. - returned: success - type: complex - contains: - logBucket: - description: - - The destination bucket where the current bucket's logs should be placed. - returned: success - type: str - logObjectPrefix: - description: - - A prefix for log object names. - returned: success - type: str - metageneration: - description: - - The metadata generation of this bucket. - returned: success - type: int - name: - description: - - The name of the bucket. - returned: success - type: str - owner: - description: - - The owner of the bucket. This is always the project team's owner group. - returned: success - type: complex - contains: - entity: - description: - - The entity, in the form project-owner-projectId. - returned: success - type: str - entityId: - description: - - The ID for the entity. - returned: success - type: str - projectNumber: - description: - - The project number of the project the bucket belongs to. - returned: success - type: int - storageClass: - description: - - The bucket's default storage class, used whenever no storageClass is specified for - a newly-created object. This defines how objects in the bucket are stored and determines - the SLA and the cost of storage. - - 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. - returned: success - type: str - timeCreated: - description: - - The creation time of the bucket in RFC 3339 format. - returned: success - type: str - updated: - description: - - The modification time of the bucket in RFC 3339 format. - returned: success - type: str - versioning: - description: - - The bucket's versioning configuration. - returned: success - type: complex - contains: - enabled: - description: - - While set to true, versioning is fully enabled for this bucket. - returned: success - type: bool - website: - description: - - The bucket's website configuration, controlling how the service behaves when accessing - bucket contents as a web site. See the Static Website Examples for more information. - returned: success - type: complex - contains: - mainPageSuffix: - description: - - If the requested object path is missing, the service will ensure the path has a - trailing '/', append this suffix, and attempt to retrieve the resulting object. - This allows the creation of index.html objects to represent directory pages. - returned: success - type: str - notFoundPage: - description: - - If the requested object path is missing, and any mainPageSuffix object is missing, - if applicable, the service will return the named object from this bucket as the - content for a 404 Not Found result. - returned: success - type: str - project: - description: - - A valid API project identifier. - returned: success - type: str - predefinedDefaultObjectAcl: - description: - - Apply a predefined set of default object access controls to this bucket. - - 'Acceptable values are: - "authenticatedRead": Object owner gets OWNER access, - and allAuthenticatedUsers get READER access.' - - '- "bucketOwnerFullControl": Object owner gets OWNER access, and project team - owners get OWNER access.' - - '- "bucketOwnerRead": Object owner gets OWNER access, and project team owners - get READER access.' - - '- "private": Object owner gets OWNER access.' - - '- "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.' - returned: success - type: str + description: + - The ID of the access-control entry. + returned: success + type: str + projectTeam: + description: + - The project team associated with the entity. + returned: success + type: complex + contains: + projectNumber: + description: + - The project team associated with the entity. + returned: success + type: str + team: + description: + - The team. + returned: success + type: str + role: + description: + - The access permission for the entity. + returned: success + type: str +cors: + description: + - The bucket's Cross-Origin Resource Sharing (CORS) configuration. + returned: success + type: complex + contains: + maxAgeSeconds: + description: + - The value, in seconds, to return in the Access-Control-Max-Age header used + in preflight responses. + returned: success + type: int + method: + description: + - 'The list of HTTP methods on which to include CORS response headers, (GET, + OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means + "any method".' + returned: success + type: list + origin: + description: + - The list of Origins eligible to receive CORS response headers. + - 'Note: "*" is permitted in the list of origins, and means "any Origin".' + returned: success + type: list + responseHeader: + description: + - The list of HTTP headers other than the simple response headers to give permission + for the user-agent to share across domains. + returned: success + type: list +defaultObjectAcl: + description: + - Default access controls to apply to new objects when no ACL is provided. + returned: success + type: complex + contains: + bucket: + description: + - The name of the bucket. + returned: success + type: dict + domain: + description: + - The domain associated with the entity. + returned: success + type: str + email: + description: + - The email address associated with the entity. + returned: success + type: str + entity: + description: + - 'The entity holding the permission, in one of the following forms: * user-{{userId}} + * user-{{email}} (such as "user-liz@example.com") * group-{{groupId}} * group-{{email}} + (such as "group-example@googlegroups.com") * domain-{{domain}} (such as "domain-example.com") + * project-team-{{projectId}} * allUsers * allAuthenticatedUsers .' + returned: success + type: str + entityId: + description: + - The ID for the entity. + returned: success + type: str + generation: + description: + - The content generation of the object, if applied to an object. + returned: success + type: int + id: + description: + - The ID of the access-control entry. + returned: success + type: str + object: + description: + - The name of the object, if applied to an object. + returned: success + type: str + projectTeam: + description: + - The project team associated with the entity. + returned: success + type: complex + contains: + projectNumber: + description: + - The project team associated with the entity. + returned: success + type: str + team: + description: + - The team. + returned: success + type: str + role: + description: + - The access permission for the entity. + returned: success + type: str +id: + description: + - The ID of the bucket. For buckets, the id and name properities are the same. + returned: success + type: str +lifecycle: + description: + - The bucket's lifecycle configuration. + - See U(https://developers.google.com/storage/docs/lifecycle) for more information. + returned: success + type: complex + contains: + rule: + description: + - A lifecycle management rule, which is made of an action to take and the condition(s) + under which the action will be taken. + returned: success + type: complex + contains: + action: + description: + - The action to take. + returned: success + type: complex + contains: + storageClass: + description: + - Target storage class. Required iff the type of the action is SetStorageClass. + returned: success + type: str + type: + description: + - Type of the action. Currently, only Delete and SetStorageClass are + supported. + returned: success + type: str + condition: + description: + - The condition(s) under which the action will be taken. + returned: success + type: complex + contains: + ageDays: + description: + - Age of an object (in days). This condition is satisfied when an object + reaches the specified age. + returned: success + type: int + createdBefore: + description: + - A date in RFC 3339 format with only the date part (for instance, "2013-01-15"). + This condition is satisfied when an object is created before midnight + of the specified date in UTC. + returned: success + type: str + isLive: + description: + - Relevant only for versioned objects. If the value is true, this condition + matches live objects; if the value is false, it matches archived objects. + returned: success + type: bool + matchesStorageClass: + description: + - Objects having any of the storage classes specified by this condition + will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE, + COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY. + returned: success + type: list + numNewerVersions: + description: + - Relevant only for versioned objects. If the value is N, this condition + is satisfied when there are at least N versions (including the live + version) newer than this version of the object. + returned: success + type: int +location: + description: + - The location of the bucket. Object data for objects in the bucket resides in physical + storage within this region. Defaults to US. See the developer's guide for the + authoritative list. + returned: success + type: str +logging: + description: + - The bucket's logging configuration, which defines the destination bucket and optional + name prefix for the current bucket's logs. + returned: success + type: complex + contains: + logBucket: + description: + - The destination bucket where the current bucket's logs should be placed. + returned: success + type: str + logObjectPrefix: + description: + - A prefix for log object names. + returned: success + type: str +metageneration: + description: + - The metadata generation of this bucket. + returned: success + type: int +name: + description: + - The name of the bucket. + returned: success + type: str +owner: + description: + - The owner of the bucket. This is always the project team's owner group. + returned: success + type: complex + contains: + entity: + description: + - The entity, in the form project-owner-projectId. + returned: success + type: str + entityId: + description: + - The ID for the entity. + returned: success + type: str +projectNumber: + description: + - The project number of the project the bucket belongs to. + returned: success + type: int +storageClass: + description: + - The bucket's default storage class, used whenever no storageClass is specified + for a newly-created object. This defines how objects in the bucket are stored + and determines the SLA and the cost of storage. + - 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. + returned: success + type: str +timeCreated: + description: + - The creation time of the bucket in RFC 3339 format. + returned: success + type: str +updated: + description: + - The modification time of the bucket in RFC 3339 format. + returned: success + type: str +versioning: + description: + - The bucket's versioning configuration. + returned: success + type: complex + contains: + enabled: + description: + - While set to true, versioning is fully enabled for this bucket. + returned: success + type: bool +website: + description: + - The bucket's website configuration, controlling how the service behaves when accessing + bucket contents as a web site. See the Static Website Examples for more information. + returned: success + type: complex + contains: + mainPageSuffix: + description: + - If the requested object path is missing, the service will ensure the path + has a trailing '/', append this suffix, and attempt to retrieve the resulting + object. This allows the creation of index.html objects to represent directory + pages. + returned: success + type: str + notFoundPage: + description: + - If the requested object path is missing, and any mainPageSuffix object is + missing, if applicable, the service will return the named object from this + bucket as the content for a 404 Not Found result. + returned: success + type: str +project: + description: + - A valid API project identifier. + returned: success + type: str +predefinedDefaultObjectAcl: + description: + - Apply a predefined set of default object access controls to this bucket. + - 'Acceptable values are: - "authenticatedRead": Object owner gets OWNER access, + and allAuthenticatedUsers get READER access.' + - '- "bucketOwnerFullControl": Object owner gets OWNER access, and project team + owners get OWNER access.' + - '- "bucketOwnerRead": Object owner gets OWNER access, and project team owners + get READER access.' + - '- "private": Object owner gets OWNER access.' + - '- "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.' + returned: success + type: str ''' ################################################################################ @@ -792,7 +824,7 @@ def main(): project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']) )), - role=dict(type='str', choices=['OWNER', 'READER']) + role=dict(required=True, type='str', choices=['OWNER', 'READER']) )), lifecycle=dict(type='dict', options=dict( rule=dict(type='list', elements='dict', options=dict( @@ -891,7 +923,7 @@ def resource_to_request(module): u'predefinedDefaultObjectAcl': module.params.get('predefined_default_object_acl'), u'acl': BucketAclArray(module.params.get('acl', []), module).to_request(), u'cors': BucketCorsArray(module.params.get('cors', []), module).to_request(), - u'defaultObjectAcl': BucketDefaultObjectAclArray(module.params.get('default_object_acl', []), module).to_request(), + u'defaultObjectAcl': BucketDefaultobjectaclArray(module.params.get('default_object_acl', []), module).to_request(), u'lifecycle': BucketLifecycle(module.params.get('lifecycle', {}), module).to_request(), u'location': module.params.get('location'), u'logging': BucketLogging(module.params.get('logging', {}), module).to_request(), @@ -968,7 +1000,7 @@ def response_to_hash(module, response): return { u'acl': BucketAclArray(response.get(u'acl', []), module).from_response(), u'cors': BucketCorsArray(response.get(u'cors', []), module).from_response(), - u'defaultObjectAcl': BucketDefaultObjectAclArray(module.params.get('default_object_acl', []), module).to_request(), + u'defaultObjectAcl': BucketDefaultobjectaclArray(module.params.get('default_object_acl', []), module).to_request(), u'id': response.get(u'id'), u'lifecycle': BucketLifecycle(response.get(u'lifecycle', {}), module).from_response(), u'location': response.get(u'location'), @@ -1013,7 +1045,7 @@ class BucketAclArray(object): u'entity': item.get('entity'), u'entityId': item.get('entity_id'), u'id': item.get('id'), - u'projectTeam': BucketProjectTeam(item.get('project_team', {}), self.module).to_request(), + u'projectTeam': BucketProjectteam(item.get('project_team', {}), self.module).to_request(), u'role': item.get('role') }) @@ -1025,12 +1057,12 @@ class BucketAclArray(object): u'entity': item.get(u'entity'), u'entityId': item.get(u'entityId'), u'id': item.get(u'id'), - u'projectTeam': BucketProjectTeam(item.get(u'projectTeam', {}), self.module).from_response(), + u'projectTeam': BucketProjectteam(item.get(u'projectTeam', {}), self.module).from_response(), u'role': item.get(u'role') }) -class BucketProjectTeam(object): +class BucketProjectteam(object): def __init__(self, request, module): self.module = module if request: @@ -1088,7 +1120,7 @@ class BucketCorsArray(object): }) -class BucketDefaultObjectAclArray(object): +class BucketDefaultobjectaclArray(object): def __init__(self, request, module): self.module = module if request: @@ -1118,7 +1150,7 @@ class BucketDefaultObjectAclArray(object): u'generation': item.get('generation'), u'id': item.get('id'), u'object': item.get('object'), - u'projectTeam': BucketProjectTeam(item.get('project_team', {}), self.module).to_request(), + u'projectTeam': BucketProjectteam(item.get('project_team', {}), self.module).to_request(), u'role': item.get('role') }) @@ -1132,12 +1164,12 @@ class BucketDefaultObjectAclArray(object): u'generation': item.get(u'generation'), u'id': item.get(u'id'), u'object': item.get(u'object'), - u'projectTeam': BucketProjectTeam(item.get(u'projectTeam', {}), self.module).from_response(), + u'projectTeam': BucketProjectteam(item.get(u'projectTeam', {}), self.module).from_response(), u'role': item.get(u'role') }) -class BucketProjectTeam(object): +class BucketProjectteam(object): def __init__(self, request, module): self.module = module if request: 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 0f48f4aaf3..d075f43d17 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 @@ -32,71 +32,78 @@ DOCUMENTATION = ''' --- module: gcp_storage_bucket_access_control description: - - The BucketAccessControls resource represents the Access Control Lists (ACLs) for - buckets within Google Cloud Storage. ACLs let you specify who has access to your - data and to what extent. - - 'There are three roles that can be assigned to an entity: READERs can get the bucket, - though no acl property will be returned, and list the bucket''s objects. WRITERs - are READERs, and they can insert objects into the bucket and delete the bucket''s - objects. OWNERs are WRITERs, and they can get the acl property of a bucket, update - a bucket, and call all BucketAccessControls methods on the bucket. For more information, - see Access Control, with the caveat that this API uses READER, WRITER, and OWNER - instead of READ, WRITE, and FULL_CONTROL.' +- The BucketAccessControls resource represents the Access Control Lists (ACLs) for + buckets within Google Cloud Storage. ACLs let you specify who has access to your + data and to what extent. +- 'There are three roles that can be assigned to an entity: READERs can get the bucket, + though no acl property will be returned, and list the bucket''s objects. WRITERs + are READERs, and they can insert objects into the bucket and delete the bucket''s + objects. OWNERs are WRITERs, and they can get the acl property of a bucket, update + a bucket, and call all BucketAccessControls methods on the bucket. For more information, + see Access Control, with the caveat that this API uses READER, WRITER, and OWNER + instead of READ, WRITE, and FULL_CONTROL.' short_description: Creates a GCP BucketAccessControl version_added: 2.6 author: Google Inc. (@googlecloudplatform) requirements: - - python >= 2.6 - - requests >= 2.18.4 - - google-auth >= 1.3.0 +- python >= 2.6 +- requests >= 2.18.4 +- google-auth >= 1.3.0 options: - state: + state: + description: + - Whether the given object should exist in GCP + choices: + - present + - absent + default: present + bucket: + 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' + required: true + entity: + description: + - 'The entity holding the permission, in one of the following forms: user-userId + user-email group-groupId group-email domain-domain project-team-projectId allUsers + allAuthenticatedUsers Examples: The user liz@example.com would be user-liz@example.com.' + - The group example@googlegroups.com would be group-example@googlegroups.com. + - To refer to all members of the Google Apps for Business domain example.com, + the entity would be domain-example.com. + required: true + entity_id: + description: + - The ID for the entity. + required: false + project_team: + description: + - The project team associated with the entity. + required: false + suboptions: + project_number: description: - - Whether the given object should exist in GCP - choices: ['present', 'absent'] - default: 'present' - bucket: - 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.' - required: true - entity: - description: - - 'The entity holding the permission, in one of the following forms: user-userId - user-email group-groupId group-email domain-domain project-team-projectId allUsers - allAuthenticatedUsers Examples: The user liz@example.com would be - user-liz@example.com.' - - The group example@googlegroups.com would be group-example@googlegroups.com. - - To refer to all members of the Google Apps for Business domain example.com, the - entity would be domain-example.com. - required: true - entity_id: - description: - - The ID for the entity. + - The project team associated with the entity. required: false - project_team: + team: description: - - The project team associated with the entity. + - The team. required: false - suboptions: - project_number: - description: - - The project team associated with the entity. - required: false - team: - description: - - The team. - required: false - choices: ['editors', 'owners', 'viewers'] - role: - description: - - The access permission for the entity. - required: false - choices: ['OWNER', 'READER', 'WRITER'] + choices: + - editors + - owners + - viewers + role: + description: + - The access permission for the entity. + required: false + choices: + - OWNER + - READER + - WRITER extends_documentation_fragment: gcp ''' @@ -122,63 +129,62 @@ EXAMPLES = ''' ''' RETURN = ''' - bucket: - description: - - The name of the bucket. - returned: success - type: dict - domain: - description: - - The domain associated with the entity. - returned: success - type: str - email: - description: - - The email address associated with the entity. - returned: success - type: str - entity: - description: - - 'The entity holding the permission, in one of the following forms: user-userId - user-email group-groupId group-email domain-domain project-team-projectId allUsers - allAuthenticatedUsers Examples: The user liz@example.com would be - user-liz@example.com.' - - The group example@googlegroups.com would be group-example@googlegroups.com. - - To refer to all members of the Google Apps for Business domain example.com, the - entity would be domain-example.com. - returned: success - type: str - entityId: - description: - - The ID for the entity. - returned: success - type: str - id: - description: - - The ID of the access-control entry. - returned: success - type: str - projectTeam: - description: - - The project team associated with the entity. - returned: success - type: complex - contains: - projectNumber: - description: - - The project team associated with the entity. - returned: success - type: str - team: - description: - - The team. - returned: success - type: str - role: - description: - - The access permission for the entity. - returned: success - type: str +bucket: + description: + - The name of the bucket. + returned: success + type: dict +domain: + description: + - The domain associated with the entity. + returned: success + type: str +email: + description: + - The email address associated with the entity. + returned: success + type: str +entity: + description: + - 'The entity holding the permission, in one of the following forms: user-userId + user-email group-groupId group-email domain-domain project-team-projectId allUsers + allAuthenticatedUsers Examples: The user liz@example.com would be user-liz@example.com.' + - The group example@googlegroups.com would be group-example@googlegroups.com. + - To refer to all members of the Google Apps for Business domain example.com, the + entity would be domain-example.com. + returned: success + type: str +entityId: + description: + - The ID for the entity. + returned: success + type: str +id: + description: + - The ID of the access-control entry. + returned: success + type: str +projectTeam: + description: + - The project team associated with the entity. + returned: success + type: complex + contains: + projectNumber: + description: + - The project team associated with the entity. + returned: success + type: str + team: + description: + - The team. + returned: success + type: str +role: + description: + - The access permission for the entity. + returned: success + type: str ''' ################################################################################ @@ -262,7 +268,7 @@ def resource_to_request(module): u'bucket': replace_resource_dict(module.params.get(u'bucket', {}), 'name'), u'entity': module.params.get('entity'), u'entityId': module.params.get('entity_id'), - u'projectTeam': BucketAccessControlProjectTeam(module.params.get('project_team', {}), module).to_request(), + u'projectTeam': BucketAccessControlProjectteam(module.params.get('project_team', {}), module).to_request(), u'role': module.params.get('role') } return_vals = {} @@ -335,12 +341,12 @@ def response_to_hash(module, response): u'entity': response.get(u'entity'), u'entityId': response.get(u'entityId'), u'id': response.get(u'id'), - u'projectTeam': BucketAccessControlProjectTeam(response.get(u'projectTeam', {}), module).from_response(), + u'projectTeam': BucketAccessControlProjectteam(response.get(u'projectTeam', {}), module).from_response(), u'role': response.get(u'role') } -class BucketAccessControlProjectTeam(object): +class BucketAccessControlProjectteam(object): def __init__(self, request, module): self.module = module if request: