From 93f851b698d9d8f50d0b1ca7b7c21cc84510f00b Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 2 Oct 2019 11:31:46 -0700 Subject: [PATCH] Bug fixes for GCP modules (#61915) --- .../cloud/google/gcp_compute_disk_info.py | 51 +++- .../cloud/google/gcp_compute_firewall.py | 64 ++++- .../cloud/google/gcp_compute_firewall_info.py | 51 +++- .../google/gcp_compute_forwarding_rule.py | 58 +++- .../gcp_compute_forwarding_rule_info.py | 51 +++- .../google/gcp_compute_global_address.py | 60 ++++- .../google/gcp_compute_global_address_info.py | 51 +++- .../gcp_compute_global_forwarding_rule.py | 214 ++++++++++++++- ...gcp_compute_global_forwarding_rule_info.py | 101 ++++++- .../cloud/google/gcp_compute_health_check.py | 229 +++++++++++++++- .../google/gcp_compute_health_check_info.py | 109 +++++++- .../google/gcp_compute_http_health_check.py | 50 +++- .../gcp_compute_http_health_check_info.py | 51 +++- .../google/gcp_compute_https_health_check.py | 50 +++- .../gcp_compute_https_health_check_info.py | 51 +++- .../modules/cloud/google/gcp_compute_image.py | 85 ++++-- .../cloud/google/gcp_compute_image_info.py | 68 +++-- .../cloud/google/gcp_compute_instance.py | 50 +++- .../google/gcp_compute_instance_group.py | 42 ++- .../google/gcp_compute_instance_group_info.py | 51 +++- .../gcp_compute_instance_group_manager.py | 40 ++- ...gcp_compute_instance_group_manager_info.py | 51 +++- .../cloud/google/gcp_compute_instance_info.py | 51 +++- .../gcp_compute_firewall/tasks/autogen.yml | 147 ++++++++++ .../gcp_compute_firewall/tasks/main.yml | 147 +--------- .../tasks/autogen.yml | 170 ++++++++++++ .../tasks/main.yml | 170 +----------- .../tasks/autogen.yml | 102 +++++++ .../gcp_compute_global_address/tasks/main.yml | 102 +------ .../tasks/autogen.yml | 251 ++++++++++++++++++ .../tasks/main.yml | 251 +----------------- .../tasks/autogen.yml | 142 ++++++++++ .../gcp_compute_health_check/tasks/main.yml | 142 +--------- .../tasks/autogen.yml | 122 +++++++++ .../tasks/main.yml | 122 +-------- .../tasks/autogen.yml | 122 +++++++++ .../tasks/main.yml | 122 +-------- .../gcp_compute_image/tasks/autogen.yml | 129 +++++++++ .../targets/gcp_compute_image/tasks/main.yml | 129 +-------- .../gcp_compute_instance/tasks/autogen.yml | 251 ++++++++++++++++++ .../gcp_compute_instance/tasks/main.yml | 251 +----------------- .../tasks/autogen.yml | 149 +++++++++++ .../gcp_compute_instance_group/tasks/main.yml | 149 +---------- .../tasks/autogen.yml | 206 ++++++++++++++ .../tasks/main.yml | 206 +------------- 45 files changed, 3366 insertions(+), 1895 deletions(-) create mode 100644 test/integration/targets/gcp_compute_firewall/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_global_address/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_health_check/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_image/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_instance/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml create mode 100644 test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml diff --git a/lib/ansible/modules/cloud/google/gcp_compute_disk_info.py b/lib/ansible/modules/cloud/google/gcp_compute_disk_info.py index 7e15d9480b1..fb7eab3d3e5 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_disk_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_disk_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_disk_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP Disk -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -53,7 +53,54 @@ options: - A reference to the zone where the disk resides. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_firewall.py b/lib/ansible/modules/cloud/google/gcp_compute_firewall.py index 2a4bcee1437..3a8ccb328e1 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_firewall.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_firewall.py @@ -40,7 +40,7 @@ description: 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -85,7 +85,7 @@ options: and port-range tuple that describes a denied connection. required: false type: list - version_added: 2.8 + version_added: '2.8' suboptions: ip_protocol: description: @@ -117,7 +117,7 @@ options: in CIDR format. Only IPv4 is supported. required: false type: list - version_added: 2.8 + version_added: '2.8' direction: description: - 'Direction of traffic to which this firewall applies; default is INGRESS. Note: @@ -126,7 +126,7 @@ options: - 'Some valid choices include: "INGRESS", "EGRESS"' required: false type: str - version_added: 2.8 + version_added: '2.8' disabled: description: - Denotes whether the firewall rule is disabled, i.e not applied to the network @@ -135,7 +135,7 @@ options: rule will be enabled. required: false type: bool - version_added: 2.8 + version_added: '2.8' name: description: - Name of the resource. Provided by the client when the resource is created. The @@ -173,7 +173,7 @@ options: required: false default: '1000' type: int - version_added: 2.8 + version_added: '2.8' source_ranges: description: - If source ranges are specified, the firewall will apply only to traffic that @@ -198,7 +198,7 @@ options: sourceServiceAccounts cannot be used at the same time as sourceTags or targetTags. required: false type: list - version_added: 2.8 + version_added: '2.8' source_tags: description: - If source tags are specified, the firewall will apply only to traffic with source @@ -220,7 +220,7 @@ options: rule applies to all instances on the specified network. required: false type: list - version_added: 2.8 + version_added: '2.8' target_tags: description: - A list of instance tags indicating sets of instances located in the network @@ -229,10 +229,56 @@ options: the specified network. required: false type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str notes: - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/firewalls)' - 'Official Documentation: U(https://cloud.google.com/vpc/docs/firewalls)' +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py b/lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py index 1013fa4144d..d84816842a8 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_firewall_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP Firewall -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -48,7 +48,54 @@ options: - Each additional filter in the list will act be added as an AND condition (filter1 and filter2) . type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' 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 8794ed0e3f5..047515325f2 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py @@ -35,7 +35,7 @@ description: 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -187,7 +187,7 @@ options: }}"' required: false type: dict - version_added: 2.7 + version_added: '2.7' all_ports: description: - For internal TCP/UDP load balancing (i.e. load balancing scheme is INTERNAL @@ -196,7 +196,7 @@ options: Used with backend service. Cannot be set if port or portRange are set. required: false type: bool - version_added: 2.8 + version_added: '2.8' network_tier: description: - 'The networking tier used for configuring this address. This field can take @@ -205,7 +205,7 @@ options: - 'Some valid choices include: "PREMIUM", "STANDARD"' required: false type: str - version_added: 2.8 + version_added: '2.8' service_label: description: - An optional prefix to the service name for this Forwarding Rule. @@ -218,17 +218,63 @@ options: - This field is only used for INTERNAL load balancing. required: false type: str - version_added: 2.8 + version_added: '2.8' region: description: - A reference to the region where the regional forwarding rule resides. - This field is not applicable to global forwarding rules. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str notes: - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/forwardingRule)' - 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules)' +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py index c4b9763fa3c..e11d02b694c 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_forwarding_rule_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP ForwardingRule -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -54,7 +54,54 @@ options: - This field is not applicable to global forwarding rules. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' 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 a20f6237e2e..dee335d5e9c 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_global_address.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_global_address.py @@ -34,7 +34,7 @@ description: - Represents a Global Address resource. Global addresses are used for HTTP(S) load balancing. short_description: Creates a GCP GlobalAddress -version_added: 2.6 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -54,7 +54,7 @@ options: - The static external IP address represented by this resource. required: false type: str - version_added: 2.8 + version_added: '2.8' description: description: - An optional description of this resource. @@ -84,7 +84,7 @@ options: - This field is not applicable to addresses with addressType=EXTERNAL. required: false type: int - version_added: 2.9 + version_added: '2.9' address_type: description: - The type of the address to reserve, default is EXTERNAL. @@ -94,7 +94,7 @@ options: required: false default: EXTERNAL type: str - version_added: 2.8 + version_added: '2.8' purpose: description: - The purpose of the resource. For global internal addresses it can be * VPC_PEERING @@ -102,7 +102,7 @@ options: - 'Some valid choices include: "VPC_PEERING"' required: false type: str - version_added: 2.9 + version_added: '2.9' network: description: - The URL of the network in which to reserve the IP range. The IP range must be @@ -116,11 +116,57 @@ options: }}"' required: false type: dict - version_added: 2.9 -extends_documentation_fragment: gcp + version_added: '2.9' + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str notes: - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/globalAddresses)' - 'Reserving a Static External IP Address: U(https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address)' +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py b/lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py index e6a115a2f53..3c6e0592e27 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_global_address_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP GlobalAddress -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -48,7 +48,54 @@ options: - Each additional filter in the list will act be added as an AND condition (filter1 and filter2) . type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' 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 4f1832eaca5..fa3b0484ce6 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 @@ -37,7 +37,7 @@ description: - For more information, see U(https://cloud.google.com/compute/docs/load-balancing/http/) . short_description: Creates a GCP GlobalForwardingRule -version_added: 2.6 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -107,6 +107,54 @@ options: required: false default: EXTERNAL type: str + metadata_filters: + description: + - Opaque filter criteria used by Loadbalancer to restrict routing configuration + to a limited set xDS compliant clients. In their xDS requests to Loadbalancer, + xDS clients present node metadata. If a match takes place, the relevant routing + configuration is made available to those proxies. + - For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY, + at least one of the filterLabels must match the corresponding label provided + in the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of + its filterLabels must match with corresponding labels in the provided metadata. + - metadataFilters specified here can be overridden by those specified in the UrlMap + that this ForwardingRule references. + - metadataFilters only applies to Loadbalancers that have their loadBalancingScheme + set to INTERNAL_SELF_MANAGED. + required: false + type: list + version_added: '2.10' + suboptions: + filter_match_criteria: + description: + - Specifies how individual filterLabel matches within the list of filterLabels + contribute towards the overall metadataFilter match. + - MATCH_ANY - At least one of the filterLabels must have a matching label + in the provided metadata. + - MATCH_ALL - All filterLabels must have matching labels in the provided metadata. + - 'Some valid choices include: "MATCH_ANY", "MATCH_ALL"' + required: true + type: str + filter_labels: + description: + - The list of label value pairs that must match labels in the provided metadata + based on filterMatchCriteria This list must not be empty and can have at + the most 64 entries. + required: true + type: list + suboptions: + name: + description: + - Name of the metadata label. The length must be between 1 and 1024 characters, + inclusive. + required: true + type: str + value: + description: + - The value that the label must match. The value has a maximum length + of 1024 characters. + required: true + type: str name: description: - Name of the resource; provided by the client when the resource is created. The @@ -149,9 +197,46 @@ options: description: - The URL of the target resource to receive the matched traffic. - The forwarded traffic must be of a type appropriate to the target object. + - For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are valid. + required: true + type: str + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. type: str -extends_documentation_fragment: gcp ''' EXAMPLES = ''' @@ -296,6 +381,52 @@ loadBalancingScheme: global forwarding rules cannot be used for INTERNAL load balancing.' returned: success type: str +metadataFilters: + description: + - Opaque filter criteria used by Loadbalancer to restrict routing configuration + to a limited set xDS compliant clients. In their xDS requests to Loadbalancer, + xDS clients present node metadata. If a match takes place, the relevant routing + configuration is made available to those proxies. + - For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY, + at least one of the filterLabels must match the corresponding label provided in + the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of its + filterLabels must match with corresponding labels in the provided metadata. + - metadataFilters specified here can be overridden by those specified in the UrlMap + that this ForwardingRule references. + - metadataFilters only applies to Loadbalancers that have their loadBalancingScheme + set to INTERNAL_SELF_MANAGED. + returned: success + type: complex + contains: + filterMatchCriteria: + description: + - Specifies how individual filterLabel matches within the list of filterLabels + contribute towards the overall metadataFilter match. + - MATCH_ANY - At least one of the filterLabels must have a matching label in + the provided metadata. + - MATCH_ALL - All filterLabels must have matching labels in the provided metadata. + returned: success + type: str + filterLabels: + description: + - The list of label value pairs that must match labels in the provided metadata + based on filterMatchCriteria This list must not be empty and can have at the + most 64 entries. + returned: success + type: complex + contains: + name: + description: + - Name of the metadata label. The length must be between 1 and 1024 characters, + inclusive. + returned: success + type: str + value: + description: + - The value that the label must match. The value has a maximum length of + 1024 characters. + returned: success + type: str name: description: - Name of the resource; provided by the client when the resource is created. The @@ -332,6 +463,7 @@ target: description: - The URL of the target resource to receive the matched traffic. - The forwarded traffic must be of a type appropriate to the target object. + - For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are valid. returned: success type: str ''' @@ -340,7 +472,7 @@ target: # Imports ################################################################################ -from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict +from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict import json import time @@ -360,6 +492,16 @@ def main(): ip_protocol=dict(type='str'), ip_version=dict(type='str'), load_balancing_scheme=dict(default='EXTERNAL', type='str'), + metadata_filters=dict( + type='list', + elements='dict', + options=dict( + filter_match_criteria=dict(required=True, type='str'), + filter_labels=dict( + required=True, type='list', elements='dict', options=dict(name=dict(required=True, type='str'), value=dict(required=True, type='str')) + ), + ), + ), name=dict(required=True, type='str'), network=dict(type='dict'), port_range=dict(type='str'), @@ -434,6 +576,7 @@ def resource_to_request(module): u'IPProtocol': module.params.get('ip_protocol'), u'ipVersion': module.params.get('ip_version'), u'loadBalancingScheme': module.params.get('load_balancing_scheme'), + u'metadataFilters': GlobalForwardingRuleMetadatafiltersArray(module.params.get('metadata_filters', []), module).to_request(), u'name': module.params.get('name'), u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'), u'portRange': module.params.get('port_range'), @@ -510,6 +653,7 @@ def response_to_hash(module, response): u'IPProtocol': response.get(u'IPProtocol'), u'ipVersion': response.get(u'ipVersion'), u'loadBalancingScheme': response.get(u'loadBalancingScheme'), + u'metadataFilters': GlobalForwardingRuleMetadatafiltersArray(response.get(u'metadataFilters', []), module).from_response(), u'name': response.get(u'name'), u'network': response.get(u'network'), u'portRange': response.get(u'portRange'), @@ -552,5 +696,69 @@ def raise_if_errors(response, err_path, module): module.fail_json(msg=errors) +class GlobalForwardingRuleMetadatafiltersArray(object): + def __init__(self, request, module): + self.module = module + if request: + self.request = request + else: + self.request = [] + + def to_request(self): + items = [] + for item in self.request: + items.append(self._request_for_item(item)) + return items + + def from_response(self): + items = [] + for item in self.request: + items.append(self._response_from_item(item)) + return items + + def _request_for_item(self, item): + return remove_nones_from_dict( + { + u'filterMatchCriteria': item.get('filter_match_criteria'), + u'filterLabels': GlobalForwardingRuleFilterlabelsArray(item.get('filter_labels', []), self.module).to_request(), + } + ) + + def _response_from_item(self, item): + return remove_nones_from_dict( + { + u'filterMatchCriteria': item.get(u'filterMatchCriteria'), + u'filterLabels': GlobalForwardingRuleFilterlabelsArray(item.get(u'filterLabels', []), self.module).from_response(), + } + ) + + +class GlobalForwardingRuleFilterlabelsArray(object): + def __init__(self, request, module): + self.module = module + if request: + self.request = request + else: + self.request = [] + + def to_request(self): + items = [] + for item in self.request: + items.append(self._request_for_item(item)) + return items + + def from_response(self): + items = [] + for item in self.request: + items.append(self._response_from_item(item)) + return items + + def _request_for_item(self, item): + return remove_nones_from_dict({u'name': item.get('name'), u'value': item.get('value')}) + + def _response_from_item(self, item): + return remove_nones_from_dict({u'name': item.get(u'name'), u'value': item.get(u'value')}) + + if __name__ == '__main__': main() diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py index c10fc014b34..1a98a7e3cf8 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_global_forwarding_rule_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP GlobalForwardingRule -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -48,7 +48,54 @@ options: - Each additional filter in the list will act be added as an AND condition (filter1 and filter2) . type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' @@ -128,6 +175,54 @@ resources: NOTE: Currently global forwarding rules cannot be used for INTERNAL load balancing.' returned: success type: str + metadataFilters: + description: + - Opaque filter criteria used by Loadbalancer to restrict routing configuration + to a limited set xDS compliant clients. In their xDS requests to Loadbalancer, + xDS clients present node metadata. If a match takes place, the relevant routing + configuration is made available to those proxies. + - For each metadataFilter in this list, if its filterMatchCriteria is set to + MATCH_ANY, at least one of the filterLabels must match the corresponding label + provided in the metadata. If its filterMatchCriteria is set to MATCH_ALL, + then all of its filterLabels must match with corresponding labels in the provided + metadata. + - metadataFilters specified here can be overridden by those specified in the + UrlMap that this ForwardingRule references. + - metadataFilters only applies to Loadbalancers that have their loadBalancingScheme + set to INTERNAL_SELF_MANAGED. + returned: success + type: complex + contains: + filterMatchCriteria: + description: + - Specifies how individual filterLabel matches within the list of filterLabels + contribute towards the overall metadataFilter match. + - MATCH_ANY - At least one of the filterLabels must have a matching label + in the provided metadata. + - MATCH_ALL - All filterLabels must have matching labels in the provided + metadata. + returned: success + type: str + filterLabels: + description: + - The list of label value pairs that must match labels in the provided metadata + based on filterMatchCriteria This list must not be empty and can have + at the most 64 entries. + returned: success + type: complex + contains: + name: + description: + - Name of the metadata label. The length must be between 1 and 1024 + characters, inclusive. + returned: success + type: str + value: + description: + - The value that the label must match. The value has a maximum length + of 1024 characters. + returned: success + type: str name: description: - Name of the resource; provided by the client when the resource is created. @@ -165,6 +260,8 @@ resources: description: - The URL of the target resource to receive the matched traffic. - The forwarded traffic must be of a type appropriate to the target object. + - For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are + valid. returned: success type: str ''' 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 438f4f144fc..3e7cc6840e6 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_health_check.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_health_check.py @@ -41,7 +41,7 @@ description: 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -107,7 +107,7 @@ options: - 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. - - 'Some valid choices include: "TCP", "SSL", "HTTP", "HTTPS"' + - 'Some valid choices include: "TCP", "SSL", "HTTP", "HTTPS", "HTTP2"' required: false type: str http_health_check: @@ -171,7 +171,7 @@ options: - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"' required: false type: str - version_added: 2.9 + version_added: '2.9' https_health_check: description: - A nested object resource. @@ -233,7 +233,7 @@ options: - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"' required: false type: str - version_added: 2.9 + version_added: '2.9' tcp_health_check: description: - A nested object resource. @@ -288,7 +288,7 @@ options: - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"' required: false type: str - version_added: 2.9 + version_added: '2.9' ssl_health_check: description: - A nested object resource. @@ -343,11 +343,119 @@ options: - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"' required: false type: str - version_added: 2.9 -extends_documentation_fragment: gcp + version_added: '2.9' + http2_health_check: + description: + - A nested object resource. + required: false + type: dict + version_added: '2.10' + suboptions: + host: + description: + - The value of the host header in the HTTP2 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 + type: str + request_path: + description: + - The request path of the HTTP2 health check request. + - The default value is /. + required: false + default: "/" + 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. + required: false + type: str + port: + description: + - The TCP port number for the HTTP2 health check request. + - The default value is 443. + required: false + type: int + port_name: + description: + - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name + are defined, port takes precedence. + required: false + 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. + - 'Some valid choices include: "NONE", "PROXY_V1"' + required: false + default: NONE + type: str + port_specification: + description: + - 'Specifies how port is selected for health checking, can be one of the following + values: * `USE_FIXED_PORT`: The port number in `port` is used for health + checking.' + - "* `USE_NAMED_PORT`: The `portName` is used for health checking." + - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for + each network endpoint is used for health checking. For other backends, the + port or named port specified in the Backend Service is used for health checking." + - If not specified, HTTP2 health check follows behavior specified in `port` + and `portName` fields. + - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"' + required: false + type: str + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str notes: - 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/healthChecks)' - 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/health-checks)' +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' @@ -638,6 +746,62 @@ sslHealthCheck: `portName` fields. returned: success type: str +http2HealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + host: + description: + - The value of the host header in the HTTP2 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 HTTP2 health check request. + - The default value is /. + 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 HTTP2 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 + portSpecification: + description: + - 'Specifies how port is selected for health checking, can be one of the following + values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking.' + - "* `USE_NAMED_PORT`: The `portName` is used for health checking." + - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each + network endpoint is used for health checking. For other backends, the port + or named port specified in the Backend Service is used for health checking." + - If not specified, HTTP2 health check follows behavior specified in `port` + and `portName` fields. + returned: success + type: str ''' ################################################################################ @@ -712,8 +876,20 @@ def main(): port_specification=dict(type='str'), ), ), + http2_health_check=dict( + type='dict', + options=dict( + host=dict(type='str'), + request_path=dict(default='/', type='str'), + response=dict(type='str'), + port=dict(type='int'), + port_name=dict(type='str'), + proxy_header=dict(default='NONE', type='str'), + port_specification=dict(type='str'), + ), + ), ), - mutually_exclusive=[['http_health_check', 'https_health_check', 'ssl_health_check', 'tcp_health_check']], + mutually_exclusive=[['http2_health_check', 'http_health_check', 'https_health_check', 'ssl_health_check', 'tcp_health_check']], ) if not module.params['scopes']: @@ -776,6 +952,7 @@ def resource_to_request(module): 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'http2HealthCheck': HealthCheckHttp2healthcheck(module.params.get('http2_health_check', {}), module).to_request(), } return_vals = {} for k, v in request.items(): @@ -854,6 +1031,7 @@ def response_to_hash(module, 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'http2HealthCheck': HealthCheckHttp2healthcheck(response.get(u'http2HealthCheck', {}), module).from_response(), } @@ -1028,5 +1206,40 @@ class HealthCheckSslhealthcheck(object): ) +class HealthCheckHttp2healthcheck(object): + def __init__(self, request, module): + self.module = module + if request: + self.request = request + else: + self.request = {} + + def to_request(self): + return remove_nones_from_dict( + { + u'host': self.request.get('host'), + u'requestPath': self.request.get('request_path'), + u'response': self.request.get('response'), + u'port': self.request.get('port'), + u'portName': self.request.get('port_name'), + u'proxyHeader': self.request.get('proxy_header'), + u'portSpecification': self.request.get('port_specification'), + } + ) + + def from_response(self): + return remove_nones_from_dict( + { + u'host': self.request.get(u'host'), + u'requestPath': self.request.get(u'requestPath'), + u'response': self.request.get(u'response'), + u'port': self.request.get(u'port'), + u'portName': self.request.get(u'portName'), + u'proxyHeader': self.request.get(u'proxyHeader'), + u'portSpecification': self.request.get(u'portSpecification'), + } + ) + + if __name__ == '__main__': main() diff --git a/lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py b/lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py index 3e54f6740f1..f2480c3d871 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_health_check_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP HealthCheck -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -48,7 +48,54 @@ options: - Each additional filter in the list will act be added as an AND condition (filter1 and filter2) . type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' @@ -347,6 +394,64 @@ resources: and `portName` fields. returned: success type: str + http2HealthCheck: + description: + - A nested object resource. + returned: success + type: complex + contains: + host: + description: + - The value of the host header in the HTTP2 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 HTTP2 health check request. + - The default value is /. + 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 HTTP2 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 + portSpecification: + description: + - 'Specifies how port is selected for health checking, can be one of the + following values: * `USE_FIXED_PORT`: The port number in `port` is used + for health checking.' + - "* `USE_NAMED_PORT`: The `portName` is used for health checking." + - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for + each network endpoint is used for health checking. For other backends, + the port or named port specified in the Backend Service is used for health + checking." + - If not specified, HTTP2 health check follows behavior specified in `port` + and `portName` fields. + returned: success + type: str ''' ################################################################################ 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 fab94111268..b0eb0f63f5b 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 @@ -34,7 +34,7 @@ description: - 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -113,10 +113,56 @@ options: failures. The default value is 2. required: false type: int -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str notes: - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/httpHealthChecks)' - 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)' +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py index 528460553d6..c633a4f2fb1 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_http_health_check_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP HttpHealthCheck -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -48,7 +48,54 @@ options: - Each additional filter in the list will act be added as an AND condition (filter1 and filter2) . type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' 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 05bc76a8fd9..0d5c7cdcc53 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 @@ -34,7 +34,7 @@ description: - 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -110,10 +110,56 @@ options: failures. The default value is 2. required: false type: int -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str notes: - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/httpsHealthChecks)' - 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)' +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py index 868b051ff2a..78b247bef4a 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_https_health_check_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP HttpsHealthCheck -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -48,7 +48,54 @@ options: - Each additional filter in the list will act be added as an AND condition (filter1 and filter2) . type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_image.py b/lib/ansible/modules/cloud/google/gcp_compute_image.py index 4dd2699598f..0b79ad4fd41 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_image.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_image.py @@ -43,7 +43,7 @@ description: 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -79,24 +79,16 @@ options: type: str 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. + - A list of features to enable on the guest operating system. + - Applicable only for bootable images. required: false type: list suboptions: type: description: - - The type of supported feature. Currently 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. - - 'Some valid choices include: "VIRTIO_SCSI_MULTIQUEUE"' + - The type of supported feature. + - 'Some valid choices include: "MULTI_IP_SUBNET", "SECURE_BOOT", "UEFI_COMPATIBLE", + "VIRTIO_SCSI_MULTIQUEUE", "WINDOWS"' required: false type: str image_encryption_key: @@ -118,7 +110,7 @@ options: - Labels to apply to this Image. required: false type: dict - version_added: 2.8 + version_added: '2.8' licenses: description: - Any applicable license URI. @@ -199,10 +191,56 @@ options: - 'Some valid choices include: "RAW"' required: false type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str notes: - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/images)' - 'Official Documentation: U(https://cloud.google.com/compute/docs/images)' +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' @@ -301,23 +339,14 @@ family: 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. + - A list of features to enable on the guest operating system. + - Applicable only for bootable images. returned: success type: complex contains: type: description: - - The type of supported feature. Currently 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. + - The type of supported feature. returned: success type: str id: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_image_info.py b/lib/ansible/modules/cloud/google/gcp_compute_image_info.py index 6d8c14b652f..1e95e79fc4d 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_image_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_image_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_image_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP Image -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -48,7 +48,54 @@ options: - Each additional filter in the list will act be added as an AND condition (filter1 and filter2) . type: list -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' @@ -141,25 +188,14 @@ resources: 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. + - A list of features to enable on the guest operating system. + - Applicable only for bootable images. returned: success type: complex contains: type: description: - - The type of supported feature. Currently 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. + - The type of supported feature. returned: success type: str id: diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance.py b/lib/ansible/modules/cloud/google/gcp_compute_instance.py index 49f6ca8dfe5..d2a72647463 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance.py @@ -33,7 +33,7 @@ module: gcp_compute_instance description: - An instance is a virtual machine (VM) hosted on Google's infrastructure. short_description: Creates a GCP Instance -version_added: 2.6 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -62,7 +62,7 @@ options: - Whether the resource should be protected against deletion. required: false type: bool - version_added: 2.9 + version_added: '2.9' disks: description: - An array of disks that are associated with the instances that are created from @@ -231,13 +231,13 @@ options: when using zonal DNS. required: false type: str - version_added: 2.9 + version_added: '2.9' labels: description: - Labels to apply to this instance. A list of key->value pairs. required: false type: dict - version_added: 2.9 + version_added: '2.9' metadata: description: - The metadata key/value pairs to assign to instances that are created from this @@ -415,7 +415,7 @@ options: - Configuration for various parameters related to shielded instances. required: false type: dict - version_added: 2.9 + version_added: '2.9' suboptions: enable_secure_boot: description: @@ -442,7 +442,7 @@ options: "SUSPENDING", "SUSPENDED", "TERMINATED"' required: false type: str - version_added: 2.8 + version_added: '2.8' tags: description: - A list of tags to apply to this instance. Tags are used to identify valid sources @@ -472,7 +472,43 @@ options: - A reference to the zone where the machine resides. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str ''' EXAMPLES = ''' 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 4d4e304efb8..75def45f4a2 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py @@ -36,7 +36,7 @@ description: 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -124,8 +124,44 @@ options: - Only the full identifier of the instance will be returned. required: false type: list - version_added: 2.8 -extends_documentation_fragment: gcp + version_added: '2.8' + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py index 59d27856cd0..11f34a11a50 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_instance_group_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP InstanceGroup -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -53,7 +53,54 @@ options: - A reference to the zone where the instance group resides. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' 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 9ece0b7b7f9..14b18a48e87 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 @@ -38,7 +38,7 @@ description: 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 +version_added: '2.6' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -122,7 +122,43 @@ options: - The zone the managed instance group resides. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py index aa872bd0bfa..ba97143ece1 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_instance_group_manager_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP InstanceGroupManager -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -53,7 +53,54 @@ options: - The zone the managed instance group resides. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_info.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_info.py index 988e67cd50d..bc852d6fbf6 100644 --- a/lib/ansible/modules/cloud/google/gcp_compute_instance_info.py +++ b/lib/ansible/modules/cloud/google/gcp_compute_instance_info.py @@ -35,7 +35,7 @@ description: - This module was called C(gcp_compute_instance_facts) before Ansible 2.9. The usage has not changed. short_description: Gather info for GCP Instance -version_added: 2.7 +version_added: '2.7' author: Google Inc. (@googlecloudplatform) requirements: - python >= 2.6 @@ -53,7 +53,54 @@ options: - A reference to the zone where the machine resides. required: true type: str -extends_documentation_fragment: gcp + project: + description: + - The Google Cloud Platform project to use. + type: str + auth_kind: + description: + - The type of credential used. + type: str + required: true + choices: + - application + - machineaccount + - serviceaccount + service_account_contents: + description: + - The contents of a Service Account JSON file, either in a dictionary or as a + JSON string that represents it. + type: jsonarg + service_account_file: + description: + - The path of a Service Account JSON file if serviceaccount is selected as type. + type: path + service_account_email: + description: + - An optional service account email address if machineaccount is selected and + the user does not wish to use the default email. + type: str + scopes: + description: + - Array of scopes to be used + type: list + env_type: + description: + - Specifies which Ansible environment you're running this module within. + - This should not be set unless you know what you're doing. + - This only alters the User Agent string for any API requests. + type: str +notes: +- for authentication, you can set service_account_file using the c(gcp_service_account_file) + env variable. +- for authentication, you can set service_account_contents using the c(GCP_SERVICE_ACCOUNT_CONTENTS) + env variable. +- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL) + env variable. +- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable. +- For authentication, you can set scopes using the C(GCP_SCOPES) env variable. +- Environment variables values will only be used if the playbook values are not set. +- The I(service_account_email) and I(service_account_file) options are mutually exclusive. ''' EXAMPLES = ''' diff --git a/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml b/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml new file mode 100644 index 00000000000..7a775501f52 --- /dev/null +++ b/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml @@ -0,0 +1,147 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: delete a firewall + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a firewall + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that firewall was created + gcp_compute_firewall_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a firewall that already exists + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a firewall + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that firewall was deleted + gcp_compute_firewall_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a firewall that does not exist + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_firewall/tasks/main.yml b/test/integration/targets/gcp_compute_firewall/tasks/main.yml index 7a775501f52..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_firewall/tasks/main.yml +++ b/test/integration/targets/gcp_compute_firewall/tasks/main.yml @@ -1,147 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: delete a firewall - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a firewall - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that firewall was created - gcp_compute_firewall_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a firewall that already exists - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a firewall - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that firewall was deleted - gcp_compute_firewall_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a firewall that does not exist - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml b/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml new file mode 100644 index 00000000000..c46fa9b8bad --- /dev/null +++ b/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml @@ -0,0 +1,170 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: create a address + gcp_compute_address: + name: address-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: create a target pool + gcp_compute_target_pool: + name: targetpool-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: targetpool +- name: delete a forwarding rule + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a forwarding rule + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that forwarding_rule was created + gcp_compute_forwarding_rule_info: + filters: + - name = {{ resource_name }} + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a forwarding rule that already exists + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a forwarding rule + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that forwarding_rule was deleted + gcp_compute_forwarding_rule_info: + filters: + - name = {{ resource_name }} + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a forwarding rule that does not exist + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a target pool + gcp_compute_target_pool: + name: targetpool-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: targetpool + ignore_errors: true +- name: delete a address + gcp_compute_address: + name: address-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml b/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml index c46fa9b8bad..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml +++ b/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml @@ -1,170 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: create a address - gcp_compute_address: - name: address-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: create a target pool - gcp_compute_target_pool: - name: targetpool-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: targetpool -- name: delete a forwarding rule - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a forwarding rule - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that forwarding_rule was created - gcp_compute_forwarding_rule_info: - filters: - - name = {{ resource_name }} - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a forwarding rule that already exists - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a forwarding rule - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that forwarding_rule was deleted - gcp_compute_forwarding_rule_info: - filters: - - name = {{ resource_name }} - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a forwarding rule that does not exist - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a target pool - gcp_compute_target_pool: - name: targetpool-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: targetpool - ignore_errors: true -- name: delete a address - gcp_compute_address: - name: address-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml b/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml new file mode 100644 index 00000000000..fdbd73770a1 --- /dev/null +++ b/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml @@ -0,0 +1,102 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: delete a global address + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a global address + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_address was created + gcp_compute_global_address_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a global address that already exists + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a global address + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_address was deleted + gcp_compute_global_address_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a global address that does not exist + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_global_address/tasks/main.yml b/test/integration/targets/gcp_compute_global_address/tasks/main.yml index fdbd73770a1..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_global_address/tasks/main.yml +++ b/test/integration/targets/gcp_compute_global_address/tasks/main.yml @@ -1,102 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: delete a global address - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a global address - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_address was created - gcp_compute_global_address_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a global address that already exists - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a global address - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_address was deleted - gcp_compute_global_address_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a global address that does not exist - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml new file mode 100644 index 00000000000..234f0360464 --- /dev/null +++ b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml @@ -0,0 +1,251 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: create a global address + gcp_compute_global_address: + name: globaladdress-globalforwardingrule + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: globaladdress +- name: create a instance group + gcp_compute_instance_group: + name: instancegroup-globalforwardingrule + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-globalforwardingrule + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: create a backend service + gcp_compute_backend_service: + name: backendservice-globalforwardingrule + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: backendservice +- name: create a URL map + gcp_compute_url_map: + name: urlmap-globalforwardingrule + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: urlmap +- name: create a target HTTP proxy + gcp_compute_target_http_proxy: + name: targethttpproxy-globalforwardingrule + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: httpproxy +- name: delete a global forwarding rule + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a global forwarding rule + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_forwarding_rule was created + gcp_compute_global_forwarding_rule_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a global forwarding rule that already exists + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a global forwarding rule + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_forwarding_rule was deleted + gcp_compute_global_forwarding_rule_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a global forwarding rule that does not exist + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a target HTTP proxy + gcp_compute_target_http_proxy: + name: targethttpproxy-globalforwardingrule + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: httpproxy + ignore_errors: true +- name: delete a URL map + gcp_compute_url_map: + name: urlmap-globalforwardingrule + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: urlmap + ignore_errors: true +- name: delete a backend service + gcp_compute_backend_service: + name: backendservice-globalforwardingrule + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: backendservice + ignore_errors: true +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-globalforwardingrule + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-globalforwardingrule + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true +- name: delete a global address + gcp_compute_global_address: + name: globaladdress-globalforwardingrule + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: globaladdress + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml index 234f0360464..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml +++ b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml @@ -1,251 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: create a global address - gcp_compute_global_address: - name: globaladdress-globalforwardingrule - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: globaladdress -- name: create a instance group - gcp_compute_instance_group: - name: instancegroup-globalforwardingrule - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-globalforwardingrule - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: create a backend service - gcp_compute_backend_service: - name: backendservice-globalforwardingrule - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: backendservice -- name: create a URL map - gcp_compute_url_map: - name: urlmap-globalforwardingrule - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: urlmap -- name: create a target HTTP proxy - gcp_compute_target_http_proxy: - name: targethttpproxy-globalforwardingrule - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: httpproxy -- name: delete a global forwarding rule - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a global forwarding rule - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_forwarding_rule was created - gcp_compute_global_forwarding_rule_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a global forwarding rule that already exists - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a global forwarding rule - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_forwarding_rule was deleted - gcp_compute_global_forwarding_rule_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a global forwarding rule that does not exist - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a target HTTP proxy - gcp_compute_target_http_proxy: - name: targethttpproxy-globalforwardingrule - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: httpproxy - ignore_errors: true -- name: delete a URL map - gcp_compute_url_map: - name: urlmap-globalforwardingrule - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: urlmap - ignore_errors: true -- name: delete a backend service - gcp_compute_backend_service: - name: backendservice-globalforwardingrule - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: backendservice - ignore_errors: true -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-globalforwardingrule - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-globalforwardingrule - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true -- name: delete a global address - gcp_compute_global_address: - name: globaladdress-globalforwardingrule - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: globaladdress - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml new file mode 100644 index 00000000000..ab1c837cc7c --- /dev/null +++ b/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml @@ -0,0 +1,142 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: delete a health check + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a health check + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that health_check was created + gcp_compute_health_check_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a health check that already exists + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a health check + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that health_check was deleted + gcp_compute_health_check_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a health check that does not exist + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_health_check/tasks/main.yml index ab1c837cc7c..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_health_check/tasks/main.yml +++ b/test/integration/targets/gcp_compute_health_check/tasks/main.yml @@ -1,142 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: delete a health check - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a health check - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that health_check was created - gcp_compute_health_check_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a health check that already exists - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a health check - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that health_check was deleted - gcp_compute_health_check_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a health check that does not exist - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml new file mode 100644 index 00000000000..5e27f31b38a --- /dev/null +++ b/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml @@ -0,0 +1,122 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a HTTP health check + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that http_health_check was created + gcp_compute_http_health_check_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a HTTP health check that already exists + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that http_health_check was deleted + gcp_compute_http_health_check_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a HTTP health check that does not exist + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml index 5e27f31b38a..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml +++ b/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml @@ -1,122 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a HTTP health check - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that http_health_check was created - gcp_compute_http_health_check_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a HTTP health check that already exists - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that http_health_check was deleted - gcp_compute_http_health_check_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a HTTP health check that does not exist - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml new file mode 100644 index 00000000000..7d34fc83741 --- /dev/null +++ b/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml @@ -0,0 +1,122 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: delete a HTTPS health check + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a HTTPS health check + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that https_health_check was created + gcp_compute_https_health_check_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a HTTPS health check that already exists + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a HTTPS health check + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that https_health_check was deleted + gcp_compute_https_health_check_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a HTTPS health check that does not exist + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml index 7d34fc83741..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml +++ b/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml @@ -1,122 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: delete a HTTPS health check - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a HTTPS health check - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that https_health_check was created - gcp_compute_https_health_check_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a HTTPS health check that already exists - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a HTTPS health check - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that https_health_check was deleted - gcp_compute_https_health_check_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a HTTPS health check that does not exist - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_image/tasks/autogen.yml b/test/integration/targets/gcp_compute_image/tasks/autogen.yml new file mode 100644 index 00000000000..b51608bc116 --- /dev/null +++ b/test/integration/targets/gcp_compute_image/tasks/autogen.yml @@ -0,0 +1,129 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: create a disk + gcp_compute_disk: + name: disk-image + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: disk +- name: delete a image + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a image + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that image was created + gcp_compute_image_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a image that already exists + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a image + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that image was deleted + gcp_compute_image_info: + filters: + - name = {{ resource_name }} + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a image that does not exist + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a disk + gcp_compute_disk: + name: disk-image + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: disk + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_image/tasks/main.yml b/test/integration/targets/gcp_compute_image/tasks/main.yml index b51608bc116..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_image/tasks/main.yml +++ b/test/integration/targets/gcp_compute_image/tasks/main.yml @@ -1,129 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: create a disk - gcp_compute_disk: - name: disk-image - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: disk -- name: delete a image - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a image - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that image was created - gcp_compute_image_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a image that already exists - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a image - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that image was deleted - gcp_compute_image_info: - filters: - - name = {{ resource_name }} - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a image that does not exist - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a disk - gcp_compute_disk: - name: disk-image - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: disk - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_instance/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance/tasks/autogen.yml new file mode 100644 index 00000000000..766f33222d4 --- /dev/null +++ b/test/integration/targets/gcp_compute_instance/tasks/autogen.yml @@ -0,0 +1,251 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: create a disk + gcp_compute_disk: + name: disk-instance + size_gb: 50 + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: disk +- name: create a network + gcp_compute_network: + name: network-instance + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: create a address + gcp_compute_address: + name: address-instance + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: delete a instance + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was created + gcp_compute_instance_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance that already exists + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was deleted + gcp_compute_instance_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance that does not exist + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a address + gcp_compute_address: + name: address-instance + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true +- name: delete a network + gcp_compute_network: + name: network-instance + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true +- name: delete a disk + gcp_compute_disk: + name: disk-instance + size_gb: 50 + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: disk + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_instance/tasks/main.yml b/test/integration/targets/gcp_compute_instance/tasks/main.yml index 766f33222d4..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_instance/tasks/main.yml +++ b/test/integration/targets/gcp_compute_instance/tasks/main.yml @@ -1,251 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: create a disk - gcp_compute_disk: - name: disk-instance - size_gb: 50 - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: disk -- name: create a network - gcp_compute_network: - name: network-instance - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: create a address - gcp_compute_address: - name: address-instance - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: delete a instance - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was created - gcp_compute_instance_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance that already exists - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was deleted - gcp_compute_instance_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance that does not exist - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a address - gcp_compute_address: - name: address-instance - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true -- name: delete a network - gcp_compute_network: - name: network-instance - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true -- name: delete a disk - gcp_compute_disk: - name: disk-instance - size_gb: 50 - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: disk - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml new file mode 100644 index 00000000000..b16a128bbd8 --- /dev/null +++ b/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml @@ -0,0 +1,149 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: create a network + gcp_compute_network: + name: network-instancegroup + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: delete a instance group + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance group + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group was created + gcp_compute_instance_group_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance group that already exists + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance group + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group was deleted + gcp_compute_instance_group_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance group that does not exist + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a network + gcp_compute_network: + name: network-instancegroup + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_instance_group/tasks/main.yml b/test/integration/targets/gcp_compute_instance_group/tasks/main.yml index b16a128bbd8..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_instance_group/tasks/main.yml +++ b/test/integration/targets/gcp_compute_instance_group/tasks/main.yml @@ -1,149 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: create a network - gcp_compute_network: - name: network-instancegroup - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: delete a instance group - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance group - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group was created - gcp_compute_instance_group_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance group that already exists - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance group - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group was deleted - gcp_compute_instance_group_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance group that does not exist - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a network - gcp_compute_network: - name: network-instancegroup - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml new file mode 100644 index 00000000000..39c62e3956c --- /dev/null +++ b/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml @@ -0,0 +1,206 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file at +# https://www.github.com/GoogleCloudPlatform/magic-modules +# +# ---------------------------------------------------------------------------- +# Pre-test setup +- name: create a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: create a address + gcp_compute_address: + name: address-instancetemplate + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: create a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancetemplate +- name: delete a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group_manager was created + gcp_compute_instance_group_manager_info: + filters: + - name = {{ resource_name }} + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance group manager that already exists + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group_manager was deleted + gcp_compute_instance_group_manager_info: + filters: + - name = {{ resource_name }} + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/compute + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance group manager that does not exist + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancetemplate + ignore_errors: true +- name: delete a address + gcp_compute_address: + name: address-instancetemplate + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true +- name: delete a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml b/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml index 39c62e3956c..45d6e49178c 100644 --- a/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml +++ b/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml @@ -1,206 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** -# -# ---------------------------------------------------------------------------- -# -# This file is automatically generated by Magic Modules and manual -# changes will be clobbered when the file is regenerated. -# -# Please read more about how to change this file at -# https://www.github.com/GoogleCloudPlatform/magic-modules -# -# ---------------------------------------------------------------------------- -# Pre-test setup -- name: create a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: create a address - gcp_compute_address: - name: address-instancetemplate - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: create a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancetemplate -- name: delete a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group_manager was created - gcp_compute_instance_group_manager_info: - filters: - - name = {{ resource_name }} - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance group manager that already exists - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group_manager was deleted - gcp_compute_instance_group_manager_info: - filters: - - name = {{ resource_name }} - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/compute - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance group manager that does not exist - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancetemplate - ignore_errors: true -- name: delete a address - gcp_compute_address: - name: address-instancetemplate - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true -- name: delete a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml