diff options
author | The Magician <magic-modules@google.com> | 2019-10-02 11:31:46 -0700 |
---|---|---|
committer | ansibot <ansibot@users.noreply.github.com> | 2019-10-02 14:31:45 -0400 |
commit | 93f851b698d9d8f50d0b1ca7b7c21cc84510f00b (patch) | |
tree | a14a80929c8efc2513fc52de43f5c71b3210ba68 /lib/ansible/modules/cloud/google/gcp_compute_health_check.py | |
parent | c2b8f64e83646ff61cde9296df24e3afa22b0d29 (diff) | |
download | ansible-93f851b698d9d8f50d0b1ca7b7c21cc84510f00b.tar.gz |
Bug fixes for GCP modules (#61915)
Diffstat (limited to 'lib/ansible/modules/cloud/google/gcp_compute_health_check.py')
-rw-r--r-- | lib/ansible/modules/cloud/google/gcp_compute_health_check.py | 229 |
1 files changed, 221 insertions, 8 deletions
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 438f4f144f..3e7cc6840e 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() |