examples showing an improper auth value (#87)

<!-- This change is generated by MagicModules. -->
/cc @rambleraptor
This commit is contained in:
The Magician 2018-09-07 14:15:36 -07:00 committed by Alex Stephen
commit 0a18332815
98 changed files with 2171 additions and 1727 deletions

View file

@ -122,12 +122,12 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a address - name: create a address
gcp_compute_address: gcp_compute_address:
name: test-address1 name: test-address1
region: us-west1 region: us-west1
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -54,7 +54,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a address facts - name: " a address facts"
gcp_compute_address_facts: gcp_compute_address_facts:
region: us-west1 region: us-west1
filters: filters:
@ -65,8 +65,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -121,7 +121,7 @@ items:
- This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER
purposes. purposes.
returned: success returned: success
type: str type: dict
users: users:
description: description:
- The URLs of the resources that are using this address. - The URLs of the resources that are using this address.
@ -157,7 +157,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -55,6 +55,23 @@ options:
description: description:
- Cloud Storage bucket name. - Cloud Storage bucket name.
required: true required: true
cdn_policy:
description:
- Cloud CDN configuration for this Backend Bucket.
required: false
version_added: 2.8
suboptions:
signed_url_cache_max_age_sec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh. Defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header.
The actual headers served in responses will not be altered.'
required: false
default: '3600'
description: description:
description: description:
- An optional textual description of the resource; provided by the client when - An optional textual description of the resource; provided by the client when
@ -76,18 +93,18 @@ options:
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/backendBuckets)' - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/backendBuckets)'
- 'Using a Cloud Storage bucket as a load balancer backend: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-bucket)' - 'Using a Cloud Storage bucket as a load balancer backend: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-bucket)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a bucket - name: create a bucket
gcp_storage_bucket: gcp_storage_bucket:
name: "bucket-backendbucket" name: bucket-backendbucket
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: bucket register: bucket
- name: create a backend bucket - name: create a backend bucket
@ -108,6 +125,23 @@ bucketName:
- Cloud Storage bucket name. - Cloud Storage bucket name.
returned: success returned: success
type: str type: str
cdnPolicy:
description:
- Cloud CDN configuration for this Backend Bucket.
returned: success
type: complex
contains:
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh. Defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header. The
actual headers served in responses will not be altered.'
returned: success
type: int
creationTimestamp: creationTimestamp:
description: description:
- Creation timestamp in RFC3339 text format. - Creation timestamp in RFC3339 text format.
@ -145,7 +179,7 @@ name:
# Imports # 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 json
import time import time
@ -161,6 +195,7 @@ def main():
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
bucket_name=dict(required=True, type='str'), bucket_name=dict(required=True, type='str'),
cdn_policy=dict(type='dict', options=dict(signed_url_cache_max_age_sec=dict(default=3600, type='int'))),
description=dict(type='str'), description=dict(type='str'),
enable_cdn=dict(type='bool'), enable_cdn=dict(type='bool'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
@ -217,6 +252,7 @@ def resource_to_request(module):
request = { request = {
u'kind': 'compute#backendBucket', u'kind': 'compute#backendBucket',
u'bucketName': module.params.get('bucket_name'), u'bucketName': module.params.get('bucket_name'),
u'cdnPolicy': BackendBucketCdnpolicy(module.params.get('cdn_policy', {}), module).to_request(),
u'description': module.params.get('description'), u'description': module.params.get('description'),
u'enableCdn': module.params.get('enable_cdn'), u'enableCdn': module.params.get('enable_cdn'),
u'name': module.params.get('name'), u'name': module.params.get('name'),
@ -286,6 +322,7 @@ def is_different(module, response):
def response_to_hash(module, response): def response_to_hash(module, response):
return { return {
u'bucketName': response.get(u'bucketName'), u'bucketName': response.get(u'bucketName'),
u'cdnPolicy': BackendBucketCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(),
u'creationTimestamp': response.get(u'creationTimestamp'), u'creationTimestamp': response.get(u'creationTimestamp'),
u'description': response.get(u'description'), u'description': response.get(u'description'),
u'enableCdn': response.get(u'enableCdn'), u'enableCdn': response.get(u'enableCdn'),
@ -329,5 +366,20 @@ def raise_if_errors(response, err_path, module):
module.fail_json(msg=errors) module.fail_json(msg=errors)
class BackendBucketCdnpolicy(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'signedUrlCacheMaxAgeSec': self.request.get('signed_url_cache_max_age_sec')})
def from_response(self):
return remove_nones_from_dict({u'signedUrlCacheMaxAgeSec': self.request.get(u'signedUrlCacheMaxAgeSec')})
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a backend bucket facts - name: " a backend bucket facts"
gcp_compute_backend_bucket_facts: gcp_compute_backend_bucket_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -69,6 +69,23 @@ items:
- Cloud Storage bucket name. - Cloud Storage bucket name.
returned: success returned: success
type: str type: str
cdnPolicy:
description:
- Cloud CDN configuration for this Backend Bucket.
returned: success
type: complex
contains:
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be
considered fresh. Defaults to 1hr (3600s). After this time period, the
response will be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control:
public, max-age=[TTL]" header, regardless of any existing Cache-Control
header. The actual headers served in responses will not be altered.'
returned: success
type: int
creationTimestamp: creationTimestamp:
description: description:
- Creation timestamp in RFC3339 text format. - Creation timestamp in RFC3339 text format.
@ -124,7 +141,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -31,8 +31,9 @@ DOCUMENTATION = '''
--- ---
module: gcp_compute_backend_service module: gcp_compute_backend_service
description: description:
- Creates a BackendService resource in the specified project using the data included - A Backend Service defines a group of virtual machines that will serve traffic for
in the request. load balancing. This resource is a global backend service, appropriate for external
load balancing. For internal load balancing, use a regional backend service instead.
short_description: Creates a GCP BackendService short_description: Creates a GCP BackendService
version_added: 2.6 version_added: 2.6
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
@ -65,8 +66,8 @@ options:
- Specifies the balancing mode for this backend. - Specifies the balancing mode for this backend.
- For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION.
Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL).
- This cannot be used for internal load balancing.
required: false required: false
default: UTILIZATION
choices: choices:
- UTILIZATION - UTILIZATION
- RATE - RATE
@ -79,8 +80,8 @@ options:
capacity (depending on balancingMode). A setting of 0 means the group is capacity (depending on balancingMode). A setting of 0 means the group is
completely drained, offering 0% of its available Capacity. Valid range is completely drained, offering 0% of its available Capacity. Valid range is
[0.0,1.0]. [0.0,1.0].
- This cannot be used for internal load balancing.
required: false required: false
default: '1.0'
description: description:
description: description:
- An optional description of this resource. - An optional description of this resource.
@ -88,18 +89,18 @@ options:
required: false required: false
group: group:
description: description:
- This instance group defines the list of instances that serve traffic. Member - The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
virtual machine instances from each instance group must live in the same In case of instance group this defines the list of instances that serve
zone as the instance group itself. traffic. Member virtual machine instances from each instance group must
- No two backends in a backend service are allowed to use same Instance Group live in the same zone as the instance group itself. No two backends in a
resource. backend service are allowed to use same Instance Group resource.
- When the BackendService has load balancing scheme INTERNAL, the instance - For Network Endpoint Groups this defines list of endpoints. All endpoints
group must be in a zone within the same region as the BackendService. of Network Endpoint Group must be hosted on instances located in the same
- 'This field represents a link to a InstanceGroup resource in GCP. It can zone as the Network Endpoint Group.
be specified in two ways. First, you can place in the selfLink of the resource - Backend service can not contain mix of Instance Group and Network Endpoint
here as a string Alternatively, you can add `register: name-of-resource` Group backends.
to a gcp_compute_instance_group task and then set this group field to "{{ - Note that you must specify an Instance Group or Network Endpoint Group resource
name-of-resource }}"' using the fully-qualified URL, rather than a partial URL.
required: false required: false
max_connections: max_connections:
description: description:
@ -107,7 +108,6 @@ options:
either CONNECTION or UTILIZATION balancing modes. either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerInstance - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance
must be set. must be set.
- This cannot be used for internal load balancing.
required: false required: false
max_connections_per_instance: max_connections_per_instance:
description: description:
@ -116,7 +116,6 @@ options:
used in either CONNECTION or UTILIZATION balancing modes. used in either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerInstance - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance
must be set. must be set.
- This cannot be used for internal load balancing.
required: false required: false
max_rate: max_rate:
description: description:
@ -124,7 +123,6 @@ options:
- Can be used with either RATE or UTILIZATION balancing modes, but required - Can be used with either RATE or UTILIZATION balancing modes, but required
if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be
set. set.
- This cannot be used for internal load balancing.
required: false required: false
max_rate_per_instance: max_rate_per_instance:
description: description:
@ -132,14 +130,13 @@ options:
This is used to calculate the capacity of the group. Can be used in either This is used to calculate the capacity of the group. Can be used in either
balancing mode. For RATE mode, either maxRate or maxRatePerInstance must balancing mode. For RATE mode, either maxRate or maxRatePerInstance must
be set. be set.
- This cannot be used for internal load balancing.
required: false required: false
max_utilization: max_utilization:
description: description:
- Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
target for the group. The default is 0.8. Valid range is [0.0, 1.0]. target for the group. The default is 0.8. Valid range is [0.0, 1.0].
- This cannot be used for internal load balancing.
required: false required: false
default: '0.8'
cdn_policy: cdn_policy:
description: description:
- Cloud CDN configuration for this BackendService. - Cloud CDN configuration for this BackendService.
@ -182,9 +179,21 @@ options:
or query_string_blacklist, not both. or query_string_blacklist, not both.
- "'&' and '=' will be percent encoded and not treated as delimiters." - "'&' and '=' will be percent encoded and not treated as delimiters."
required: false required: false
signed_url_cache_max_age_sec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh, defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header.
The actual headers served in responses will not be altered.'
required: false
default: '3600'
version_added: 2.8
connection_draining: connection_draining:
description: description:
- Settings for connection draining. - Settings for connection draining .
required: false required: false
suboptions: suboptions:
draining_timeout_sec: draining_timeout_sec:
@ -192,6 +201,7 @@ options:
- Time for which instance will be drained (not accept new connections, but - Time for which instance will be drained (not accept new connections, but
still work to finish started). still work to finish started).
required: false required: false
default: '300'
description: description:
description: description:
- An optional description of this resource. - An optional description of this resource.
@ -199,7 +209,6 @@ options:
enable_cdn: enable_cdn:
description: description:
- If true, enable Cloud CDN for this BackendService. - If true, enable Cloud CDN for this BackendService.
- When the load balancing scheme is INTERNAL, this field is not used.
required: false required: false
type: bool type: bool
health_checks: health_checks:
@ -207,9 +216,7 @@ options:
- The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health
checking this BackendService. Currently at most one health check can be specified, checking this BackendService. Currently at most one health check can be specified,
and a health check is required. and a health check is required.
- For internal load balancing, a URL to a HealthCheck resource must be specified required: true
instead.
required: false
iap: iap:
description: description:
- Settings for enabling Cloud Identity Aware Proxy. - Settings for enabling Cloud Identity Aware Proxy.
@ -223,25 +230,22 @@ options:
type: bool type: bool
oauth2_client_id: oauth2_client_id:
description: description:
- OAuth2 Client ID for IAP. - OAuth2 Client ID for IAP .
required: false required: true
oauth2_client_secret: oauth2_client_secret:
description: description:
- OAuth2 Client Secret for IAP. - OAuth2 Client Secret for IAP .
required: false required: true
oauth2_client_secret_sha256:
description:
- OAuth2 Client Secret SHA-256 for IAP.
required: false
load_balancing_scheme: load_balancing_scheme:
description: description:
- Indicates whether the backend service will be used with internal or external - Indicates whether the backend service will be used with internal or external
load balancing. A backend service created for one type of load balancing cannot load balancing. A backend service created for one type of load balancing cannot
be used with the other. be used with the other. Must be `EXTERNAL` for a global backend service. Defaults
to `EXTERNAL`.
required: false required: false
default: EXTERNAL
version_added: 2.7 version_added: 2.7
choices: choices:
- INTERNAL
- EXTERNAL - EXTERNAL
name: name:
description: description:
@ -251,44 +255,40 @@ options:
which means the first character must be a lowercase letter, and all following which means the first character must be a lowercase letter, and all following
characters must be a dash, lowercase letter, or digit, except the last character, characters must be a dash, lowercase letter, or digit, except the last character,
which cannot be a dash. which cannot be a dash.
required: false required: true
port_name: port_name:
description: description:
- Name of backend port. The same name should appear in the instance groups referenced - Name of backend port. The same name should appear in the instance groups referenced
by this service. Required when the load balancing scheme is EXTERNAL. by this service. Required when the load balancing scheme is EXTERNAL.
- When the load balancing scheme is INTERNAL, this field is not used.
required: false required: false
protocol: protocol:
description: description:
- The protocol this BackendService uses to communicate with backends. - The protocol this BackendService uses to communicate with backends.
- Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. - 'Possible values are HTTP, HTTPS, HTTP2, TCP, and SSL. The default is HTTP.
- For internal load balancing, the possible values are TCP and UDP, and the default **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may result
is TCP. in errors if used with the GA API.'
required: false required: false
choices: choices:
- HTTP - HTTP
- HTTPS - HTTPS
- HTTP2
- TCP - TCP
- SSL - SSL
region: security_policy:
description: description:
- The region where the regional backend service resides. - The security policy associated with this backend service.
- This field is not applicable to global backend services.
required: false required: false
version_added: 2.8
session_affinity: session_affinity:
description: description:
- Type of session affinity to use. The default is NONE. - Type of session affinity to use. The default is NONE.
- When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE.
- When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO,
or CLIENT_IP_PORT_PROTO.
- When the protocol is UDP, this field is not used. - When the protocol is UDP, this field is not used.
required: false required: false
choices: choices:
- NONE - NONE
- CLIENT_IP - CLIENT_IP
- GENERATED_COOKIE - GENERATED_COOKIE
- CLIENT_IP_PROTO
- CLIENT_IP_PORT_PROTO
timeout_sec: timeout_sec:
description: description:
- How many seconds to wait for the backend before considering it a failed request. - How many seconds to wait for the backend before considering it a failed request.
@ -297,30 +297,33 @@ options:
aliases: aliases:
- timeout_seconds - timeout_seconds
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/backendServices)'
- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-service)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: "instancegroup-backendservice" name: instancegroup-backendservice
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancegroup register: instancegroup
- name: create a http health check - name: create a http health check
gcp_compute_http_health_check: gcp_compute_http_health_check:
name: "httphealthcheck-backendservice" name: httphealthcheck-backendservice
healthy_threshold: 10 healthy_threshold: 10
port: 8080 port: 8080
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: healthcheck register: healthcheck
- name: create a backend service - name: create a backend service
@ -357,7 +360,6 @@ backends:
- Specifies the balancing mode for this backend. - Specifies the balancing mode for this backend.
- For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION. - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION.
Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL).
- This cannot be used for internal load balancing.
returned: success returned: success
type: str type: str
capacityScaler: capacityScaler:
@ -367,7 +369,6 @@ backends:
- Default value is 1, which means the group will serve up to 100% of its configured - Default value is 1, which means the group will serve up to 100% of its configured
capacity (depending on balancingMode). A setting of 0 means the group is completely capacity (depending on balancingMode). A setting of 0 means the group is completely
drained, offering 0% of its available Capacity. Valid range is [0.0,1.0]. drained, offering 0% of its available Capacity. Valid range is [0.0,1.0].
- This cannot be used for internal load balancing.
returned: success returned: success
type: str type: str
description: description:
@ -378,13 +379,18 @@ backends:
type: str type: str
group: group:
description: description:
- This instance group defines the list of instances that serve traffic. Member - The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
virtual machine instances from each instance group must live in the same zone In case of instance group this defines the list of instances that serve traffic.
as the instance group itself. Member virtual machine instances from each instance group must live in the
- No two backends in a backend service are allowed to use same Instance Group same zone as the instance group itself. No two backends in a backend service
resource. are allowed to use same Instance Group resource.
- When the BackendService has load balancing scheme INTERNAL, the instance group - For Network Endpoint Groups this defines list of endpoints. All endpoints
must be in a zone within the same region as the BackendService. of Network Endpoint Group must be hosted on instances located in the same
zone as the Network Endpoint Group.
- Backend service can not contain mix of Instance Group and Network Endpoint
Group backends.
- Note that you must specify an Instance Group or Network Endpoint Group resource
using the fully-qualified URL, rather than a partial URL.
returned: success returned: success
type: str type: str
maxConnections: maxConnections:
@ -393,7 +399,6 @@ backends:
either CONNECTION or UTILIZATION balancing modes. either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must
be set. be set.
- This cannot be used for internal load balancing.
returned: success returned: success
type: int type: int
maxConnectionsPerInstance: maxConnectionsPerInstance:
@ -403,7 +408,6 @@ backends:
in either CONNECTION or UTILIZATION balancing modes. in either CONNECTION or UTILIZATION balancing modes.
- For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must
be set. be set.
- This cannot be used for internal load balancing.
returned: success returned: success
type: int type: int
maxRate: maxRate:
@ -412,7 +416,6 @@ backends:
- Can be used with either RATE or UTILIZATION balancing modes, but required - Can be used with either RATE or UTILIZATION balancing modes, but required
if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be if RATE mode. For RATE mode, either maxRate or maxRatePerInstance must be
set. set.
- This cannot be used for internal load balancing.
returned: success returned: success
type: int type: int
maxRatePerInstance: maxRatePerInstance:
@ -421,14 +424,12 @@ backends:
This is used to calculate the capacity of the group. Can be used in either This is used to calculate the capacity of the group. Can be used in either
balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be
set. set.
- This cannot be used for internal load balancing.
returned: success returned: success
type: str type: str
maxUtilization: maxUtilization:
description: description:
- Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
target for the group. The default is 0.8. Valid range is [0.0, 1.0]. target for the group. The default is 0.8. Valid range is [0.0, 1.0].
- This cannot be used for internal load balancing.
returned: success returned: success
type: str type: str
cdnPolicy: cdnPolicy:
@ -477,9 +478,20 @@ cdnPolicy:
- "'&' and '=' will be percent encoded and not treated as delimiters." - "'&' and '=' will be percent encoded and not treated as delimiters."
returned: success returned: success
type: list type: list
signedUrlCacheMaxAgeSec:
description:
- Maximum number of seconds the response to a signed URL request will be considered
fresh, defaults to 1hr (3600s). After this time period, the response will
be revalidated before being served.
- 'When serving responses to signed URL requests, Cloud CDN will internally
behave as though all responses from this backend had a "Cache-Control: public,
max-age=[TTL]" header, regardless of any existing Cache-Control header. The
actual headers served in responses will not be altered.'
returned: success
type: int
connectionDraining: connectionDraining:
description: description:
- Settings for connection draining. - Settings for connection draining .
returned: success returned: success
type: complex type: complex
contains: contains:
@ -494,6 +506,12 @@ creationTimestamp:
- Creation timestamp in RFC3339 text format. - Creation timestamp in RFC3339 text format.
returned: success returned: success
type: str type: str
fingerprint:
description:
- Fingerprint of this resource. A hash of the contents stored in this object. This
field is used in optimistic locking.
returned: success
type: str
description: description:
description: description:
- An optional description of this resource. - An optional description of this resource.
@ -502,7 +520,6 @@ description:
enableCDN: enableCDN:
description: description:
- If true, enable Cloud CDN for this BackendService. - If true, enable Cloud CDN for this BackendService.
- When the load balancing scheme is INTERNAL, this field is not used.
returned: success returned: success
type: bool type: bool
healthChecks: healthChecks:
@ -510,8 +527,6 @@ healthChecks:
- The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health - The list of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health
checking this BackendService. Currently at most one health check can be specified, checking this BackendService. Currently at most one health check can be specified,
and a health check is required. and a health check is required.
- For internal load balancing, a URL to a HealthCheck resource must be specified
instead.
returned: success returned: success
type: list type: list
id: id:
@ -532,24 +547,25 @@ iap:
type: bool type: bool
oauth2ClientId: oauth2ClientId:
description: description:
- OAuth2 Client ID for IAP. - OAuth2 Client ID for IAP .
returned: success returned: success
type: str type: str
oauth2ClientSecret: oauth2ClientSecret:
description: description:
- OAuth2 Client Secret for IAP. - OAuth2 Client Secret for IAP .
returned: success returned: success
type: str type: str
oauth2ClientSecretSha256: oauth2ClientSecretSha256:
description: description:
- OAuth2 Client Secret SHA-256 for IAP. - OAuth2 Client Secret SHA-256 for IAP .
returned: success returned: success
type: str type: str
loadBalancingScheme: loadBalancingScheme:
description: description:
- Indicates whether the backend service will be used with internal or external load - Indicates whether the backend service will be used with internal or external load
balancing. A backend service created for one type of load balancing cannot be balancing. A backend service created for one type of load balancing cannot be
used with the other. used with the other. Must be `EXTERNAL` for a global backend service. Defaults
to `EXTERNAL`.
returned: success returned: success
type: str type: str
name: name:
@ -566,29 +582,25 @@ portName:
description: description:
- Name of backend port. The same name should appear in the instance groups referenced - Name of backend port. The same name should appear in the instance groups referenced
by this service. Required when the load balancing scheme is EXTERNAL. by this service. Required when the load balancing scheme is EXTERNAL.
- When the load balancing scheme is INTERNAL, this field is not used.
returned: success returned: success
type: str type: str
protocol: protocol:
description: description:
- The protocol this BackendService uses to communicate with backends. - The protocol this BackendService uses to communicate with backends.
- Possible values are HTTP, HTTPS, TCP, and SSL. The default is HTTP. - 'Possible values are HTTP, HTTPS, HTTP2, TCP, and SSL. The default is HTTP. **NOTE**:
- For internal load balancing, the possible values are TCP and UDP, and the default HTTP2 is only valid for beta HTTP/2 load balancer types and may result in errors
is TCP. if used with the GA API.'
returned: success returned: success
type: str type: str
region: securityPolicy:
description: description:
- The region where the regional backend service resides. - The security policy associated with this backend service.
- This field is not applicable to global backend services.
returned: success returned: success
type: str type: str
sessionAffinity: sessionAffinity:
description: description:
- Type of session affinity to use. The default is NONE. - Type of session affinity to use. The default is NONE.
- When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE. - When the load balancing scheme is EXTERNAL, can be NONE, CLIENT_IP, or GENERATED_COOKIE.
- When the load balancing scheme is INTERNAL, can be NONE, CLIENT_IP, CLIENT_IP_PROTO,
or CLIENT_IP_PORT_PROTO.
- When the protocol is UDP, this field is not used. - When the protocol is UDP, this field is not used.
returned: success returned: success
type: str type: str
@ -606,7 +618,6 @@ timeoutSec:
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, 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 json
import re
import time import time
################################################################################ ################################################################################
@ -625,15 +636,15 @@ def main():
type='list', type='list',
elements='dict', elements='dict',
options=dict( options=dict(
balancing_mode=dict(type='str', choices=['UTILIZATION', 'RATE', 'CONNECTION']), balancing_mode=dict(default='UTILIZATION', type='str', choices=['UTILIZATION', 'RATE', 'CONNECTION']),
capacity_scaler=dict(type='str'), capacity_scaler=dict(default=1.0, type='str'),
description=dict(type='str'), description=dict(type='str'),
group=dict(), group=dict(type='str'),
max_connections=dict(type='int'), max_connections=dict(type='int'),
max_connections_per_instance=dict(type='int'), max_connections_per_instance=dict(type='int'),
max_rate=dict(type='int'), max_rate=dict(type='int'),
max_rate_per_instance=dict(type='str'), max_rate_per_instance=dict(type='str'),
max_utilization=dict(type='str'), max_utilization=dict(default=0.8, type='str'),
), ),
), ),
cdn_policy=dict( cdn_policy=dict(
@ -648,28 +659,24 @@ def main():
query_string_blacklist=dict(type='list', elements='str'), query_string_blacklist=dict(type='list', elements='str'),
query_string_whitelist=dict(type='list', elements='str'), query_string_whitelist=dict(type='list', elements='str'),
), ),
) ),
signed_url_cache_max_age_sec=dict(default=3600, type='int'),
), ),
), ),
connection_draining=dict(type='dict', options=dict(draining_timeout_sec=dict(type='int'))), connection_draining=dict(type='dict', options=dict(draining_timeout_sec=dict(default=300, type='int'))),
description=dict(type='str'), description=dict(type='str'),
enable_cdn=dict(type='bool'), enable_cdn=dict(type='bool'),
health_checks=dict(type='list', elements='str'), health_checks=dict(required=True, type='list', elements='str'),
iap=dict( iap=dict(
type='dict', type='dict',
options=dict( options=dict(enabled=dict(type='bool'), oauth2_client_id=dict(required=True, type='str'), oauth2_client_secret=dict(required=True, type='str')),
enabled=dict(type='bool'),
oauth2_client_id=dict(type='str'),
oauth2_client_secret=dict(type='str'),
oauth2_client_secret_sha256=dict(type='str'),
),
), ),
load_balancing_scheme=dict(type='str', choices=['INTERNAL', 'EXTERNAL']), load_balancing_scheme=dict(default='EXTERNAL', type='str', choices=['EXTERNAL']),
name=dict(type='str'), name=dict(required=True, type='str'),
port_name=dict(type='str'), port_name=dict(type='str'),
protocol=dict(type='str', choices=['HTTP', 'HTTPS', 'TCP', 'SSL']), protocol=dict(type='str', choices=['HTTP', 'HTTPS', 'HTTP2', 'TCP', 'SSL']),
region=dict(type='str'), security_policy=dict(type='str'),
session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'GENERATED_COOKIE', 'CLIENT_IP_PROTO', 'CLIENT_IP_PORT_PROTO']), session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'GENERATED_COOKIE']),
timeout_sec=dict(type='int', aliases=['timeout_seconds']), timeout_sec=dict(type='int', aliases=['timeout_seconds']),
) )
) )
@ -686,7 +693,7 @@ def main():
if fetch: if fetch:
if state == 'present': if state == 'present':
if is_different(module, fetch): if is_different(module, fetch):
update(module, self_link(module), kind) update(module, self_link(module), kind, fetch)
fetch = fetch_resource(module, self_link(module), kind) fetch = fetch_resource(module, self_link(module), kind)
changed = True changed = True
else: else:
@ -710,11 +717,25 @@ def create(module, link, kind):
return wait_for_operation(module, auth.post(link, resource_to_request(module))) return wait_for_operation(module, auth.post(link, resource_to_request(module)))
def update(module, link, kind): def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
auth = GcpSession(module, 'compute') auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.put(link, resource_to_request(module))) return wait_for_operation(module, auth.put(link, resource_to_request(module)))
def update_fields(module, request, response):
if response.get('securityPolicy') != request.get('securityPolicy'):
security_policy_update(module, request, response)
def security_policy_update(module, request, response):
auth = GcpSession(module, 'compute')
auth.post(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/backendServices/{name}/setSecurityPolicy"]).format(**module.params),
{u'securityPolicy': module.params.get('security_policy')},
)
def delete(module, link, kind): def delete(module, link, kind):
auth = GcpSession(module, 'compute') auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.delete(link)) return wait_for_operation(module, auth.delete(link))
@ -735,7 +756,7 @@ def resource_to_request(module):
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'portName': module.params.get('port_name'), u'portName': module.params.get('port_name'),
u'protocol': module.params.get('protocol'), u'protocol': module.params.get('protocol'),
u'region': region_selflink(module.params.get('region'), module.params), u'securityPolicy': module.params.get('security_policy'),
u'sessionAffinity': module.params.get('session_affinity'), u'sessionAffinity': module.params.get('session_affinity'),
u'timeoutSec': module.params.get('timeout_sec'), u'timeoutSec': module.params.get('timeout_sec'),
} }
@ -808,30 +829,22 @@ def response_to_hash(module, response):
u'cdnPolicy': BackendServiceCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(), u'cdnPolicy': BackendServiceCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(),
u'connectionDraining': BackendServiceConnectiondraining(response.get(u'connectionDraining', {}), module).from_response(), u'connectionDraining': BackendServiceConnectiondraining(response.get(u'connectionDraining', {}), module).from_response(),
u'creationTimestamp': response.get(u'creationTimestamp'), u'creationTimestamp': response.get(u'creationTimestamp'),
u'fingerprint': response.get(u'fingerprint'),
u'description': response.get(u'description'), u'description': response.get(u'description'),
u'enableCDN': response.get(u'enableCDN'), u'enableCDN': response.get(u'enableCDN'),
u'healthChecks': response.get(u'healthChecks'), u'healthChecks': response.get(u'healthChecks'),
u'id': response.get(u'id'), u'id': response.get(u'id'),
u'iap': BackendServiceIap(response.get(u'iap', {}), module).from_response(), u'iap': BackendServiceIap(response.get(u'iap', {}), module).from_response(),
u'loadBalancingScheme': response.get(u'loadBalancingScheme'), u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
u'name': response.get(u'name'), u'name': module.params.get('name'),
u'portName': response.get(u'portName'), u'portName': response.get(u'portName'),
u'protocol': response.get(u'protocol'), u'protocol': response.get(u'protocol'),
u'region': response.get(u'region'), u'securityPolicy': response.get(u'securityPolicy'),
u'sessionAffinity': response.get(u'sessionAffinity'), u'sessionAffinity': response.get(u'sessionAffinity'),
u'timeoutSec': response.get(u'timeoutSec'), u'timeoutSec': response.get(u'timeoutSec'),
} }
def region_selflink(name, params):
if name is None:
return
url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/[a-z1-9\-]*"
if not re.match(url, name):
name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name
return name
def async_op_url(module, extra_data=None): def async_op_url(module, extra_data=None):
if extra_data is None: if extra_data is None:
extra_data = {} extra_data = {}
@ -893,7 +906,7 @@ class BackendServiceBackendsArray(object):
u'balancingMode': item.get('balancing_mode'), u'balancingMode': item.get('balancing_mode'),
u'capacityScaler': item.get('capacity_scaler'), u'capacityScaler': item.get('capacity_scaler'),
u'description': item.get('description'), u'description': item.get('description'),
u'group': replace_resource_dict(item.get(u'group', {}), 'selfLink'), u'group': item.get('group'),
u'maxConnections': item.get('max_connections'), u'maxConnections': item.get('max_connections'),
u'maxConnectionsPerInstance': item.get('max_connections_per_instance'), u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
u'maxRate': item.get('max_rate'), u'maxRate': item.get('max_rate'),
@ -927,10 +940,20 @@ class BackendServiceCdnpolicy(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request()}) return remove_nones_from_dict(
{
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request(),
u'signedUrlCacheMaxAgeSec': self.request.get('signed_url_cache_max_age_sec'),
}
)
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response()}) return remove_nones_from_dict(
{
u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response(),
u'signedUrlCacheMaxAgeSec': self.request.get(u'signedUrlCacheMaxAgeSec'),
}
)
class BackendServiceCachekeypolicy(object): class BackendServiceCachekeypolicy(object):
@ -993,7 +1016,6 @@ class BackendServiceIap(object):
u'enabled': self.request.get('enabled'), u'enabled': self.request.get('enabled'),
u'oauth2ClientId': self.request.get('oauth2_client_id'), u'oauth2ClientId': self.request.get('oauth2_client_id'),
u'oauth2ClientSecret': self.request.get('oauth2_client_secret'), u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
u'oauth2ClientSecretSha256': self.request.get('oauth2_client_secret_sha256'),
} }
) )
@ -1003,7 +1025,6 @@ class BackendServiceIap(object):
u'enabled': self.request.get(u'enabled'), u'enabled': self.request.get(u'enabled'),
u'oauth2ClientId': self.request.get(u'oauth2ClientId'), u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'), u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
u'oauth2ClientSecretSha256': self.request.get(u'oauth2ClientSecretSha256'),
} }
) )

View file

@ -51,12 +51,11 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: " a backend service facts" - name: " a backend service facts"
gcp_compute_backend_service_facts: gcp_compute_backend_service_facts:
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -192,15 +192,15 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a disk - name: create a disk
gcp_compute_disk: gcp_compute_disk:
name: test_object name: "test_object"
size_gb: 50 size_gb: 50
disk_encryption_key: disk_encryption_key:
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
zone: us-central1-a zone: us-central1-a
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -55,13 +55,12 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: " a disk facts" - name: " a disk facts"
gcp_compute_disk_facts: gcp_compute_disk_facts:
zone: us-central1-a zone: us-central1-a
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -326,20 +326,20 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a firewall - name: create a firewall
gcp_compute_firewall: gcp_compute_firewall:
name: test_object name: "test_object"
allowed: allowed:
- ip_protocol: tcp - ip_protocol: tcp
ports: ports:
- '22' - '22'
target_tags: target_tags:
- test-ssh-server - test-ssh-server
- staging-ssh-server - staging-ssh-server
source_tags: source_tags:
- test-ssh-clients - test-ssh-clients
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -51,12 +51,11 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: " a firewall facts" - name: " a firewall facts"
gcp_compute_firewall_facts: gcp_compute_firewall_facts:
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -250,16 +250,16 @@ EXAMPLES = '''
- name: create a forwarding rule - name: create a forwarding rule
gcp_compute_forwarding_rule: gcp_compute_forwarding_rule:
name: test_object name: "test_object"
region: us-west1 region: us-west1
target: "{{ targetpool }}" target: "{{ targetpool }}"
ip_protocol: TCP ip_protocol: TCP
port_range: 80-80 port_range: 80-80
ip_address: "{{ address.address }}" ip_address: "{{ address.address }}"
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -56,13 +56,12 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: " a forwarding rule facts" - name: " a forwarding rule facts"
gcp_compute_forwarding_rule_facts: gcp_compute_forwarding_rule_facts:
region: us-west1 region: us-west1
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -94,11 +94,11 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a global address - name: create a global address
gcp_compute_global_address: gcp_compute_global_address:
name: test_object name: "test_object"
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -51,12 +51,11 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: " a global address facts" - name: " a global address facts"
gcp_compute_global_address_facts: gcp_compute_global_address_facts:
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -81,8 +81,8 @@ options:
ip_protocol: ip_protocol:
description: description:
- The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP,
AH, SCTP or ICMP. AH, SCTP or ICMP. When the load balancing scheme is INTERNAL_SELF_MANAGED, only
- When the load balancing scheme is INTERNAL, only TCP and UDP are valid. TCP is valid.
required: false required: false
choices: choices:
- TCP - TCP
@ -91,35 +91,24 @@ options:
- AH - AH
- SCTP - SCTP
- ICMP - ICMP
backend_service:
description:
- A reference to a BackendService to receive the matched traffic.
- This is used for internal load balancing.
- "(not used for external load balancing) ."
- 'This field represents a link to a BackendService resource in GCP. It can be
specified in two ways. First, you can place in the selfLink of the resource
here as a string Alternatively, you can add `register: name-of-resource` to
a gcp_compute_backend_service task and then set this backend_service field to
"{{ name-of-resource }}"'
required: false
ip_version: ip_version:
description: description:
- The IP Version that will be used by this forwarding rule. Valid options are - The IP Version that will be used by this global forwarding rule.
IPV4 or IPV6. This can only be specified for a global forwarding rule. - Valid options are IPV4 or IPV6.
required: false required: false
choices: choices:
- IPV4 - IPV4
- IPV6 - IPV6
load_balancing_scheme: load_balancing_scheme:
description: description:
- 'This signifies what the ForwardingRule will be used for and can only take the - This signifies what the GlobalForwardingRule will be used for.
following values: INTERNAL, EXTERNAL The value of INTERNAL means that this will - 'The value of INTERNAL_SELF_MANAGED means that this will be used for Internal
be used for Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL Global HTTP(S) LB. The value of EXTERNAL means that this will be used for External
means that this will be used for External Load Balancing (HTTP(S) LB, External Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) NOTE: Currently
TCP/UDP LB, SSL Proxy) .' global forwarding rules cannot be used for INTERNAL load balancing.'
required: false required: false
choices: choices:
- INTERNAL - INTERNAL_SELF_MANAGED
- EXTERNAL - EXTERNAL
name: name:
description: description:
@ -132,14 +121,15 @@ options:
required: true required: true
network: network:
description: description:
- For internal load balancing, this field identifies the network that the load
balanced IP should belong to for this Forwarding Rule. If this field is not
specified, the default network will be used.
- This field is not used for external load balancing. - This field is not used for external load balancing.
- For INTERNAL_SELF_MANAGED load balancing, this field identifies the network
that the load balanced IP should belong to for this global forwarding rule.
If this field is not specified, the default network will be used.
- 'This field represents a link to a Network resource in GCP. It can be specified - 'This field represents a link to a Network resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_network of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this network field to "{{ name-of-resource }}"' to a gcp_compute_network task and then set this network field to "{{ name-of-resource
}}"'
required: false required: false
port_range: port_range:
description: description:
@ -155,101 +145,79 @@ options:
43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
500, 4500 .' 500, 4500 .'
required: false required: false
ports:
description:
- This field is used along with the backend_service field for internal load balancing.
- When the load balancing scheme is INTERNAL, a single port or a comma separated
list of ports can be configured. Only packets addressed to these ports will
be forwarded to the backends configured with this forwarding rule.
- You may specify a maximum of up to 5 ports.
required: false
subnetwork:
description:
- A reference to a subnetwork.
- For internal load balancing, this field identifies the subnetwork that the load
balanced IP should belong to for this Forwarding Rule.
- If the network specified is in auto subnet mode, this field is optional. However,
if the network is in custom subnet mode, a subnetwork must be specified.
- This field is not used for external load balancing.
- 'This field represents a link to a Subnetwork resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_subnetwork
task and then set this subnetwork field to "{{ name-of-resource }}"'
required: false
target: target:
description: description:
- This target must be a global load balancing resource. The forwarded traffic - The URL of the target resource to receive the matched traffic.
must be of a type appropriate to the target object. - The forwarded traffic must be of a type appropriate to the target object.
- 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .' required: true
required: false
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a global address - name: create a global address
gcp_compute_global_address: gcp_compute_global_address:
name: "globaladdress-globalforwardingrule" name: globaladdress-globalforwardingrule
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: globaladdress register: globaladdress
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: "instancegroup-globalforwardingrule" name: instancegroup-globalforwardingrule
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancegroup register: instancegroup
- name: create a http health check - name: create a http health check
gcp_compute_http_health_check: gcp_compute_http_health_check:
name: "httphealthcheck-globalforwardingrule" name: httphealthcheck-globalforwardingrule
healthy_threshold: 10 healthy_threshold: 10
port: 8080 port: 8080
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: healthcheck register: healthcheck
- name: create a backend service - name: create a backend service
gcp_compute_backend_service: gcp_compute_backend_service:
name: "backendservice-globalforwardingrule" name: backendservice-globalforwardingrule
backends: backends:
- group: "{{ instancegroup }}" - group: "{{ instancegroup }}"
health_checks: health_checks:
- "{{ healthcheck.selfLink }}" - "{{ healthcheck.selfLink }}"
enable_cdn: true enable_cdn: 'true'
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: backendservice register: backendservice
- name: create a url map - name: create a url map
gcp_compute_url_map: gcp_compute_url_map:
name: "urlmap-globalforwardingrule" name: urlmap-globalforwardingrule
default_service: "{{ backendservice }}" default_service: "{{ backendservice }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: urlmap register: urlmap
- name: create a target http proxy - name: create a target http proxy
gcp_compute_target_http_proxy: gcp_compute_target_http_proxy:
name: "targethttpproxy-globalforwardingrule" name: targethttpproxy-globalforwardingrule
url_map: "{{ urlmap }}" url_map: "{{ urlmap }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: httpproxy register: httpproxy
- name: create a global forwarding rule - name: create a global forwarding rule
@ -308,30 +276,23 @@ IPAddress:
IPProtocol: IPProtocol:
description: description:
- The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH, - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH,
SCTP or ICMP. SCTP or ICMP. When the load balancing scheme is INTERNAL_SELF_MANAGED, only TCP
- When the load balancing scheme is INTERNAL, only TCP and UDP are valid. is valid.
returned: success
type: str
backendService:
description:
- A reference to a BackendService to receive the matched traffic.
- This is used for internal load balancing.
- "(not used for external load balancing) ."
returned: success returned: success
type: str type: str
ipVersion: ipVersion:
description: description:
- The IP Version that will be used by this forwarding rule. Valid options are IPV4 - The IP Version that will be used by this global forwarding rule.
or IPV6. This can only be specified for a global forwarding rule. - Valid options are IPV4 or IPV6.
returned: success returned: success
type: str type: str
loadBalancingScheme: loadBalancingScheme:
description: description:
- 'This signifies what the ForwardingRule will be used for and can only take the - This signifies what the GlobalForwardingRule will be used for.
following values: INTERNAL, EXTERNAL The value of INTERNAL means that this will - 'The value of INTERNAL_SELF_MANAGED means that this will be used for Internal
be used for Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL Global HTTP(S) LB. The value of EXTERNAL means that this will be used for External
means that this will be used for External Load Balancing (HTTP(S) LB, External Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) NOTE: Currently
TCP/UDP LB, SSL Proxy) .' global forwarding rules cannot be used for INTERNAL load balancing.'
returned: success returned: success
type: str type: str
name: name:
@ -346,12 +307,12 @@ name:
type: str type: str
network: network:
description: description:
- For internal load balancing, this field identifies the network that the load balanced
IP should belong to for this Forwarding Rule. If this field is not specified,
the default network will be used.
- This field is not used for external load balancing. - This field is not used for external load balancing.
- For INTERNAL_SELF_MANAGED load balancing, this field identifies the network that
the load balanced IP should belong to for this global forwarding rule. If this
field is not specified, the default network will be used.
returned: success returned: success
type: str type: dict
portRange: portRange:
description: description:
- This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
@ -366,36 +327,10 @@ portRange:
465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500 .' 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500 .'
returned: success returned: success
type: str type: str
ports:
description:
- This field is used along with the backend_service field for internal load balancing.
- When the load balancing scheme is INTERNAL, a single port or a comma separated
list of ports can be configured. Only packets addressed to these ports will be
forwarded to the backends configured with this forwarding rule.
- You may specify a maximum of up to 5 ports.
returned: success
type: list
subnetwork:
description:
- A reference to a subnetwork.
- For internal load balancing, this field identifies the subnetwork that the load
balanced IP should belong to for this Forwarding Rule.
- If the network specified is in auto subnet mode, this field is optional. However,
if the network is in custom subnet mode, a subnetwork must be specified.
- This field is not used for external load balancing.
returned: success
type: str
region:
description:
- A reference to the region where the regional forwarding rule resides.
- This field is not applicable to global forwarding rules.
returned: success
type: str
target: target:
description: description:
- This target must be a global load balancing resource. The forwarded traffic must - The URL of the target resource to receive the matched traffic.
be of a type appropriate to the target object. - The forwarded traffic must be of a type appropriate to the target object.
- 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .'
returned: success returned: success
type: str type: str
''' '''
@ -422,15 +357,12 @@ def main():
description=dict(type='str'), description=dict(type='str'),
ip_address=dict(type='str'), ip_address=dict(type='str'),
ip_protocol=dict(type='str', choices=['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP']), ip_protocol=dict(type='str', choices=['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP']),
backend_service=dict(),
ip_version=dict(type='str', choices=['IPV4', 'IPV6']), ip_version=dict(type='str', choices=['IPV4', 'IPV6']),
load_balancing_scheme=dict(type='str', choices=['INTERNAL', 'EXTERNAL']), load_balancing_scheme=dict(type='str', choices=['INTERNAL_SELF_MANAGED', 'EXTERNAL']),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
network=dict(), network=dict(type='dict'),
port_range=dict(type='str'), port_range=dict(type='str'),
ports=dict(type='list', elements='str'), target=dict(required=True, type='str'),
subnetwork=dict(),
target=dict(type='str'),
) )
) )
@ -446,7 +378,7 @@ def main():
if fetch: if fetch:
if state == 'present': if state == 'present':
if is_different(module, fetch): if is_different(module, fetch):
update(module, self_link(module), kind) update(module, self_link(module), kind, fetch)
fetch = fetch_resource(module, self_link(module), kind) fetch = fetch_resource(module, self_link(module), kind)
changed = True changed = True
else: else:
@ -470,9 +402,22 @@ def create(module, link, kind):
return wait_for_operation(module, auth.post(link, resource_to_request(module))) return wait_for_operation(module, auth.post(link, resource_to_request(module)))
def update(module, link, kind): def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
return fetch_resource(module, self_link(module), kind)
def update_fields(module, request, response):
if response.get('target') != request.get('target'):
target_update(module, request, response)
def target_update(module, request, response):
auth = GcpSession(module, 'compute') auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.put(link, resource_to_request(module))) auth.post(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/forwardingRules/{name}/setTarget"]).format(**module.params),
{u'target': module.params.get('target')},
)
def delete(module, link, kind): def delete(module, link, kind):
@ -486,14 +431,11 @@ def resource_to_request(module):
u'description': module.params.get('description'), u'description': module.params.get('description'),
u'IPAddress': module.params.get('ip_address'), u'IPAddress': module.params.get('ip_address'),
u'IPProtocol': module.params.get('ip_protocol'), u'IPProtocol': module.params.get('ip_protocol'),
u'backendService': replace_resource_dict(module.params.get(u'backend_service', {}), 'selfLink'),
u'ipVersion': module.params.get('ip_version'), u'ipVersion': module.params.get('ip_version'),
u'loadBalancingScheme': module.params.get('load_balancing_scheme'), u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'), u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
u'portRange': module.params.get('port_range'), u'portRange': module.params.get('port_range'),
u'ports': module.params.get('ports'),
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
u'target': module.params.get('target'), u'target': module.params.get('target'),
} }
return_vals = {} return_vals = {}
@ -565,15 +507,11 @@ def response_to_hash(module, response):
u'id': response.get(u'id'), u'id': response.get(u'id'),
u'IPAddress': response.get(u'IPAddress'), u'IPAddress': response.get(u'IPAddress'),
u'IPProtocol': response.get(u'IPProtocol'), u'IPProtocol': response.get(u'IPProtocol'),
u'backendService': response.get(u'backendService'),
u'ipVersion': response.get(u'ipVersion'), u'ipVersion': response.get(u'ipVersion'),
u'loadBalancingScheme': response.get(u'loadBalancingScheme'), u'loadBalancingScheme': response.get(u'loadBalancingScheme'),
u'name': response.get(u'name'), u'name': response.get(u'name'),
u'network': response.get(u'network'), u'network': response.get(u'network'),
u'portRange': response.get(u'portRange'), u'portRange': response.get(u'portRange'),
u'ports': response.get(u'ports'),
u'subnetwork': response.get(u'subnetwork'),
u'region': response.get(u'region'),
u'target': response.get(u'target'), u'target': response.get(u'target'),
} }

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a global forwarding rule facts - name: " a global forwarding rule facts"
gcp_compute_global_forwarding_rule_facts: gcp_compute_global_forwarding_rule_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -106,30 +106,23 @@ items:
IPProtocol: IPProtocol:
description: description:
- The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP,
AH, SCTP or ICMP. AH, SCTP or ICMP. When the load balancing scheme is INTERNAL_SELF_MANAGED,
- When the load balancing scheme is INTERNAL, only TCP and UDP are valid. only TCP is valid.
returned: success
type: str
backendService:
description:
- A reference to a BackendService to receive the matched traffic.
- This is used for internal load balancing.
- "(not used for external load balancing) ."
returned: success returned: success
type: str type: str
ipVersion: ipVersion:
description: description:
- The IP Version that will be used by this forwarding rule. Valid options are - The IP Version that will be used by this global forwarding rule.
IPV4 or IPV6. This can only be specified for a global forwarding rule. - Valid options are IPV4 or IPV6.
returned: success returned: success
type: str type: str
loadBalancingScheme: loadBalancingScheme:
description: description:
- 'This signifies what the ForwardingRule will be used for and can only take - This signifies what the GlobalForwardingRule will be used for.
the following values: INTERNAL, EXTERNAL The value of INTERNAL means that - 'The value of INTERNAL_SELF_MANAGED means that this will be used for Internal
this will be used for Internal Network Load Balancing (TCP, UDP). The value Global HTTP(S) LB. The value of EXTERNAL means that this will be used for
of EXTERNAL means that this will be used for External Load Balancing (HTTP(S) External Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy)
LB, External TCP/UDP LB, SSL Proxy) .' NOTE: Currently global forwarding rules cannot be used for INTERNAL load balancing.'
returned: success returned: success
type: str type: str
name: name:
@ -144,12 +137,12 @@ items:
type: str type: str
network: network:
description: description:
- For internal load balancing, this field identifies the network that the load
balanced IP should belong to for this Forwarding Rule. If this field is not
specified, the default network will be used.
- This field is not used for external load balancing. - This field is not used for external load balancing.
- For INTERNAL_SELF_MANAGED load balancing, this field identifies the network
that the load balanced IP should belong to for this global forwarding rule.
If this field is not specified, the default network will be used.
returned: success returned: success
type: str type: dict
portRange: portRange:
description: description:
- This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy, - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
@ -165,37 +158,10 @@ items:
500, 4500 .' 500, 4500 .'
returned: success returned: success
type: str type: str
ports:
description:
- This field is used along with the backend_service field for internal load
balancing.
- When the load balancing scheme is INTERNAL, a single port or a comma separated
list of ports can be configured. Only packets addressed to these ports will
be forwarded to the backends configured with this forwarding rule.
- You may specify a maximum of up to 5 ports.
returned: success
type: list
subnetwork:
description:
- A reference to a subnetwork.
- For internal load balancing, this field identifies the subnetwork that the
load balanced IP should belong to for this Forwarding Rule.
- If the network specified is in auto subnet mode, this field is optional. However,
if the network is in custom subnet mode, a subnetwork must be specified.
- This field is not used for external load balancing.
returned: success
type: str
region:
description:
- A reference to the region where the regional forwarding rule resides.
- This field is not applicable to global forwarding rules.
returned: success
type: str
target: target:
description: description:
- This target must be a global load balancing resource. The forwarded traffic - The URL of the target resource to receive the matched traffic.
must be of a type appropriate to the target object. - The forwarded traffic must be of a type appropriate to the target object.
- 'Valid types: HTTP_PROXY, HTTPS_PROXY, SSL_PROXY, TCP_PROXY .'
returned: success returned: success
type: str type: str
''' '''
@ -222,7 +188,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -309,7 +309,7 @@ EXAMPLES = '''
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "test_project" project: "test_project"
auth_kind: "service_account" auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
@ -403,26 +403,26 @@ RETURN = '''
- PROXY_V1 - PROXY_V1
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/latest/healthChecks)' - '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)' - 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/health-checks)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a health check - name: create a health check
gcp_compute_health_check: gcp_compute_health_check:
name: "test_object" name: test_object
type: TCP type: TCP
tcp_health_check: tcp_health_check:
port_name: service-health port_name: service-health
request: ping request: ping
response: pong response: pong
healthy_threshold: 10 healthy_threshold: 10
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a health check facts - name: " a health check facts"
gcp_compute_health_check_facts: gcp_compute_health_check_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -312,7 +312,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -105,7 +105,7 @@ options:
required: false required: false
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks)' - '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)' - 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)'
''' '''

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a http health check facts - name: " a http health check facts"
gcp_compute_http_health_check_facts: gcp_compute_http_health_check_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -158,7 +158,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -102,7 +102,7 @@ options:
required: false required: false
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpsHealthChecks)' - '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)' - 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)'
''' '''

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a https health check facts - name: " a https health check facts"
gcp_compute_https_health_check_facts: gcp_compute_https_health_check_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -158,7 +158,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -106,11 +106,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource. base64 to either encrypt or decrypt this resource.
required: false required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
labels: labels:
description: description:
- Labels to apply to this Image. - Labels to apply to this Image.
@ -158,9 +153,10 @@ options:
- You must provide either this property or the rawDisk.source property but not - You must provide either this property or the rawDisk.source property but not
both to create an image. both to create an image.
- 'This field represents a link to a Disk resource in GCP. It can be specified - 'This field represents a link to a Disk resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_disk of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this source_disk field to "{{ name-of-resource }}"' to a gcp_compute_disk task and then set this source_disk field to "{{ name-of-resource
}}"'
required: false required: false
source_disk_encryption_key: source_disk_encryption_key:
description: description:
@ -173,11 +169,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource. base64 to either encrypt or decrypt this resource.
required: false required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
source_disk_id: source_disk_id:
description: description:
- The ID value of the disk used to create this image. This value may be used to - The ID value of the disk used to create this image. This value may be used to
@ -193,19 +184,19 @@ options:
- RAW - RAW
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/images)' - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/images)'
- 'Official Documentation: U(https://cloud.google.com/compute/docs/images)' - 'Official Documentation: U(https://cloud.google.com/compute/docs/images)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a disk - name: create a disk
gcp_compute_disk: gcp_compute_disk:
name: "disk-image" name: disk-image
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: disk register: disk
- name: create a image - name: create a image
@ -394,7 +385,7 @@ sourceDisk:
- You must provide either this property or the rawDisk.source property but not both - You must provide either this property or the rawDisk.source property but not both
to create an image. to create an image.
returned: success returned: success
type: str type: dict
sourceDiskEncryptionKey: sourceDiskEncryptionKey:
description: description:
- The customer-supplied encryption key of the source disk. Required if the source - The customer-supplied encryption key of the source disk. Required if the source
@ -435,6 +426,7 @@ sourceType:
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, 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 json
import re
import time import time
################################################################################ ################################################################################
@ -452,7 +444,7 @@ def main():
disk_size_gb=dict(type='int'), disk_size_gb=dict(type='int'),
family=dict(type='str'), family=dict(type='str'),
guest_os_features=dict(type='list', elements='dict', options=dict(type=dict(type='str', choices=['VIRTIO_SCSI_MULTIQUEUE']))), guest_os_features=dict(type='list', elements='dict', options=dict(type=dict(type='str', choices=['VIRTIO_SCSI_MULTIQUEUE']))),
image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))), image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
labels=dict(type='dict'), labels=dict(type='dict'),
licenses=dict(type='list', elements='str'), licenses=dict(type='list', elements='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
@ -460,8 +452,8 @@ def main():
type='dict', type='dict',
options=dict(container_type=dict(type='str', choices=['TAR']), sha1_checksum=dict(type='str'), source=dict(required=True, type='str')), options=dict(container_type=dict(type='str', choices=['TAR']), sha1_checksum=dict(type='str'), source=dict(required=True, type='str')),
), ),
source_disk=dict(), source_disk=dict(type='dict'),
source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))), source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
source_disk_id=dict(type='str'), source_disk_id=dict(type='str'),
source_type=dict(type='str', choices=['RAW']), source_type=dict(type='str', choices=['RAW']),
) )
@ -628,6 +620,15 @@ def response_to_hash(module, response):
} }
def license_selflink(name, params):
if name is None:
return
url = r"https://www.googleapis.com/compute/v1//projects/.*/global/licenses/[a-z1-9\-]*"
if not re.match(url, name):
name = "https://www.googleapis.com/compute/v1//projects/{project}/global/licenses/%s".format(**params) % name
return name
def async_op_url(module, extra_data=None): def async_op_url(module, extra_data=None):
if extra_data is None: if extra_data is None:
extra_data = {} extra_data = {}
@ -730,10 +731,10 @@ class ImageImageencryptionkey(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
class ImageRawdisk(object): class ImageRawdisk(object):
@ -764,10 +765,10 @@ class ImageSourcediskencryptionkey(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a image facts - name: " a image facts"
gcp_compute_image_facts: gcp_compute_image_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -243,7 +243,7 @@ items:
- You must provide either this property or the rawDisk.source property but not - You must provide either this property or the rawDisk.source property but not
both to create an image. both to create an image.
returned: success returned: success
type: str type: dict
sourceDiskEncryptionKey: sourceDiskEncryptionKey:
description: description:
- The customer-supplied encryption key of the source disk. Required if the source - The customer-supplied encryption key of the source disk. Required if the source
@ -300,7 +300,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -54,6 +54,8 @@ options:
routes. routes.
required: false required: false
type: bool type: bool
aliases:
- ip_forward
disks: disks:
description: description:
- An array of disks that are associated with the instances that are created from - An array of disks that are associated with the instances that are created from
@ -96,11 +98,6 @@ options:
- Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
encryption key to either encrypt or decrypt this resource. encryption key to either encrypt or decrypt this resource.
required: false required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
index: index:
description: description:
- Assigns a zero-based index to this disk, where 0 is reserved for the boot - Assigns a zero-based index to this disk, where 0 is reserved for the boot
@ -137,6 +134,9 @@ options:
create a disk with one of the public operating system images, specify create a disk with one of the public operating system images, specify
the image by its family name. the image by its family name.
required: false required: false
aliases:
- image
- image_family
source_image_encryption_key: source_image_encryption_key:
description: description:
- The customer-supplied encryption key of the source image. Required if - The customer-supplied encryption key of the source image. Required if
@ -151,11 +151,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in - Specifies a 256-bit customer-supplied encryption key, encoded in
RFC 4648 base64 to either encrypt or decrypt this resource. RFC 4648 base64 to either encrypt or decrypt this resource.
required: false required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
encryption key that protects this resource.
required: false
interface: interface:
description: description:
- Specifies the disk interface to use for attaching this disk, which is either - Specifies the disk interface to use for attaching this disk, which is either
@ -181,9 +176,10 @@ options:
- If desired, you can also attach existing non-root persistent disks using - If desired, you can also attach existing non-root persistent disks using
this property. This field is only applicable for persistent disks. this property. This field is only applicable for persistent disks.
- 'This field represents a link to a Disk resource in GCP. It can be specified - 'This field represents a link to a Disk resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as in two ways. First, you can place a dictionary with key ''selfLink'' and
a string Alternatively, you can add `register: name-of-resource` to a gcp_compute_disk value of your resource''s selfLink Alternatively, you can add `register:
task and then set this source field to "{{ name-of-resource }}"' name-of-resource` to a gcp_compute_disk task and then set this source field
to "{{ name-of-resource }}"'
required: false required: false
type: type:
description: description:
@ -266,10 +262,10 @@ options:
address pool. If you specify a static external IP address, it must live address pool. If you specify a static external IP address, it must live
in the same region as the zone of the instance. in the same region as the zone of the instance.
- 'This field represents a link to a Address resource in GCP. It can be - 'This field represents a link to a Address resource in GCP. It can be
specified in two ways. First, you can place in the address of the resource specified in two ways. First, you can place a dictionary with key ''address''
here as a string Alternatively, you can add `register: name-of-resource` and value of your resource''s address Alternatively, you can add `register:
to a gcp_compute_address task and then set this nat_ip field to "{{ name-of-resource` to a gcp_compute_address task and then set this nat_ip
name-of-resource }}"' field to "{{ name-of-resource }}"'
required: false required: false
type: type:
description: description:
@ -297,11 +293,6 @@ options:
from which to allocate the IP CIDR range for this alias IP range. If from which to allocate the IP CIDR range for this alias IP range. If
left unspecified, the primary range of the subnetwork will be used. left unspecified, the primary range of the subnetwork will be used.
required: false required: false
name:
description:
- The name of the network interface, generated by the server. For network
devices, these are eth0, eth1, etc .
required: false
network: network:
description: description:
- Specifies the title of an existing network. When creating an instance, if - Specifies the title of an existing network. When creating an instance, if
@ -309,9 +300,10 @@ options:
global/networks/default is used; if the network is not specified but the global/networks/default is used; if the network is not specified but the
subnetwork is specified, the network is inferred. subnetwork is specified, the network is inferred.
- 'This field represents a link to a Network resource in GCP. It can be specified - 'This field represents a link to a Network resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as in two ways. First, you can place a dictionary with key ''selfLink'' and
a string Alternatively, you can add `register: name-of-resource` to a gcp_compute_network value of your resource''s selfLink Alternatively, you can add `register:
task and then set this network field to "{{ name-of-resource }}"' name-of-resource` to a gcp_compute_network task and then set this network
field to "{{ name-of-resource }}"'
required: false required: false
network_ip: network_ip:
description: description:
@ -326,10 +318,10 @@ options:
If the network is in auto subnet mode, providing the subnetwork is optional. If the network is in auto subnet mode, providing the subnetwork is optional.
If the network is in custom subnet mode, then this field should be specified. If the network is in custom subnet mode, then this field should be specified.
- 'This field represents a link to a Subnetwork resource in GCP. It can be - 'This field represents a link to a Subnetwork resource in GCP. It can be
specified in two ways. First, you can place in the selfLink of the resource specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` and value of your resource''s selfLink Alternatively, you can add `register:
to a gcp_compute_subnetwork task and then set this subnetwork field to "{{ name-of-resource` to a gcp_compute_subnetwork task and then set this subnetwork
name-of-resource }}"' field to "{{ name-of-resource }}"'
required: false required: false
scheduling: scheduling:
description: description:
@ -419,33 +411,33 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a disk - name: create a disk
gcp_compute_disk: gcp_compute_disk:
name: "disk-instance" name: disk-instance
size_gb: 50 size_gb: 50
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: disk register: disk
- name: create a network - name: create a network
gcp_compute_network: gcp_compute_network:
name: "network-instance" name: network-instance
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: network register: network
- name: create a address - name: create a address
gcp_compute_address: gcp_compute_address:
name: "address-instance" name: address-instance
region: us-central1 region: us-central1
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: address register: address
- name: create a instance - name: create a instance
@ -627,7 +619,7 @@ disks:
- If desired, you can also attach existing non-root persistent disks using this - If desired, you can also attach existing non-root persistent disks using this
property. This field is only applicable for persistent disks. property. This field is only applicable for persistent disks.
returned: success returned: success
type: str type: dict
type: type:
description: description:
- Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified,
@ -723,7 +715,7 @@ networkInterfaces:
address pool. If you specify a static external IP address, it must live address pool. If you specify a static external IP address, it must live
in the same region as the zone of the instance. in the same region as the zone of the instance.
returned: success returned: success
type: str type: dict
type: type:
description: description:
- The type of configuration. The default and only option is ONE_TO_ONE_NAT. - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
@ -765,7 +757,7 @@ networkInterfaces:
is used; if the network is not specified but the subnetwork is specified, is used; if the network is not specified but the subnetwork is specified,
the network is inferred. the network is inferred.
returned: success returned: success
type: str type: dict
networkIP: networkIP:
description: description:
- An IPv4 internal network address to assign to the instance for this network - An IPv4 internal network address to assign to the instance for this network
@ -780,7 +772,7 @@ networkInterfaces:
the network is in auto subnet mode, providing the subnetwork is optional. the network is in auto subnet mode, providing the subnetwork is optional.
If the network is in custom subnet mode, then this field should be specified. If the network is in custom subnet mode, then this field should be specified.
returned: success returned: success
type: str type: dict
scheduling: scheduling:
description: description:
- Sets the scheduling options for this instance. - Sets the scheduling options for this instance.
@ -889,7 +881,7 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
can_ip_forward=dict(type='bool'), can_ip_forward=dict(type='bool', aliases=['ip_forward']),
disks=dict( disks=dict(
type='list', type='list',
elements='dict', elements='dict',
@ -897,7 +889,7 @@ def main():
auto_delete=dict(type='bool'), auto_delete=dict(type='bool'),
boot=dict(type='bool'), boot=dict(type='bool'),
device_name=dict(type='str'), device_name=dict(type='str'),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'), sha256=dict(type='str'))), disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'))),
index=dict(type='int'), index=dict(type='int'),
initialize_params=dict( initialize_params=dict(
type='dict', type='dict',
@ -905,13 +897,13 @@ def main():
disk_name=dict(type='str'), disk_name=dict(type='str'),
disk_size_gb=dict(type='int'), disk_size_gb=dict(type='int'),
disk_type=dict(type='str'), disk_type=dict(type='str'),
source_image=dict(type='str'), source_image=dict(type='str', aliases=['image', 'image_family']),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))), source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
), ),
), ),
interface=dict(type='str', choices=['SCSI', 'NVME']), interface=dict(type='str', choices=['SCSI', 'NVME']),
mode=dict(type='str', choices=['READ_WRITE', 'READ_ONLY']), mode=dict(type='str', choices=['READ_WRITE', 'READ_ONLY']),
source=dict(), source=dict(type='dict'),
type=dict(type='str', choices=['SCRATCH', 'PERSISTENT']), type=dict(type='str', choices=['SCRATCH', 'PERSISTENT']),
), ),
), ),
@ -928,13 +920,14 @@ def main():
access_configs=dict( access_configs=dict(
type='list', type='list',
elements='dict', elements='dict',
options=dict(name=dict(required=True, type='str'), nat_ip=dict(), type=dict(required=True, type='str', choices=['ONE_TO_ONE_NAT'])), options=dict(
name=dict(required=True, type='str'), nat_ip=dict(type='dict'), type=dict(required=True, type='str', choices=['ONE_TO_ONE_NAT'])
),
), ),
alias_ip_ranges=dict(type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))), alias_ip_ranges=dict(type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))),
name=dict(type='str'), network=dict(type='dict'),
network=dict(),
network_ip=dict(type='str'), network_ip=dict(type='str'),
subnetwork=dict(), subnetwork=dict(type='dict'),
), ),
), ),
scheduling=dict( scheduling=dict(
@ -1170,7 +1163,7 @@ def raise_if_errors(response, err_path, module):
def encode_request(request, module): def encode_request(request, module):
if 'metadata' in request: if 'metadata' in request and request['metadata'] is not None:
request['metadata'] = metadata_encoder(request['metadata']) request['metadata'] = metadata_encoder(request['metadata'])
return request return request
@ -1309,14 +1302,10 @@ class InstanceDiskencryptionkey(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict( return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key')})
{u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key'), u'sha256': self.request.get('sha256')}
)
def from_response(self): def from_response(self):
return remove_nones_from_dict( return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey')})
{u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey'), u'sha256': self.request.get(u'sha256')}
)
class InstanceInitializeparams(object): class InstanceInitializeparams(object):
@ -1359,10 +1348,10 @@ class InstanceSourceimageencryptionkey(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
class InstanceGuestacceleratorsArray(object): class InstanceGuestacceleratorsArray(object):
@ -1417,7 +1406,6 @@ class InstanceNetworkinterfacesArray(object):
{ {
u'accessConfigs': InstanceAccessconfigsArray(item.get('access_configs', []), self.module).to_request(), u'accessConfigs': InstanceAccessconfigsArray(item.get('access_configs', []), self.module).to_request(),
u'aliasIpRanges': InstanceAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(), u'aliasIpRanges': InstanceAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(),
u'name': item.get('name'),
u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'), u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'),
u'networkIP': item.get('network_ip'), u'networkIP': item.get('network_ip'),
u'subnetwork': replace_resource_dict(item.get(u'subnetwork', {}), 'selfLink'), u'subnetwork': replace_resource_dict(item.get(u'subnetwork', {}), 'selfLink'),
@ -1429,7 +1417,6 @@ class InstanceNetworkinterfacesArray(object):
{ {
u'accessConfigs': InstanceAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(), u'accessConfigs': InstanceAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(),
u'aliasIpRanges': InstanceAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(), u'aliasIpRanges': InstanceAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(),
u'name': item.get(u'name'),
u'network': item.get(u'network'), u'network': item.get(u'network'),
u'networkIP': item.get(u'networkIP'), u'networkIP': item.get(u'networkIP'),
u'subnetwork': item.get(u'subnetwork'), u'subnetwork': item.get(u'subnetwork'),

View file

@ -42,7 +42,7 @@ requirements:
options: options:
filters: filters:
description: description:
- A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters.) - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- Each additional filter in the list will act be added as an AND condition (filter1 - Each additional filter in the list will act be added as an AND condition (filter1
and filter2) . and filter2) .
zone: zone:
@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a instance facts - name: " a instance facts"
gcp_compute_instance_facts: gcp_compute_instance_facts:
zone: us-central1-a zone: us-central1-a
filters: filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -225,7 +225,7 @@ items:
- If desired, you can also attach existing non-root persistent disks using - If desired, you can also attach existing non-root persistent disks using
this property. This field is only applicable for persistent disks. this property. This field is only applicable for persistent disks.
returned: success returned: success
type: str type: dict
type: type:
description: description:
- Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified, - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified,
@ -323,7 +323,7 @@ items:
IP address pool. If you specify a static external IP address, it must IP address pool. If you specify a static external IP address, it must
live in the same region as the zone of the instance. live in the same region as the zone of the instance.
returned: success returned: success
type: str type: dict
type: type:
description: description:
- The type of configuration. The default and only option is ONE_TO_ONE_NAT. - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
@ -365,7 +365,7 @@ items:
global/networks/default is used; if the network is not specified but the global/networks/default is used; if the network is not specified but the
subnetwork is specified, the network is inferred. subnetwork is specified, the network is inferred.
returned: success returned: success
type: str type: dict
networkIP: networkIP:
description: description:
- An IPv4 internal network address to assign to the instance for this network - An IPv4 internal network address to assign to the instance for this network
@ -380,7 +380,7 @@ items:
If the network is in auto subnet mode, providing the subnetwork is optional. If the network is in auto subnet mode, providing the subnetwork is optional.
If the network is in custom subnet mode, then this field should be specified. If the network is in custom subnet mode, then this field should be specified.
returned: success returned: success
type: str type: dict
scheduling: scheduling:
description: description:
- Sets the scheduling options for this instance. - Sets the scheduling options for this instance.
@ -493,7 +493,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -107,16 +107,16 @@ EXAMPLES = '''
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: test_object name: "test_object"
named_ports: named_ports:
- name: ansible - name: ansible
port: 1234 port: 1234
network: "{{ network }}" network: "{{ network }}"
zone: us-central1-a zone: us-central1-a
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -55,13 +55,12 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: " a instance group facts" - name: " a instance group facts"
gcp_compute_instance_group_facts: gcp_compute_instance_group_facts:
zone: us-central1-a zone: us-central1-a
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -70,10 +70,10 @@ options:
group uses this template to create all new instances in the managed instance group uses this template to create all new instances in the managed instance
group. group.
- 'This field represents a link to a InstanceTemplate resource in GCP. It can - 'This field represents a link to a InstanceTemplate resource in GCP. It can
be specified in two ways. First, you can place in the selfLink of the resource be specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` to and value of your resource''s selfLink Alternatively, you can add `register:
a gcp_compute_instance_template task and then set this instance_template field name-of-resource` to a gcp_compute_instance_template task and then set this
to "{{ name-of-resource }}"' instance_template field to "{{ name-of-resource }}"'
required: true required: true
name: name:
description: description:
@ -117,43 +117,43 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a network - name: create a network
gcp_compute_network: gcp_compute_network:
name: "network-instancetemplate" name: network-instancetemplate
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: network register: network
- name: create a address - name: create a address
gcp_compute_address: gcp_compute_address:
name: "address-instancetemplate" name: address-instancetemplate
region: us-west1 region: us-west1
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: address register: address
- name: create a instance template - name: create a instance template
gcp_compute_instance_template: gcp_compute_instance_template:
name: "{{ resource_name }}" name: "{{ resource_name }}"
properties: properties:
disks: disks:
- auto_delete: true - auto_delete: 'true'
boot: true boot: 'true'
initialize_params: initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1 machine_type: n1-standard-1
network_interfaces: network_interfaces:
- network: "{{ network }}" - network: "{{ network }}"
access_configs: access_configs:
- name: test-config - name: test-config
type: ONE_TO_ONE_NAT type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}" nat_ip: "{{ address }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancetemplate register: instancetemplate
- name: create a instance group manager - name: create a instance group manager
@ -261,13 +261,13 @@ instanceGroup:
description: description:
- The instance group being managed. - The instance group being managed.
returned: success returned: success
type: str type: dict
instanceTemplate: instanceTemplate:
description: description:
- The instance template that is specified for this managed instance group. The group - The instance template that is specified for this managed instance group. The group
uses this template to create all new instances in the managed instance group. uses this template to create all new instances in the managed instance group.
returned: success returned: success
type: str type: dict
name: name:
description: description:
- The name of the managed instance group. The name must be 1-63 characters long, - The name of the managed instance group. The name must be 1-63 characters long,
@ -339,10 +339,10 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
base_instance_name=dict(required=True, type='str'), base_instance_name=dict(required=True, type='str'),
description=dict(type='str'), description=dict(type='str'),
instance_template=dict(required=True), instance_template=dict(required=True, type='dict'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
named_ports=dict(type='list', elements='dict', options=dict(name=dict(type='str'), port=dict(type='int'))), named_ports=dict(type='list', elements='dict', options=dict(name=dict(type='str'), port=dict(type='int'))),
target_pools=dict(type='list'), target_pools=dict(type='list', elements='dict'),
target_size=dict(type='int'), target_size=dict(type='int'),
zone=dict(required=True, type='str'), zone=dict(required=True, type='str'),
) )
@ -537,32 +537,10 @@ class InstanceGroupManagerCurrentactions(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict( return remove_nones_from_dict({})
{
u'abandoning': self.request.get('abandoning'),
u'creating': self.request.get('creating'),
u'creatingWithoutRetries': self.request.get('creating_without_retries'),
u'deleting': self.request.get('deleting'),
u'none': self.request.get('none'),
u'recreating': self.request.get('recreating'),
u'refreshing': self.request.get('refreshing'),
u'restarting': self.request.get('restarting'),
}
)
def from_response(self): def from_response(self):
return remove_nones_from_dict( return remove_nones_from_dict({})
{
u'abandoning': self.request.get(u'abandoning'),
u'creating': self.request.get(u'creating'),
u'creatingWithoutRetries': self.request.get(u'creatingWithoutRetries'),
u'deleting': self.request.get(u'deleting'),
u'none': self.request.get(u'none'),
u'recreating': self.request.get(u'recreating'),
u'refreshing': self.request.get(u'refreshing'),
u'restarting': self.request.get(u'restarting'),
}
)
class InstanceGroupManagerNamedportsArray(object): class InstanceGroupManagerNamedportsArray(object):

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a instance group manager facts - name: " a instance group manager facts"
gcp_compute_instance_group_manager_facts: gcp_compute_instance_group_manager_facts:
zone: us-west1-a zone: us-west1-a
filters: filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -161,14 +161,14 @@ items:
description: description:
- The instance group being managed. - The instance group being managed.
returned: success returned: success
type: str type: dict
instanceTemplate: instanceTemplate:
description: description:
- The instance template that is specified for this managed instance group. The - The instance template that is specified for this managed instance group. The
group uses this template to create all new instances in the managed instance group uses this template to create all new instances in the managed instance
group. group.
returned: success returned: success
type: str type: dict
name: name:
description: description:
- The name of the managed instance group. The name must be 1-63 characters long, - The name of the managed instance group. The name must be 1-63 characters long,
@ -241,7 +241,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -422,24 +422,24 @@ EXAMPLES = '''
- name: create a instance template - name: create a instance template
gcp_compute_instance_template: gcp_compute_instance_template:
name: test_object name: "test_object"
properties: properties:
disks: disks:
- auto_delete: 'true' - auto_delete: true
boot: 'true' boot: true
initialize_params: initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1 machine_type: n1-standard-1
network_interfaces: network_interfaces:
- network: "{{ network }}" - network: "{{ network }}"
access_configs: access_configs:
- name: test-config - name: test-config
type: ONE_TO_ONE_NAT type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}" nat_ip: "{{ address }}"
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a instance template facts - name: " a instance template facts"
gcp_compute_instance_template_facts: gcp_compute_instance_template_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -250,7 +250,7 @@ items:
- Note that for InstanceTemplate, specify the disk name, not the URL - Note that for InstanceTemplate, specify the disk name, not the URL
for the disk. for the disk.
returned: success returned: success
type: str type: dict
type: type:
description: description:
- Specifies the type of the disk, either SCRATCH or PERSISTENT. If not - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not
@ -326,7 +326,7 @@ items:
ephemeral IP address pool. If you specify a static external IP ephemeral IP address pool. If you specify a static external IP
address, it must live in the same region as the zone of the instance. address, it must live in the same region as the zone of the instance.
returned: success returned: success
type: str type: dict
type: type:
description: description:
- The type of configuration. The default and only option is ONE_TO_ONE_NAT. - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
@ -370,7 +370,7 @@ items:
network global/networks/default is used; if the network is not specified network global/networks/default is used; if the network is not specified
but the subnetwork is specified, the network is inferred. but the subnetwork is specified, the network is inferred.
returned: success returned: success
type: str type: dict
networkIP: networkIP:
description: description:
- An IPv4 internal network address to assign to the instance for this - An IPv4 internal network address to assign to the instance for this
@ -386,7 +386,7 @@ items:
optional. If the network is in custom subnet mode, then this field optional. If the network is in custom subnet mode, then this field
should be specified. should be specified.
returned: success returned: success
type: str type: dict
scheduling: scheduling:
description: description:
- Sets the scheduling options for this instance. - Sets the scheduling options for this instance.
@ -482,7 +482,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -51,12 +51,30 @@ options:
interconnect: interconnect:
description: description:
- URL of the underlying Interconnect object that this attachment's traffic will - URL of the underlying Interconnect object that this attachment's traffic will
traverse through. traverse through. Required if type is DEDICATED, must not be set if type is
required: true PARTNER.
required: false
description: description:
description: description:
- An optional description of this resource. - An optional description of this resource.
required: false required: false
edge_availability_domain:
description:
- Desired availability domain for the attachment. Only available for type PARTNER,
at creation time. For improved reliability, customers should configure a pair
of attachments with one per availability domain. The selected availability domain
will be provided to the Partner via the pairing key so that the provisioned
circuit will lie in the specified domain. If not specified, the value will default
to AVAILABILITY_DOMAIN_ANY.
required: false
type:
description:
- The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
required: false
choices:
- DEDICATED
- PARTNER
- PARTNER_PROVIDER
router: router:
description: description:
- URL of the cloud router to be used for dynamic routing. This router must be - URL of the cloud router to be used for dynamic routing. This router must be
@ -64,9 +82,10 @@ options:
will automatically connect the Interconnect to the network & region within which will automatically connect the Interconnect to the network & region within which
the Cloud Router is configured. the Cloud Router is configured.
- 'This field represents a link to a Router resource in GCP. It can be specified - 'This field represents a link to a Router resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_router of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this router field to "{{ name-of-resource }}"' to a gcp_compute_router task and then set this router field to "{{ name-of-resource
}}"'
required: true required: true
name: name:
description: description:
@ -89,7 +108,8 @@ options:
required: false required: false
vlan_tag8021q: vlan_tag8021q:
description: description:
- The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. - The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. When using
PARTNER type this will be managed upstream.
required: false required: false
region: region:
description: description:
@ -101,14 +121,14 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a interconnect attachment - name: create a interconnect attachment
gcp_compute_interconnect_attachment: gcp_compute_interconnect_attachment:
name: "test_object" name: test_object
region: us-central1 region: us-central1
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
interconnect: https://googleapis.com/compute/v1/projects/test_project/global/interconnects/... interconnect: https://googleapis.com/compute/v1/projects/test_project/global/interconnects/...
router: https://googleapis.com/compute/v1/projects/test_project/regions/us-central1/routers/... router: https://googleapis.com/compute/v1/projects/test_project/regions/us-central1/routers/...
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
register: disk register: disk
''' '''
@ -128,7 +148,7 @@ customerRouterIpAddress:
interconnect: interconnect:
description: description:
- URL of the underlying Interconnect object that this attachment's traffic will - URL of the underlying Interconnect object that this attachment's traffic will
traverse through. traverse through. Required if type is DEDICATED, must not be set if type is PARTNER.
returned: success returned: success
type: str type: str
description: description:
@ -136,6 +156,30 @@ description:
- An optional description of this resource. - An optional description of this resource.
returned: success returned: success
type: str type: str
edgeAvailabilityDomain:
description:
- Desired availability domain for the attachment. Only available for type PARTNER,
at creation time. For improved reliability, customers should configure a pair
of attachments with one per availability domain. The selected availability domain
will be provided to the Partner via the pairing key so that the provisioned circuit
will lie in the specified domain. If not specified, the value will default to
AVAILABILITY_DOMAIN_ANY.
returned: success
type: str
pairingKey:
description:
- '[Output only for type PARTNER. Not present for DEDICATED]. The opaque identifier
of an PARTNER attachment used to initiate provisioning with a selected partner.
Of the form "XXXXX/region/domain" .'
returned: success
type: str
partnerAsn:
description:
- "[Output only for type PARTNER. Not present for DEDICATED]. Optional BGP ASN for
the router that should be supplied by a layer 3 Partner if they configured BGP
on behalf of the customer."
returned: success
type: str
privateInterconnectInfo: privateInterconnectInfo:
description: description:
- Information specific to an InterconnectAttachment. This property is populated - Information specific to an InterconnectAttachment. This property is populated
@ -149,6 +193,16 @@ privateInterconnectInfo:
going to and from this network and region. going to and from this network and region.
returned: success returned: success
type: int type: int
type:
description:
- The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
returned: success
type: str
state:
description:
- "[Output Only] The current state of this attachment's functionality."
returned: success
type: str
googleReferenceId: googleReferenceId:
description: description:
- Google reference ID, to be used when raising support tickets with Google or otherwise - Google reference ID, to be used when raising support tickets with Google or otherwise
@ -162,7 +216,7 @@ router:
automatically connect the Interconnect to the network & region within which the automatically connect the Interconnect to the network & region within which the
Cloud Router is configured. Cloud Router is configured.
returned: success returned: success
type: str type: dict
creationTimestamp: creationTimestamp:
description: description:
- Creation timestamp in RFC3339 text format. - Creation timestamp in RFC3339 text format.
@ -196,7 +250,8 @@ candidateSubnets:
type: list type: list
vlanTag8021q: vlanTag8021q:
description: description:
- The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. - The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. When using
PARTNER type this will be managed upstream.
returned: success returned: success
type: int type: int
region: region:
@ -226,9 +281,11 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
interconnect=dict(required=True, type='str'), interconnect=dict(type='str'),
description=dict(type='str'), description=dict(type='str'),
router=dict(required=True), edge_availability_domain=dict(type='str'),
type=dict(type='str', choices=['DEDICATED', 'PARTNER', 'PARTNER_PROVIDER']),
router=dict(required=True, type='dict'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
candidate_subnets=dict(type='list', elements='str'), candidate_subnets=dict(type='list', elements='str'),
vlan_tag8021q=dict(type='int'), vlan_tag8021q=dict(type='int'),
@ -273,7 +330,8 @@ def create(module, link, kind):
def update(module, link, kind): def update(module, link, kind):
module.fail_json(msg="InterconnectAttachment cannot be edited") delete(module, self_link(module), kind)
create(module, collection(module), kind)
def delete(module, link, kind): def delete(module, link, kind):
@ -286,6 +344,8 @@ def resource_to_request(module):
u'kind': 'compute#interconnectAttachment', u'kind': 'compute#interconnectAttachment',
u'interconnect': module.params.get('interconnect'), u'interconnect': module.params.get('interconnect'),
u'description': module.params.get('description'), u'description': module.params.get('description'),
u'edgeAvailabilityDomain': module.params.get('edge_availability_domain'),
u'type': module.params.get('type'),
u'router': replace_resource_dict(module.params.get(u'router', {}), 'selfLink'), u'router': replace_resource_dict(module.params.get(u'router', {}), 'selfLink'),
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'candidateSubnets': module.params.get('candidate_subnets'), u'candidateSubnets': module.params.get('candidate_subnets'),
@ -359,7 +419,12 @@ def response_to_hash(module, response):
u'customerRouterIpAddress': response.get(u'customerRouterIpAddress'), u'customerRouterIpAddress': response.get(u'customerRouterIpAddress'),
u'interconnect': response.get(u'interconnect'), u'interconnect': response.get(u'interconnect'),
u'description': response.get(u'description'), u'description': response.get(u'description'),
u'edgeAvailabilityDomain': response.get(u'edgeAvailabilityDomain'),
u'pairingKey': response.get(u'pairingKey'),
u'partnerAsn': response.get(u'partnerAsn'),
u'privateInterconnectInfo': InterconnectAttachmentPrivateinterconnectinfo(response.get(u'privateInterconnectInfo', {}), module).from_response(), u'privateInterconnectInfo': InterconnectAttachmentPrivateinterconnectinfo(response.get(u'privateInterconnectInfo', {}), module).from_response(),
u'type': response.get(u'type'),
u'state': response.get(u'state'),
u'googleReferenceId': response.get(u'googleReferenceId'), u'googleReferenceId': response.get(u'googleReferenceId'),
u'router': response.get(u'router'), u'router': response.get(u'router'),
u'creationTimestamp': response.get(u'creationTimestamp'), u'creationTimestamp': response.get(u'creationTimestamp'),
@ -423,10 +488,10 @@ class InterconnectAttachmentPrivateinterconnectinfo(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'tag8021q': self.request.get('tag8021q')}) return remove_nones_from_dict({})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'tag8021q': self.request.get(u'tag8021q')}) return remove_nones_from_dict({})
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -53,19 +53,20 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a interconnect attachment facts - name: " a interconnect attachment facts"
gcp_compute_interconnect_attachment_facts: gcp_compute_interconnect_attachment_facts:
region: us-central1 region: us-central1
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -84,7 +85,8 @@ items:
interconnect: interconnect:
description: description:
- URL of the underlying Interconnect object that this attachment's traffic will - URL of the underlying Interconnect object that this attachment's traffic will
traverse through. traverse through. Required if type is DEDICATED, must not be set if type is
PARTNER.
returned: success returned: success
type: str type: str
description: description:
@ -92,6 +94,30 @@ items:
- An optional description of this resource. - An optional description of this resource.
returned: success returned: success
type: str type: str
edgeAvailabilityDomain:
description:
- Desired availability domain for the attachment. Only available for type PARTNER,
at creation time. For improved reliability, customers should configure a pair
of attachments with one per availability domain. The selected availability
domain will be provided to the Partner via the pairing key so that the provisioned
circuit will lie in the specified domain. If not specified, the value will
default to AVAILABILITY_DOMAIN_ANY.
returned: success
type: str
pairingKey:
description:
- '[Output only for type PARTNER. Not present for DEDICATED]. The opaque identifier
of an PARTNER attachment used to initiate provisioning with a selected partner.
Of the form "XXXXX/region/domain" .'
returned: success
type: str
partnerAsn:
description:
- "[Output only for type PARTNER. Not present for DEDICATED]. Optional BGP ASN
for the router that should be supplied by a layer 3 Partner if they configured
BGP on behalf of the customer."
returned: success
type: str
privateInterconnectInfo: privateInterconnectInfo:
description: description:
- Information specific to an InterconnectAttachment. This property is populated - Information specific to an InterconnectAttachment. This property is populated
@ -105,6 +131,16 @@ items:
customer, going to and from this network and region. customer, going to and from this network and region.
returned: success returned: success
type: int type: int
type:
description:
- The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
returned: success
type: str
state:
description:
- "[Output Only] The current state of this attachment's functionality."
returned: success
type: str
googleReferenceId: googleReferenceId:
description: description:
- Google reference ID, to be used when raising support tickets with Google or - Google reference ID, to be used when raising support tickets with Google or
@ -118,7 +154,7 @@ items:
will automatically connect the Interconnect to the network & region within will automatically connect the Interconnect to the network & region within
which the Cloud Router is configured. which the Cloud Router is configured.
returned: success returned: success
type: str type: dict
creationTimestamp: creationTimestamp:
description: description:
- Creation timestamp in RFC3339 text format. - Creation timestamp in RFC3339 text format.
@ -153,7 +189,8 @@ items:
type: list type: list
vlanTag8021q: vlanTag8021q:
description: description:
- The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. - The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. When using
PARTNER type this will be managed upstream.
returned: success returned: success
type: int type: int
region: region:
@ -185,7 +222,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -31,18 +31,7 @@ DOCUMENTATION = '''
--- ---
module: gcp_compute_network module: gcp_compute_network
description: description:
- Represents a Network resource. - Manages a VPC network or legacy network resource on GCP.
- Your Cloud Platform Console project can contain multiple networks, and each network
can have multiple instances attached to it. A network allows you to define a gateway
IP and the network range for the instances attached to that network. Every project
is provided with a default network with preset configurations and firewall rules.
You can choose to customize the default network by adding or removing rules, or
you can create new networks in that project. Generally, most users only need one
network, although you can have up to five networks per project by default.
- A network belongs to only one project, and each instance can only belong to one
network. All Compute Engine networks use the IPv4 protocol. Compute Engine currently
does not support IPv6. However, Google is a major advocate of IPv6 and it is an
important future direction.
short_description: Creates a GCP Network short_description: Creates a GCP Network
version_added: 2.6 version_added: 2.6
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
@ -60,14 +49,18 @@ options:
default: present default: present
description: description:
description: description:
- An optional description of this resource. Provide this property when you create - An optional description of this resource. The resource must be recreated to
the resource. modify this field.
required: false required: false
ipv4_range: ipv4_range:
description: description:
- 'The range of internal addresses that are legal on this network. This range - If this field is specified, a deprecated legacy network is created.
is a CIDR specification, for example: 192.168.0.0/16. Provided by the client - You will no longer be able to create a legacy network on Feb 1, 2020.
when the network is created.' - See the [legacy network docs](U(https://cloud.google.com/vpc/docs/legacy)) for
more details.
- The range of internal addresses that are legal on this legacy network.
- 'This range is a CIDR specification, for example: `192.168.0.0/16`.'
- The resource must be recreated to modify this field.
required: false required: false
name: name:
description: description:
@ -80,10 +73,11 @@ options:
required: true required: true
auto_create_subnetworks: auto_create_subnetworks:
description: description:
- When set to true, the network is created in "auto subnet mode". When set to - When set to `true`, the network is created in "auto subnet mode" and it will
false, the network is in "custom subnet mode". create a subnet for each region automatically across the `10.128.0.0/9` address
- In "auto subnet mode", a newly created network is assigned the default CIDR range.
of 10.128.0.0/9 and it automatically creates one subnetwork per region. - When set to `false`, the network is created in "custom subnet mode" so the user
can explicitly connect subnetwork resources.
required: false required: false
type: bool type: bool
routing_config: routing_config:
@ -95,9 +89,9 @@ options:
suboptions: suboptions:
routing_mode: routing_mode:
description: description:
- The network-wide routing mode to use. If set to REGIONAL, this network's - The network-wide routing mode to use. If set to `REGIONAL`, this network's
cloud routers will only advertise routes with subnetworks of this network cloud routers will only advertise routes with subnetworks of this network
in the same region as the router. If set to GLOBAL, this network's cloud in the same region as the router. If set to `GLOBAL`, this network's cloud
routers will advertise routes with all subnetworks of this network, across routers will advertise routes with all subnetworks of this network, across
regions. regions.
required: true required: true
@ -124,15 +118,14 @@ EXAMPLES = '''
RETURN = ''' RETURN = '''
description: description:
description: description:
- An optional description of this resource. Provide this property when you create - An optional description of this resource. The resource must be recreated to modify
the resource. this field.
returned: success returned: success
type: str type: str
gateway_ipv4: gateway_ipv4:
description: description:
- A gateway address for default routing to other networks. This value is read only - The gateway address for default routing out of the network. This value is selected
and is selected by the Google Compute Engine, typically as the first usable address by GCP.
in the IPv4Range.
returned: success returned: success
type: str type: str
id: id:
@ -142,9 +135,13 @@ id:
type: int type: int
ipv4_range: ipv4_range:
description: description:
- 'The range of internal addresses that are legal on this network. This range is - If this field is specified, a deprecated legacy network is created.
a CIDR specification, for example: 192.168.0.0/16. Provided by the client when - You will no longer be able to create a legacy network on Feb 1, 2020.
the network is created.' - See the [legacy network docs](U(https://cloud.google.com/vpc/docs/legacy)) for
more details.
- The range of internal addresses that are legal on this legacy network.
- 'This range is a CIDR specification, for example: `192.168.0.0/16`.'
- The resource must be recreated to modify this field.
returned: success returned: success
type: str type: str
name: name:
@ -164,10 +161,10 @@ subnetworks:
type: list type: list
autoCreateSubnetworks: autoCreateSubnetworks:
description: description:
- When set to true, the network is created in "auto subnet mode". When set to false, - When set to `true`, the network is created in "auto subnet mode" and it will create
the network is in "custom subnet mode". a subnet for each region automatically across the `10.128.0.0/9` address range.
- In "auto subnet mode", a newly created network is assigned the default CIDR of - When set to `false`, the network is created in "custom subnet mode" so the user
10.128.0.0/9 and it automatically creates one subnetwork per region. can explicitly connect subnetwork resources.
returned: success returned: success
type: bool type: bool
creationTimestamp: creationTimestamp:
@ -184,10 +181,11 @@ routingConfig:
contains: contains:
routingMode: routingMode:
description: description:
- The network-wide routing mode to use. If set to REGIONAL, this network's cloud - The network-wide routing mode to use. If set to `REGIONAL`, this network's
routers will only advertise routes with subnetworks of this network in the cloud routers will only advertise routes with subnetworks of this network
same region as the router. If set to GLOBAL, this network's cloud routers in the same region as the router. If set to `GLOBAL`, this network's cloud
will advertise routes with all subnetworks of this network, across regions. routers will advertise routes with all subnetworks of this network, across
regions.
returned: success returned: success
type: str type: str
''' '''
@ -232,7 +230,7 @@ def main():
if fetch: if fetch:
if state == 'present': if state == 'present':
if is_different(module, fetch): if is_different(module, fetch):
update(module, self_link(module), kind) update(module, self_link(module), kind, fetch)
fetch = fetch_resource(module, self_link(module), kind) fetch = fetch_resource(module, self_link(module), kind)
changed = True changed = True
else: else:
@ -256,9 +254,22 @@ def create(module, link, kind):
return wait_for_operation(module, auth.post(link, resource_to_request(module))) return wait_for_operation(module, auth.post(link, resource_to_request(module)))
def update(module, link, kind): def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
return fetch_resource(module, self_link(module), kind)
def update_fields(module, request, response):
if response.get('routingConfig') != request.get('routingConfig'):
routing_config_update(module, request, response)
def routing_config_update(module, request, response):
auth = GcpSession(module, 'compute') auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.patch(link, resource_to_request(module))) auth.patch(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/networks/{name}"]).format(**module.params),
{u'routingConfig': NetworkRoutingconfig(module.params.get('routing_config', {}), module).to_request()},
)
def delete(module, link, kind): def delete(module, link, kind):

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a network facts - name: " a network facts"
gcp_compute_network_facts: gcp_compute_network_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,22 +59,21 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
description: description:
description: description:
- An optional description of this resource. Provide this property when you create - An optional description of this resource. The resource must be recreated to
the resource. modify this field.
returned: success returned: success
type: str type: str
gateway_ipv4: gateway_ipv4:
description: description:
- A gateway address for default routing to other networks. This value is read - The gateway address for default routing out of the network. This value is
only and is selected by the Google Compute Engine, typically as the first selected by GCP.
usable address in the IPv4Range.
returned: success returned: success
type: str type: str
id: id:
@ -84,9 +83,13 @@ items:
type: int type: int
ipv4_range: ipv4_range:
description: description:
- 'The range of internal addresses that are legal on this network. This range - If this field is specified, a deprecated legacy network is created.
is a CIDR specification, for example: 192.168.0.0/16. Provided by the client - You will no longer be able to create a legacy network on Feb 1, 2020.
when the network is created.' - See the [legacy network docs](U(https://cloud.google.com/vpc/docs/legacy))
for more details.
- The range of internal addresses that are legal on this legacy network.
- 'This range is a CIDR specification, for example: `192.168.0.0/16`.'
- The resource must be recreated to modify this field.
returned: success returned: success
type: str type: str
name: name:
@ -106,10 +109,11 @@ items:
type: list type: list
autoCreateSubnetworks: autoCreateSubnetworks:
description: description:
- When set to true, the network is created in "auto subnet mode". When set to - When set to `true`, the network is created in "auto subnet mode" and it will
false, the network is in "custom subnet mode". create a subnet for each region automatically across the `10.128.0.0/9` address
- In "auto subnet mode", a newly created network is assigned the default CIDR range.
of 10.128.0.0/9 and it automatically creates one subnetwork per region. - When set to `false`, the network is created in "custom subnet mode" so the
user can explicitly connect subnetwork resources.
returned: success returned: success
type: bool type: bool
creationTimestamp: creationTimestamp:
@ -126,9 +130,9 @@ items:
contains: contains:
routingMode: routingMode:
description: description:
- The network-wide routing mode to use. If set to REGIONAL, this network's - The network-wide routing mode to use. If set to `REGIONAL`, this network's
cloud routers will only advertise routes with subnetworks of this network cloud routers will only advertise routes with subnetworks of this network
in the same region as the router. If set to GLOBAL, this network's cloud in the same region as the router. If set to `GLOBAL`, this network's cloud
routers will advertise routes with all subnetworks of this network, across routers will advertise routes with all subnetworks of this network, across
regions. regions.
returned: success returned: success
@ -157,7 +161,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -88,6 +88,14 @@ options:
of sizeGb must not be less than the size of the sourceImage or the size of the of sizeGb must not be less than the size of the sourceImage or the size of the
snapshot. snapshot.
required: false required: false
physical_block_size_bytes:
description:
- Physical block size of the persistent disk, in bytes. If not present in a request,
a default value is used. Currently supported sizes are 4096 and 16384, other
sizes may be added in the future.
- If an unsupported value is requested, the error message will list the supported
values for the caller's project.
required: false
replica_zones: replica_zones:
description: description:
- URLs of the zones where the disk should be replicated to. - URLs of the zones where the disk should be replicated to.
@ -118,19 +126,15 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource. base64 to either encrypt or decrypt this resource.
required: false required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
source_snapshot: source_snapshot:
description: description:
- The source snapshot used to create this disk. You can provide this as a partial - The source snapshot used to create this disk. You can provide this as a partial
or full URL to the resource. or full URL to the resource.
- 'This field represents a link to a Snapshot resource in GCP. It can be specified - 'This field represents a link to a Snapshot resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_snapshot of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this source_snapshot field to "{{ name-of-resource }}"' to a gcp_compute_snapshot task and then set this source_snapshot field to "{{
name-of-resource }}"'
required: false required: false
source_snapshot_encryption_key: source_snapshot_encryption_key:
description: description:
@ -143,11 +147,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource. base64 to either encrypt or decrypt this resource.
required: false required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)' - 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)'
@ -157,18 +156,18 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a region disk - name: create a region disk
gcp_compute_region_disk: gcp_compute_region_disk:
name: "test_object" name: test_object
size_gb: 50 size_gb: 50
disk_encryption_key: disk_encryption_key:
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
region: us-central1 region: us-central1
replica_zones: replica_zones:
- https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''
@ -240,6 +239,15 @@ users:
.' .'
returned: success returned: success
type: list type: list
physicalBlockSizeBytes:
description:
- Physical block size of the persistent disk, in bytes. If not present in a request,
a default value is used. Currently supported sizes are 4096 and 16384, other sizes
may be added in the future.
- If an unsupported value is requested, the error message will list the supported
values for the caller's project.
returned: success
type: int
replicaZones: replicaZones:
description: description:
- URLs of the zones where the disk should be replicated to. - URLs of the zones where the disk should be replicated to.
@ -286,7 +294,7 @@ sourceSnapshot:
- The source snapshot used to create this disk. You can provide this as a partial - The source snapshot used to create this disk. You can provide this as a partial
or full URL to the resource. or full URL to the resource.
returned: success returned: success
type: str type: dict
sourceSnapshotEncryptionKey: sourceSnapshotEncryptionKey:
description: description:
- The customer-supplied encryption key of the source snapshot. Required if the source - The customer-supplied encryption key of the source snapshot. Required if the source
@ -342,12 +350,13 @@ def main():
licenses=dict(type='list', elements='str'), licenses=dict(type='list', elements='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
size_gb=dict(type='int'), size_gb=dict(type='int'),
physical_block_size_bytes=dict(type='int'),
replica_zones=dict(required=True, type='list', elements='str'), replica_zones=dict(required=True, type='list', elements='str'),
type=dict(type='str'), type=dict(type='str'),
region=dict(required=True, type='str'), region=dict(required=True, type='str'),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))), disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
source_snapshot=dict(), source_snapshot=dict(type='dict'),
source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))), source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
) )
) )
@ -430,6 +439,7 @@ def resource_to_request(module):
u'licenses': module.params.get('licenses'), u'licenses': module.params.get('licenses'),
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'sizeGb': module.params.get('size_gb'), u'sizeGb': module.params.get('size_gb'),
u'physicalBlockSizeBytes': module.params.get('physical_block_size_bytes'),
u'replicaZones': module.params.get('replica_zones'), u'replicaZones': module.params.get('replica_zones'),
u'type': region_disk_type_selflink(module.params.get('type'), module.params), u'type': region_disk_type_selflink(module.params.get('type'), module.params),
} }
@ -508,6 +518,7 @@ def response_to_hash(module, response):
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'sizeGb': response.get(u'sizeGb'), u'sizeGb': response.get(u'sizeGb'),
u'users': response.get(u'users'), u'users': response.get(u'users'),
u'physicalBlockSizeBytes': response.get(u'physicalBlockSizeBytes'),
u'replicaZones': response.get(u'replicaZones'), u'replicaZones': response.get(u'replicaZones'),
u'type': response.get(u'type'), u'type': response.get(u'type'),
} }
@ -575,10 +586,10 @@ class RegionDiskDiskencryptionkey(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
class RegionDiskSourcesnapshotencryptionkey(object): class RegionDiskSourcesnapshotencryptionkey(object):
@ -590,10 +601,10 @@ class RegionDiskSourcesnapshotencryptionkey(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'sha256': self.request.get('sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'sha256': self.request.get(u'sha256')}) return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -53,19 +53,20 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a region disk facts - name: " a region disk facts"
gcp_compute_region_disk_facts: gcp_compute_region_disk_facts:
region: us-central1 region: us-central1
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -137,6 +138,15 @@ items:
.' .'
returned: success returned: success
type: list type: list
physicalBlockSizeBytes:
description:
- Physical block size of the persistent disk, in bytes. If not present in a
request, a default value is used. Currently supported sizes are 4096 and 16384,
other sizes may be added in the future.
- If an unsupported value is requested, the error message will list the supported
values for the caller's project.
returned: success
type: int
replicaZones: replicaZones:
description: description:
- URLs of the zones where the disk should be replicated to. - URLs of the zones where the disk should be replicated to.
@ -184,7 +194,7 @@ items:
- The source snapshot used to create this disk. You can provide this as a partial - The source snapshot used to create this disk. You can provide this as a partial
or full URL to the resource. or full URL to the resource.
returned: success returned: success
type: str type: dict
sourceSnapshotEncryptionKey: sourceSnapshotEncryptionKey:
description: description:
- The customer-supplied encryption key of the source snapshot. Required if the - The customer-supplied encryption key of the source snapshot. Required if the
@ -237,7 +247,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -154,17 +154,17 @@ EXAMPLES = '''
- name: create a route - name: create a route
gcp_compute_route: gcp_compute_route:
name: test_object name: "test_object"
dest_range: 192.168.6.0/24 dest_range: 192.168.6.0/24
next_hop_gateway: global/gateways/default-internet-gateway next_hop_gateway: global/gateways/default-internet-gateway
network: "{{ network }}" network: "{{ network }}"
tags: tags:
- backends - backends
- databases - databases
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a route facts - name: " a route facts"
gcp_compute_route_facts: gcp_compute_route_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -90,7 +90,7 @@ items:
description: description:
- The network that this route applies to. - The network that this route applies to.
returned: success returned: success
type: str type: dict
priority: priority:
description: description:
- The priority of this route. Priority is used to break ties in cases where - The priority of this route. Priority is used to break ties in cases where
@ -121,7 +121,7 @@ items:
instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance
.' .'
returned: success returned: success
type: str type: dict
nextHopIp: nextHopIp:
description: description:
- Network IP address of an instance that should handle matching packets. - Network IP address of an instance that should handle matching packets.
@ -131,7 +131,7 @@ items:
description: description:
- URL to a VpnTunnel that should handle matching packets. - URL to a VpnTunnel that should handle matching packets.
returned: success returned: success
type: str type: dict
nextHopNetwork: nextHopNetwork:
description: description:
- URL to a Network that should handle matching packets. - URL to a Network that should handle matching packets.
@ -161,7 +161,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -63,9 +63,10 @@ options:
description: description:
- A reference to the network to which this router belongs. - A reference to the network to which this router belongs.
- 'This field represents a link to a Network resource in GCP. It can be specified - 'This field represents a link to a Network resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_network of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this network field to "{{ name-of-resource }}"' to a gcp_compute_network task and then set this network field to "{{ name-of-resource
}}"'
required: true required: true
bgp: bgp:
description: description:
@ -126,11 +127,11 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a network - name: create a network
gcp_compute_network: gcp_compute_network:
name: "network-router" name: network-router
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: network register: network
- name: create a router - name: create a router
@ -181,7 +182,7 @@ network:
description: description:
- A reference to the network to which this router belongs. - A reference to the network to which this router belongs.
returned: success returned: success
type: str type: dict
bgp: bgp:
description: description:
- BGP information specific to this router. - BGP information specific to this router.
@ -258,7 +259,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
description=dict(type='str'), description=dict(type='str'),
network=dict(required=True), network=dict(required=True, type='dict'),
bgp=dict( bgp=dict(
type='dict', type='dict',
options=dict( options=dict(

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a router facts - name: " a router facts"
gcp_compute_router_facts: gcp_compute_router_facts:
region: us-central1 region: us-central1
filters: filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -97,7 +97,7 @@ items:
description: description:
- A reference to the network to which this router belongs. - A reference to the network to which this router belongs.
returned: success returned: success
type: str type: dict
bgp: bgp:
description: description:
- BGP information specific to this router. - BGP information specific to this router.
@ -176,7 +176,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -216,7 +216,8 @@ def create(module, link, kind):
def update(module, link, kind): def update(module, link, kind):
module.fail_json(msg="SslCertificate cannot be edited") delete(module, self_link(module), kind)
create(module, collection(module), kind)
def delete(module, link, kind): def delete(module, link, kind):

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a ssl certificate facts - name: " a ssl certificate facts"
gcp_compute_ssl_certificate_facts: gcp_compute_ssl_certificate_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -125,7 +125,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -403,10 +403,10 @@ class SslPolicyWarningsArray(object):
return items return items
def _request_for_item(self, item): def _request_for_item(self, item):
return remove_nones_from_dict({u'code': item.get('code'), u'message': item.get('message')}) return remove_nones_from_dict({})
def _response_from_item(self, item): def _response_from_item(self, item):
return remove_nones_from_dict({u'code': item.get(u'code'), u'message': item.get(u'message')}) return remove_nones_from_dict({})
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a ssl policy facts - name: " a ssl policy facts"
gcp_compute_ssl_policy_facts: gcp_compute_ssl_policy_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -163,7 +163,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -89,9 +89,10 @@ options:
- The network this subnet belongs to. - The network this subnet belongs to.
- Only networks that are in the distributed mode can have subnetworks. - Only networks that are in the distributed mode can have subnetworks.
- 'This field represents a link to a Network resource in GCP. It can be specified - 'This field represents a link to a Network resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_network of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this network field to "{{ name-of-resource }}"' to a gcp_compute_network task and then set this network field to "{{ name-of-resource
}}"'
required: true required: true
enable_flow_logs: enable_flow_logs:
description: description:
@ -122,8 +123,8 @@ options:
required: true required: true
private_ip_google_access: private_ip_google_access:
description: description:
- Whether the VMs in this subnet can access Google services without assigned external - When enabled, VMs in this subnetwork without external IP addresses can access
IP addresses. Google APIs and services by using Private Google Access.
required: false required: false
type: bool type: bool
region: region:
@ -140,12 +141,12 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a network - name: create a network
gcp_compute_network: gcp_compute_network:
name: "network-subnetwork" name: network-subnetwork
auto_create_subnetworks: true auto_create_subnetworks: 'true'
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: network register: network
- name: create a subnetwork - name: create a subnetwork
@ -206,7 +207,7 @@ network:
- The network this subnet belongs to. - The network this subnet belongs to.
- Only networks that are in the distributed mode can have subnetworks. - Only networks that are in the distributed mode can have subnetworks.
returned: success returned: success
type: str type: dict
enableFlowLogs: enableFlowLogs:
description: description:
- Whether to enable flow logging for this subnetwork. - Whether to enable flow logging for this subnetwork.
@ -243,8 +244,8 @@ secondaryIpRanges:
type: str type: str
privateIpGoogleAccess: privateIpGoogleAccess:
description: description:
- Whether the VMs in this subnet can access Google services without assigned external - When enabled, VMs in this subnetwork without external IP addresses can access
IP addresses. Google APIs and services by using Private Google Access.
returned: success returned: success
type: bool type: bool
region: region:
@ -276,7 +277,7 @@ def main():
description=dict(type='str'), description=dict(type='str'),
ip_cidr_range=dict(required=True, type='str'), ip_cidr_range=dict(required=True, type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
network=dict(required=True), network=dict(required=True, type='dict'),
enable_flow_logs=dict(type='bool'), enable_flow_logs=dict(type='bool'),
secondary_ip_ranges=dict( secondary_ip_ranges=dict(
type='list', elements='dict', options=dict(range_name=dict(required=True, type='str'), ip_cidr_range=dict(required=True, type='str')) type='list', elements='dict', options=dict(range_name=dict(required=True, type='str'), ip_cidr_range=dict(required=True, type='str'))

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a subnetwork facts - name: " a subnetwork facts"
gcp_compute_subnetwork_facts: gcp_compute_subnetwork_facts:
region: us-west1 region: us-west1
filters: filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -114,7 +114,7 @@ items:
- The network this subnet belongs to. - The network this subnet belongs to.
- Only networks that are in the distributed mode can have subnetworks. - Only networks that are in the distributed mode can have subnetworks.
returned: success returned: success
type: str type: dict
enableFlowLogs: enableFlowLogs:
description: description:
- Whether to enable flow logging for this subnetwork. - Whether to enable flow logging for this subnetwork.
@ -152,8 +152,8 @@ items:
type: str type: str
privateIpGoogleAccess: privateIpGoogleAccess:
description: description:
- Whether the VMs in this subnet can access Google services without assigned - When enabled, VMs in this subnetwork without external IP addresses can access
external IP addresses. Google APIs and services by using Private Google Access.
returned: success returned: success
type: bool type: bool
region: region:
@ -185,7 +185,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -66,62 +66,63 @@ options:
- A reference to the UrlMap resource that defines the mapping from URL to the - A reference to the UrlMap resource that defines the mapping from URL to the
BackendService. BackendService.
- 'This field represents a link to a UrlMap resource in GCP. It can be specified - 'This field represents a link to a UrlMap resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_url_map of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this url_map field to "{{ name-of-resource }}"' to a gcp_compute_url_map task and then set this url_map field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetHttpProxies)' - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetHttpProxies)'
- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)' - 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: "instancegroup-targethttpproxy" name: instancegroup-targethttpproxy
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancegroup register: instancegroup
- name: create a http health check - name: create a http health check
gcp_compute_http_health_check: gcp_compute_http_health_check:
name: "httphealthcheck-targethttpproxy" name: httphealthcheck-targethttpproxy
healthy_threshold: 10 healthy_threshold: 10
port: 8080 port: 8080
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: healthcheck register: healthcheck
- name: create a backend service - name: create a backend service
gcp_compute_backend_service: gcp_compute_backend_service:
name: "backendservice-targethttpproxy" name: backendservice-targethttpproxy
backends: backends:
- group: "{{ instancegroup }}" - group: "{{ instancegroup }}"
health_checks: health_checks:
- "{{ healthcheck.selfLink }}" - "{{ healthcheck.selfLink }}"
enable_cdn: true enable_cdn: 'true'
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: backendservice register: backendservice
- name: create a url map - name: create a url map
gcp_compute_url_map: gcp_compute_url_map:
name: "urlmap-targethttpproxy" name: urlmap-targethttpproxy
default_service: "{{ backendservice }}" default_service: "{{ backendservice }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: urlmap register: urlmap
- name: create a target http proxy - name: create a target http proxy
@ -164,7 +165,7 @@ urlMap:
description: description:
- A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -188,7 +189,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
description=dict(type='str'), description=dict(type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
url_map=dict(required=True), url_map=dict(required=True, type='dict'),
) )
) )

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a target http proxy facts - name: " a target http proxy facts"
gcp_compute_target_http_proxy_facts: gcp_compute_target_http_proxy_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -94,7 +94,7 @@ items:
- A reference to the UrlMap resource that defines the mapping from URL to the - A reference to the UrlMap resource that defines the mapping from URL to the
BackendService. BackendService.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -119,7 +119,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -86,9 +86,10 @@ options:
resource. If not set, the TargetHttpsProxy resource will not have any SSL policy resource. If not set, the TargetHttpsProxy resource will not have any SSL policy
configured. configured.
- 'This field represents a link to a SslPolicy resource in GCP. It can be specified - 'This field represents a link to a SslPolicy resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_ssl_policy of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this ssl_policy field to "{{ name-of-resource }}"' to a gcp_compute_ssl_policy task and then set this ssl_policy field to "{{ name-of-resource
}}"'
required: false required: false
version_added: 2.8 version_added: 2.8
url_map: url_map:
@ -96,96 +97,85 @@ options:
- A reference to the UrlMap resource that defines the mapping from URL to the - A reference to the UrlMap resource that defines the mapping from URL to the
BackendService. BackendService.
- 'This field represents a link to a UrlMap resource in GCP. It can be specified - 'This field represents a link to a UrlMap resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_url_map of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this url_map field to "{{ name-of-resource }}"' to a gcp_compute_url_map task and then set this url_map field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetHttpsProxies)' - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetHttpsProxies)'
- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)' - 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: "instancegroup-targethttpsproxy" name: instancegroup-targethttpsproxy
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancegroup register: instancegroup
- name: create a http health check - name: create a http health check
gcp_compute_http_health_check: gcp_compute_http_health_check:
name: "httphealthcheck-targethttpsproxy" name: httphealthcheck-targethttpsproxy
healthy_threshold: 10 healthy_threshold: 10
port: 8080 port: 8080
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: healthcheck register: healthcheck
- name: create a backend service - name: create a backend service
gcp_compute_backend_service: gcp_compute_backend_service:
name: "backendservice-targethttpsproxy" name: backendservice-targethttpsproxy
backends: backends:
- group: "{{ instancegroup }}" - group: "{{ instancegroup }}"
health_checks: health_checks:
- "{{ healthcheck.selfLink }}" - "{{ healthcheck.selfLink }}"
enable_cdn: true enable_cdn: 'true'
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: backendservice register: backendservice
- name: create a url map - name: create a url map
gcp_compute_url_map: gcp_compute_url_map:
name: "urlmap-targethttpsproxy" name: urlmap-targethttpsproxy
default_service: "{{ backendservice }}" default_service: "{{ backendservice }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: urlmap register: urlmap
- name: create a ssl certificate - name: create a ssl certificate
gcp_compute_ssl_certificate: gcp_compute_ssl_certificate:
name: "sslcert-targethttpsproxy" name: sslcert-targethttpsproxy
description: A certificate for testing. Do not use this certificate in production description: A certificate for testing. Do not use this certificate in production
certificate: | certificate: "-----BEGIN CERTIFICATE----- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
-----BEGIN CERTIFICATE----- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ zqGNhIPGq2ULqXKK8BY=
BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM -----END CERTIFICATE-----"
FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z private_key: "-----BEGIN EC PRIVATE KEY----- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ -----END EC PRIVATE KEY-----"
4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O project: "{{ gcp_project }}"
BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn auth_kind: "{{ gcp_cred_kind }}"
0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O service_account_file: "{{ gcp_cred_file }}"
M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ state: present
zqGNhIPGq2ULqXKK8BY=
-----END CERTIFICATE-----
private_key: |
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
-----END EC PRIVATE KEY-----
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: sslcert register: sslcert
- name: create a target https proxy - name: create a target https proxy
@ -247,12 +237,12 @@ sslPolicy:
resource. If not set, the TargetHttpsProxy resource will not have any SSL policy resource. If not set, the TargetHttpsProxy resource will not have any SSL policy
configured. configured.
returned: success returned: success
type: str type: dict
urlMap: urlMap:
description: description:
- A reference to the UrlMap resource that defines the mapping from URL to the BackendService. - A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -277,9 +267,9 @@ def main():
description=dict(type='str'), description=dict(type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
quic_override=dict(type='str', choices=['NONE', 'ENABLE', 'DISABLE']), quic_override=dict(type='str', choices=['NONE', 'ENABLE', 'DISABLE']),
ssl_certificates=dict(required=True, type='list'), ssl_certificates=dict(required=True, type='list', elements='dict'),
ssl_policy=dict(), ssl_policy=dict(type='dict'),
url_map=dict(required=True), url_map=dict(required=True, type='dict'),
) )
) )

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a target https proxy facts - name: " a target https proxy facts"
gcp_compute_target_https_proxy_facts: gcp_compute_target_https_proxy_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -111,13 +111,13 @@ items:
resource. If not set, the TargetHttpsProxy resource will not have any SSL resource. If not set, the TargetHttpsProxy resource will not have any SSL
policy configured. policy configured.
returned: success returned: success
type: str type: dict
urlMap: urlMap:
description: description:
- A reference to the UrlMap resource that defines the mapping from URL to the - A reference to the UrlMap resource that defines the mapping from URL to the
BackendService. BackendService.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -142,7 +142,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -61,9 +61,10 @@ options:
pool in the "force" mode, where traffic will be spread to the healthy instances pool in the "force" mode, where traffic will be spread to the healthy instances
with the best effort, or to all instances when no instance is healthy. with the best effort, or to all instances when no instance is healthy.
- 'This field represents a link to a TargetPool resource in GCP. It can be specified - 'This field represents a link to a TargetPool resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_target_pool of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this backup_pool field to "{{ name-of-resource }}"' to a gcp_compute_target_pool task and then set this backup_pool field to "{{
name-of-resource }}"'
required: false required: false
description: description:
description: description:
@ -90,10 +91,10 @@ options:
checks pass. If not specified it means all member instances will be considered checks pass. If not specified it means all member instances will be considered
healthy at all times. healthy at all times.
- 'This field represents a link to a HttpHealthCheck resource in GCP. It can be - 'This field represents a link to a HttpHealthCheck resource in GCP. It can be
specified in two ways. First, you can place in the selfLink of the resource specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` to and value of your resource''s selfLink Alternatively, you can add `register:
a gcp_compute_http_health_check task and then set this health_check field to name-of-resource` to a gcp_compute_http_health_check task and then set this
"{{ name-of-resource }}"' health_check field to "{{ name-of-resource }}"'
required: false required: false
instances: instances:
description: description:
@ -158,7 +159,7 @@ backupPool:
pool in the "force" mode, where traffic will be spread to the healthy instances pool in the "force" mode, where traffic will be spread to the healthy instances
with the best effort, or to all instances when no instance is healthy. with the best effort, or to all instances when no instance is healthy.
returned: success returned: success
type: str type: dict
creationTimestamp: creationTimestamp:
description: description:
- Creation timestamp in RFC3339 text format. - Creation timestamp in RFC3339 text format.
@ -191,7 +192,7 @@ healthCheck:
checks pass. If not specified it means all member instances will be considered checks pass. If not specified it means all member instances will be considered
healthy at all times. healthy at all times.
returned: success returned: success
type: str type: dict
id: id:
description: description:
- The unique identifier for the resource. - The unique identifier for the resource.
@ -249,11 +250,11 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
backup_pool=dict(), backup_pool=dict(type='dict'),
description=dict(type='str'), description=dict(type='str'),
failover_ratio=dict(type='str'), failover_ratio=dict(type='str'),
health_check=dict(), health_check=dict(type='dict'),
instances=dict(type='list'), instances=dict(type='list', elements='dict'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'CLIENT_IP_PROTO']), session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'CLIENT_IP_PROTO']),
region=dict(required=True, type='str'), region=dict(required=True, type='str'),

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a target pool facts - name: " a target pool facts"
gcp_compute_target_pool_facts: gcp_compute_target_pool_facts:
region: us-west1 region: us-west1
filters: filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -83,7 +83,7 @@ items:
primary pool in the "force" mode, where traffic will be spread to the healthy primary pool in the "force" mode, where traffic will be spread to the healthy
instances with the best effort, or to all instances when no instance is healthy. instances with the best effort, or to all instances when no instance is healthy.
returned: success returned: success
type: str type: dict
creationTimestamp: creationTimestamp:
description: description:
- Creation timestamp in RFC3339 text format. - Creation timestamp in RFC3339 text format.
@ -116,7 +116,7 @@ items:
checks pass. If not specified it means all member instances will be considered checks pass. If not specified it means all member instances will be considered
healthy at all times. healthy at all times.
returned: success returned: success
type: str type: dict
id: id:
description: description:
- The unique identifier for the resource. - The unique identifier for the resource.
@ -177,7 +177,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -73,10 +73,10 @@ options:
description: description:
- A reference to the BackendService resource. - A reference to the BackendService resource.
- 'This field represents a link to a BackendService resource in GCP. It can be - 'This field represents a link to a BackendService resource in GCP. It can be
specified in two ways. First, you can place in the selfLink of the resource specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` to and value of your resource''s selfLink Alternatively, you can add `register:
a gcp_compute_backend_service task and then set this service field to "{{ name-of-resource name-of-resource` to a gcp_compute_backend_service task and then set this service
}}"' field to "{{ name-of-resource }}"'
required: true required: true
ssl_certificates: ssl_certificates:
description: description:
@ -90,91 +90,80 @@ options:
resource. If not set, the TargetSslProxy resource will not have any SSL policy resource. If not set, the TargetSslProxy resource will not have any SSL policy
configured. configured.
- 'This field represents a link to a SslPolicy resource in GCP. It can be specified - 'This field represents a link to a SslPolicy resource in GCP. It can be specified
in two ways. First, you can place in the selfLink of the resource here as a in two ways. First, you can place a dictionary with key ''selfLink'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_ssl_policy of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
task and then set this ssl_policy field to "{{ name-of-resource }}"' to a gcp_compute_ssl_policy task and then set this ssl_policy field to "{{ name-of-resource
}}"'
required: false required: false
version_added: 2.8 version_added: 2.8
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetSslProxies)' - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetSslProxies)'
- 'Setting Up SSL proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/)' - 'Setting Up SSL proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: "instancegroup-targetsslproxy" name: instancegroup-targetsslproxy
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancegroup register: instancegroup
- name: create a health check - name: create a health check
gcp_compute_health_check: gcp_compute_health_check:
name: "healthcheck-targetsslproxy" name: healthcheck-targetsslproxy
type: TCP type: TCP
tcp_health_check: tcp_health_check:
port_name: service-health port_name: service-health
request: ping request: ping
response: pong response: pong
healthy_threshold: 10 healthy_threshold: 10
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: healthcheck register: healthcheck
- name: create a backend service - name: create a backend service
gcp_compute_backend_service: gcp_compute_backend_service:
name: "backendservice-targetsslproxy" name: backendservice-targetsslproxy
backends: backends:
- group: "{{ instancegroup }}" - group: "{{ instancegroup }}"
health_checks: health_checks:
- "{{ healthcheck.selfLink }}" - "{{ healthcheck.selfLink }}"
protocol: SSL protocol: SSL
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: backendservice register: backendservice
- name: create a ssl certificate - name: create a ssl certificate
gcp_compute_ssl_certificate: gcp_compute_ssl_certificate:
name: "sslcert-targetsslproxy" name: sslcert-targetsslproxy
description: A certificate for testing. Do not use this certificate in production description: A certificate for testing. Do not use this certificate in production
certificate: | certificate: "-----BEGIN CERTIFICATE----- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
-----BEGIN CERTIFICATE----- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ zqGNhIPGq2ULqXKK8BY=
BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM -----END CERTIFICATE-----"
FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z private_key: "-----BEGIN EC PRIVATE KEY----- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ -----END EC PRIVATE KEY-----"
4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O project: "{{ gcp_project }}"
BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn auth_kind: "{{ gcp_cred_kind }}"
0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O service_account_file: "{{ gcp_cred_file }}"
M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ state: present
zqGNhIPGq2ULqXKK8BY=
-----END CERTIFICATE-----
private_key: |
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
-----END EC PRIVATE KEY-----
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: sslcert register: sslcert
- name: create a target ssl proxy - name: create a target ssl proxy
@ -225,7 +214,7 @@ service:
description: description:
- A reference to the BackendService resource. - A reference to the BackendService resource.
returned: success returned: success
type: str type: dict
sslCertificates: sslCertificates:
description: description:
- A list of SslCertificate resources that are used to authenticate connections between - A list of SslCertificate resources that are used to authenticate connections between
@ -238,7 +227,7 @@ sslPolicy:
resource. If not set, the TargetSslProxy resource will not have any SSL policy resource. If not set, the TargetSslProxy resource will not have any SSL policy
configured. configured.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -263,9 +252,9 @@ def main():
description=dict(type='str'), description=dict(type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']), proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
service=dict(required=True), service=dict(required=True, type='dict'),
ssl_certificates=dict(required=True, type='list'), ssl_certificates=dict(required=True, type='list', elements='dict'),
ssl_policy=dict(), ssl_policy=dict(type='dict'),
) )
) )

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a target ssl proxy facts - name: " a target ssl proxy facts"
gcp_compute_target_ssl_proxy_facts: gcp_compute_target_ssl_proxy_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -99,7 +99,7 @@ items:
description: description:
- A reference to the BackendService resource. - A reference to the BackendService resource.
returned: success returned: success
type: str type: dict
sslCertificates: sslCertificates:
description: description:
- A list of SslCertificate resources that are used to authenticate connections - A list of SslCertificate resources that are used to authenticate connections
@ -113,7 +113,7 @@ items:
resource. If not set, the TargetSslProxy resource will not have any SSL policy resource. If not set, the TargetSslProxy resource will not have any SSL policy
configured. configured.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -138,7 +138,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -73,57 +73,57 @@ options:
description: description:
- A reference to the BackendService resource. - A reference to the BackendService resource.
- 'This field represents a link to a BackendService resource in GCP. It can be - 'This field represents a link to a BackendService resource in GCP. It can be
specified in two ways. First, you can place in the selfLink of the resource specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` to and value of your resource''s selfLink Alternatively, you can add `register:
a gcp_compute_backend_service task and then set this service field to "{{ name-of-resource name-of-resource` to a gcp_compute_backend_service task and then set this service
}}"' field to "{{ name-of-resource }}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetTcpProxies)' - 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetTcpProxies)'
- 'Setting Up TCP proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/tcp-proxy)' - 'Setting Up TCP proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/tcp-proxy)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: "instancegroup-targettcpproxy" name: instancegroup-targettcpproxy
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancegroup register: instancegroup
- name: create a health check - name: create a health check
gcp_compute_health_check: gcp_compute_health_check:
name: "healthcheck-targettcpproxy" name: healthcheck-targettcpproxy
type: TCP type: TCP
tcp_health_check: tcp_health_check:
port_name: service-health port_name: service-health
request: ping request: ping
response: pong response: pong
healthy_threshold: 10 healthy_threshold: 10
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: healthcheck register: healthcheck
- name: create a backend service - name: create a backend service
gcp_compute_backend_service: gcp_compute_backend_service:
name: "backendservice-targettcpproxy" name: backendservice-targettcpproxy
backends: backends:
- group: "{{ instancegroup }}" - group: "{{ instancegroup }}"
health_checks: health_checks:
- "{{ healthcheck.selfLink }}" - "{{ healthcheck.selfLink }}"
protocol: TCP protocol: TCP
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: backendservice register: backendservice
- name: create a target tcp proxy - name: create a target tcp proxy
@ -173,7 +173,7 @@ service:
description: description:
- A reference to the BackendService resource. - A reference to the BackendService resource.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -198,7 +198,7 @@ def main():
description=dict(type='str'), description=dict(type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']), proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
service=dict(required=True), service=dict(required=True, type='dict'),
) )
) )

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a target tcp proxy facts - name: " a target tcp proxy facts"
gcp_compute_target_tcp_proxy_facts: gcp_compute_target_tcp_proxy_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -99,7 +99,7 @@ items:
description: description:
- A reference to the BackendService resource. - A reference to the BackendService resource.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -124,7 +124,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -101,13 +101,13 @@ EXAMPLES = '''
- name: create a target vpn gateway - name: create a target vpn gateway
gcp_compute_target_vpn_gateway: gcp_compute_target_vpn_gateway:
name: test_object name: "test_object"
region: us-west1 region: us-west1
network: "{{ network }}" network: "{{ network }}"
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a target vpn gateway facts - name: " a target vpn gateway facts"
gcp_compute_target_vpn_gateway_facts: gcp_compute_target_vpn_gateway_facts:
region: us-west1 region: us-west1
filters: filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -98,7 +98,7 @@ items:
description: description:
- The network this VPN gateway is accepting traffic for. - The network this VPN gateway is accepting traffic for.
returned: success returned: success
type: str type: dict
tunnels: tunnels:
description: description:
- A list of references to VpnTunnel resources associated with this VPN gateway. - A list of references to VpnTunnel resources associated with this VPN gateway.
@ -139,7 +139,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -52,10 +52,10 @@ options:
description: description:
- A reference to BackendService resource if none of the hostRules match. - A reference to BackendService resource if none of the hostRules match.
- 'This field represents a link to a BackendService resource in GCP. It can be - 'This field represents a link to a BackendService resource in GCP. It can be
specified in two ways. First, you can place in the selfLink of the resource specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` to and value of your resource''s selfLink Alternatively, you can add `register:
a gcp_compute_backend_service task and then set this default_service field to name-of-resource` to a gcp_compute_backend_service task and then set this default_service
"{{ name-of-resource }}"' field to "{{ name-of-resource }}"'
required: true required: true
description: description:
description: description:
@ -102,10 +102,10 @@ options:
- A reference to a BackendService resource. This will be used if none of the - A reference to a BackendService resource. This will be used if none of the
pathRules defined by this PathMatcher is matched by the URL's path portion. pathRules defined by this PathMatcher is matched by the URL's path portion.
- 'This field represents a link to a BackendService resource in GCP. It can - 'This field represents a link to a BackendService resource in GCP. It can
be specified in two ways. First, you can place in the selfLink of the resource be specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` and value of your resource''s selfLink Alternatively, you can add `register:
to a gcp_compute_backend_service task and then set this default_service name-of-resource` to a gcp_compute_backend_service task and then set this
field to "{{ name-of-resource }}"' default_service field to "{{ name-of-resource }}"'
required: true required: true
description: description:
description: description:
@ -131,10 +131,10 @@ options:
description: description:
- A reference to the BackendService resource if this rule is matched. - A reference to the BackendService resource if this rule is matched.
- 'This field represents a link to a BackendService resource in GCP. It - 'This field represents a link to a BackendService resource in GCP. It
can be specified in two ways. First, you can place in the selfLink of can be specified in two ways. First, you can place a dictionary with
the resource here as a string Alternatively, you can add `register: key ''selfLink'' and value of your resource''s selfLink Alternatively,
name-of-resource` to a gcp_compute_backend_service task and then set you can add `register: name-of-resource` to a gcp_compute_backend_service
this service field to "{{ name-of-resource }}"' task and then set this service field to "{{ name-of-resource }}"'
required: true required: true
tests: tests:
description: description:
@ -159,10 +159,10 @@ options:
- A reference to expected BackendService resource the given URL should be - A reference to expected BackendService resource the given URL should be
mapped to. mapped to.
- 'This field represents a link to a BackendService resource in GCP. It can - 'This field represents a link to a BackendService resource in GCP. It can
be specified in two ways. First, you can place in the selfLink of the resource be specified in two ways. First, you can place a dictionary with key ''selfLink''
here as a string Alternatively, you can add `register: name-of-resource` and value of your resource''s selfLink Alternatively, you can add `register:
to a gcp_compute_backend_service task and then set this service field to name-of-resource` to a gcp_compute_backend_service task and then set this
"{{ name-of-resource }}"' service field to "{{ name-of-resource }}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -170,39 +170,39 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance group - name: create a instance group
gcp_compute_instance_group: gcp_compute_instance_group:
name: "instancegroup-urlmap" name: instancegroup-urlmap
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instancegroup register: instancegroup
- name: create a http health check - name: create a http health check
gcp_compute_http_health_check: gcp_compute_http_health_check:
name: "httphealthcheck-urlmap" name: httphealthcheck-urlmap
healthy_threshold: 10 healthy_threshold: 10
port: 8080 port: 8080
timeout_sec: 2 timeout_sec: 2
unhealthy_threshold: 5 unhealthy_threshold: 5
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: healthcheck register: healthcheck
- name: create a backend service - name: create a backend service
gcp_compute_backend_service: gcp_compute_backend_service:
name: "backendservice-urlmap" name: backendservice-urlmap
backends: backends:
- group: "{{ instancegroup }}" - group: "{{ instancegroup }}"
health_checks: health_checks:
- "{{ healthcheck.selfLink }}" - "{{ healthcheck.selfLink }}"
enable_cdn: true enable_cdn: 'true'
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: backendservice register: backendservice
- name: create a url map - name: create a url map
@ -225,7 +225,7 @@ defaultService:
description: description:
- A reference to BackendService resource if none of the hostRules match. - A reference to BackendService resource if none of the hostRules match.
returned: success returned: success
type: str type: dict
description: description:
description: description:
- An optional description of this resource. Provide this property when you create - An optional description of this resource. Provide this property when you create
@ -289,7 +289,7 @@ pathMatchers:
- A reference to a BackendService resource. This will be used if none of the - A reference to a BackendService resource. This will be used if none of the
pathRules defined by this PathMatcher is matched by the URL's path portion. pathRules defined by this PathMatcher is matched by the URL's path portion.
returned: success returned: success
type: str type: dict
description: description:
description: description:
- An optional description of this resource. - An optional description of this resource.
@ -318,7 +318,7 @@ pathMatchers:
description: description:
- A reference to the BackendService resource if this rule is matched. - A reference to the BackendService resource if this rule is matched.
returned: success returned: success
type: str type: dict
tests: tests:
description: description:
- The list of expected URL mappings. Requests to update this UrlMap will succeed - The list of expected URL mappings. Requests to update this UrlMap will succeed
@ -346,7 +346,7 @@ tests:
- A reference to expected BackendService resource the given URL should be mapped - A reference to expected BackendService resource the given URL should be mapped
to. to.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -368,7 +368,7 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
default_service=dict(required=True), default_service=dict(required=True, type='dict'),
description=dict(type='str'), description=dict(type='str'),
host_rules=dict( host_rules=dict(
type='list', type='list',
@ -382,11 +382,13 @@ def main():
type='list', type='list',
elements='dict', elements='dict',
options=dict( options=dict(
default_service=dict(required=True), default_service=dict(required=True, type='dict'),
description=dict(type='str'), description=dict(type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
path_rules=dict( path_rules=dict(
type='list', elements='dict', options=dict(paths=dict(required=True, type='list', elements='str'), service=dict(required=True)) type='list',
elements='dict',
options=dict(paths=dict(required=True, type='list', elements='str'), service=dict(required=True, type='dict')),
), ),
), ),
), ),
@ -394,7 +396,10 @@ def main():
type='list', type='list',
elements='dict', elements='dict',
options=dict( options=dict(
description=dict(type='str'), host=dict(required=True, type='str'), path=dict(required=True, type='str'), service=dict(required=True) description=dict(type='str'),
host=dict(required=True, type='str'),
path=dict(required=True, type='str'),
service=dict(required=True, type='dict'),
), ),
), ),
) )

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a url map facts - name: " a url map facts"
gcp_compute_url_map_facts: gcp_compute_url_map_facts:
filters: filters:
- name = test_object - name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -73,7 +73,7 @@ items:
description: description:
- A reference to BackendService resource if none of the hostRules match. - A reference to BackendService resource if none of the hostRules match.
returned: success returned: success
type: str type: dict
description: description:
description: description:
- An optional description of this resource. Provide this property when you create - An optional description of this resource. Provide this property when you create
@ -138,7 +138,7 @@ items:
the pathRules defined by this PathMatcher is matched by the URL's path the pathRules defined by this PathMatcher is matched by the URL's path
portion. portion.
returned: success returned: success
type: str type: dict
description: description:
description: description:
- An optional description of this resource. - An optional description of this resource.
@ -167,7 +167,7 @@ items:
description: description:
- A reference to the BackendService resource if this rule is matched. - A reference to the BackendService resource if this rule is matched.
returned: success returned: success
type: str type: dict
tests: tests:
description: description:
- The list of expected URL mappings. Requests to update this UrlMap will succeed - The list of expected URL mappings. Requests to update this UrlMap will succeed
@ -195,7 +195,7 @@ items:
- A reference to expected BackendService resource the given URL should be - A reference to expected BackendService resource the given URL should be
mapped to. mapped to.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -220,7 +220,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -159,15 +159,15 @@ EXAMPLES = '''
- name: create a vpn tunnel - name: create a vpn tunnel
gcp_compute_vpn_tunnel: gcp_compute_vpn_tunnel:
name: test_object name: "test_object"
region: us-west1 region: us-west1
target_vpn_gateway: "{{ gateway }}" target_vpn_gateway: "{{ gateway }}"
router: "{{ router }}" router: "{{ router }}"
shared_secret: super secret shared_secret: super secret
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -55,13 +55,12 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: " a vpn tunnel facts" - name: " a vpn tunnel facts"
gcp_compute_vpn_tunnel_facts: gcp_compute_vpn_tunnel_facts:
region: us-west1 region: us-west1
filters: filters:
- name = test_object - name = test_object
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -170,20 +170,6 @@ options:
Because the master endpoint is open to the Internet, you should create a Because the master endpoint is open to the Internet, you should create a
strong password. strong password.
required: false required: false
cluster_ca_certificate:
description:
- Base64-encoded public certificate that is the root of trust for the cluster.
required: false
client_certificate:
description:
- Base64-encoded public certificate used by clients to authenticate to the
cluster endpoint.
required: false
client_key:
description:
- Base64-encoded private key used by clients to authenticate to the cluster
endpoint.
required: false
logging_service: logging_service:
description: description:
- 'The logging service the cluster should use to write logs. Currently available - 'The logging service the cluster should use to write logs. Currently available
@ -210,6 +196,31 @@ options:
- The name of the Google Compute Engine network to which the cluster is connected. - The name of the Google Compute Engine network to which the cluster is connected.
If left unspecified, the default network will be used. If left unspecified, the default network will be used.
required: false required: false
private_cluster_config:
description:
- Configuration for a private cluster.
required: false
version_added: 2.8
suboptions:
enable_private_nodes:
description:
- Whether nodes have internal IP addresses only. If enabled, all nodes are
given only RFC 1918 private addresses and communicate with the master via
private networking.
required: false
type: bool
enable_private_endpoint:
description:
- Whether the master's internal IP address is used as the cluster endpoint.
required: false
type: bool
master_ipv4_cidr_block:
description:
- The IP range in CIDR notation to use for the hosted master network. This
range will be used for assigning internal IP addresses to the master or
set of masters, as well as the ILB VIP. This range must not overlap with
any other ranges in use within the cluster's network.
required: false
cluster_ipv4_cidr: cluster_ipv4_cidr:
description: description:
- The IP address range of the container pods in this cluster, in CIDR notation - The IP address range of the container pods in this cluster, in CIDR notation
@ -265,7 +276,7 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a cluster - name: create a cluster
gcp_container_cluster: gcp_container_cluster:
name: my-cluster name: "test_object"
initial_node_count: 2 initial_node_count: 2
master_auth: master_auth:
username: cluster_admin username: cluster_admin
@ -273,7 +284,7 @@ EXAMPLES = '''
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
location: us-central1-a zone: us-central1-a
project: "test_project" project: "test_project"
auth_kind: "serviceaccount" auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
@ -459,6 +470,42 @@ network:
If left unspecified, the default network will be used. If left unspecified, the default network will be used.
returned: success returned: success
type: str type: str
privateClusterConfig:
description:
- Configuration for a private cluster.
returned: success
type: complex
contains:
enablePrivateNodes:
description:
- Whether nodes have internal IP addresses only. If enabled, all nodes are given
only RFC 1918 private addresses and communicate with the master via private
networking.
returned: success
type: bool
enablePrivateEndpoint:
description:
- Whether the master's internal IP address is used as the cluster endpoint.
returned: success
type: bool
masterIpv4CidrBlock:
description:
- The IP range in CIDR notation to use for the hosted master network. This range
will be used for assigning internal IP addresses to the master or set of masters,
as well as the ILB VIP. This range must not overlap with any other ranges
in use within the cluster's network.
returned: success
type: str
privateEndpoint:
description:
- The internal IP address of this cluster's master endpoint.
returned: success
type: str
publicEndpoint:
description:
- The external IP address of this cluster's master endpoint.
returned: success
type: str
clusterIpv4Cidr: clusterIpv4Cidr:
description: description:
- The IP address range of the container pods in this cluster, in CIDR notation (e.g. - The IP address range of the container pods in this cluster, in CIDR notation (e.g.
@ -603,19 +650,14 @@ def main():
preemptible=dict(type='bool'), preemptible=dict(type='bool'),
), ),
), ),
master_auth=dict( master_auth=dict(type='dict', options=dict(username=dict(type='str'), password=dict(type='str'))),
type='dict',
options=dict(
username=dict(type='str'),
password=dict(type='str'),
cluster_ca_certificate=dict(type='str'),
client_certificate=dict(type='str'),
client_key=dict(type='str'),
),
),
logging_service=dict(type='str', choices=['logging.googleapis.com', 'none']), logging_service=dict(type='str', choices=['logging.googleapis.com', 'none']),
monitoring_service=dict(type='str', choices=['monitoring.googleapis.com', 'none']), monitoring_service=dict(type='str', choices=['monitoring.googleapis.com', 'none']),
network=dict(type='str'), network=dict(type='str'),
private_cluster_config=dict(
type='dict',
options=dict(enable_private_nodes=dict(type='bool'), enable_private_endpoint=dict(type='bool'), master_ipv4_cidr_block=dict(type='str')),
),
cluster_ipv4_cidr=dict(type='str'), cluster_ipv4_cidr=dict(type='str'),
addons_config=dict( addons_config=dict(
type='dict', type='dict',
@ -684,6 +726,7 @@ def resource_to_request(module):
u'loggingService': module.params.get('logging_service'), u'loggingService': module.params.get('logging_service'),
u'monitoringService': module.params.get('monitoring_service'), u'monitoringService': module.params.get('monitoring_service'),
u'network': module.params.get('network'), u'network': module.params.get('network'),
u'privateClusterConfig': ClusterPrivateclusterconfig(module.params.get('private_cluster_config', {}), module).to_request(),
u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'), u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'),
u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(), u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(),
u'subnetwork': module.params.get('subnetwork'), u'subnetwork': module.params.get('subnetwork'),
@ -761,6 +804,7 @@ def response_to_hash(module, response):
u'loggingService': response.get(u'loggingService'), u'loggingService': response.get(u'loggingService'),
u'monitoringService': response.get(u'monitoringService'), u'monitoringService': response.get(u'monitoringService'),
u'network': response.get(u'network'), u'network': response.get(u'network'),
u'privateClusterConfig': ClusterPrivateclusterconfig(response.get(u'privateClusterConfig', {}), module).from_response(),
u'clusterIpv4Cidr': response.get(u'clusterIpv4Cidr'), u'clusterIpv4Cidr': response.get(u'clusterIpv4Cidr'),
u'addonsConfig': ClusterAddonsconfig(response.get(u'addonsConfig', {}), module).from_response(), u'addonsConfig': ClusterAddonsconfig(response.get(u'addonsConfig', {}), module).from_response(),
u'subnetwork': response.get(u'subnetwork'), u'subnetwork': response.get(u'subnetwork'),
@ -874,25 +918,36 @@ class ClusterMasterauth(object):
else: else:
self.request = {} self.request = {}
def to_request(self):
return remove_nones_from_dict({u'username': self.request.get('username'), u'password': self.request.get('password')})
def from_response(self):
return remove_nones_from_dict({u'username': self.request.get(u'username'), u'password': self.request.get(u'password')})
class ClusterPrivateclusterconfig(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict( return remove_nones_from_dict(
{ {
u'username': self.request.get('username'), u'enablePrivateNodes': self.request.get('enable_private_nodes'),
u'password': self.request.get('password'), u'enablePrivateEndpoint': self.request.get('enable_private_endpoint'),
u'clusterCaCertificate': self.request.get('cluster_ca_certificate'), u'masterIpv4CidrBlock': self.request.get('master_ipv4_cidr_block'),
u'clientCertificate': self.request.get('client_certificate'),
u'clientKey': self.request.get('client_key'),
} }
) )
def from_response(self): def from_response(self):
return remove_nones_from_dict( return remove_nones_from_dict(
{ {
u'username': self.request.get(u'username'), u'enablePrivateNodes': self.request.get(u'enablePrivateNodes'),
u'password': self.request.get(u'password'), u'enablePrivateEndpoint': self.request.get(u'enablePrivateEndpoint'),
u'clusterCaCertificate': self.request.get(u'clusterCaCertificate'), u'masterIpv4CidrBlock': self.request.get(u'masterIpv4CidrBlock'),
u'clientCertificate': self.request.get(u'clientCertificate'),
u'clientKey': self.request.get(u'clientKey'),
} }
) )

View file

@ -52,12 +52,13 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a cluster facts - name: " a cluster facts"
gcp_container_cluster_facts: gcp_container_cluster_facts:
location: us-central1-a location: us-central1-a
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -245,6 +246,42 @@ items:
If left unspecified, the default network will be used. If left unspecified, the default network will be used.
returned: success returned: success
type: str type: str
privateClusterConfig:
description:
- Configuration for a private cluster.
returned: success
type: complex
contains:
enablePrivateNodes:
description:
- Whether nodes have internal IP addresses only. If enabled, all nodes are
given only RFC 1918 private addresses and communicate with the master
via private networking.
returned: success
type: bool
enablePrivateEndpoint:
description:
- Whether the master's internal IP address is used as the cluster endpoint.
returned: success
type: bool
masterIpv4CidrBlock:
description:
- The IP range in CIDR notation to use for the hosted master network. This
range will be used for assigning internal IP addresses to the master or
set of masters, as well as the ILB VIP. This range must not overlap with
any other ranges in use within the cluster's network.
returned: success
type: str
privateEndpoint:
description:
- The internal IP address of this cluster's master endpoint.
returned: success
type: str
publicEndpoint:
description:
- The external IP address of this cluster's master endpoint.
returned: success
type: str
clusterIpv4Cidr: clusterIpv4Cidr:
description: description:
- The IP address range of the container pods in this cluster, in CIDR notation - The IP address range of the container pods in this cluster, in CIDR notation

View file

@ -144,6 +144,11 @@ options:
resource quota is sufficient for this number of instances. You must also have resource quota is sufficient for this number of instances. You must also have
available firewall and routes quota. available firewall and routes quota.
required: true required: true
version:
description:
- The version of the Kubernetes of this node.
required: false
version_added: 2.8
autoscaling: autoscaling:
description: description:
- Autoscaler configuration for this NodePool. Autoscaler is enabled only if a - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a
@ -188,24 +193,15 @@ options:
description: description:
- Specifies the Auto Upgrade knobs for the node pool. - Specifies the Auto Upgrade knobs for the node pool.
required: false required: false
suboptions: suboptions: {}
auto_upgrade_start_time:
description:
- This field is set when upgrades are about to commence with the approximate
start time for the upgrades, in RFC3339 text format.
required: false
description:
description:
- This field is set when upgrades are about to commence with the description
of the upgrade.
required: false
cluster: cluster:
description: description:
- The cluster this node pool belongs to. - The cluster this node pool belongs to.
- 'This field represents a link to a Cluster resource in GCP. It can be specified - 'This field represents a link to a Cluster resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_container_cluster your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this cluster field to "{{ name-of-resource }}"' to a gcp_container_cluster task and then set this cluster field to "{{ name-of-resource
}}"'
required: true required: true
location: location:
description: description:
@ -221,21 +217,21 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a cluster - name: create a cluster
gcp_container_cluster: gcp_container_cluster:
name: "cluster-nodepool" name: cluster-nodepool
initial_node_count: 4 initial_node_count: 4
location: us-central1-a location: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: cluster register: cluster
- name: create a node pool - name: create a node pool
gcp_container_node_pool: gcp_container_node_pool:
name: my-pool name: "test_object"
initial_node_count: 4 initial_node_count: 4
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a zone: us-central1-a
project: "test_project" project: "test_project"
auth_kind: "serviceaccount" auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
@ -418,7 +414,7 @@ cluster:
description: description:
- The cluster this node pool belongs to. - The cluster this node pool belongs to.
returned: success returned: success
type: str type: dict
location: location:
description: description:
- The location where the node pool is deployed. - The location where the node pool is deployed.
@ -462,16 +458,12 @@ def main():
), ),
), ),
initial_node_count=dict(required=True, type='int'), initial_node_count=dict(required=True, type='int'),
version=dict(type='str'),
autoscaling=dict(type='dict', options=dict(enabled=dict(type='bool'), min_node_count=dict(type='int'), max_node_count=dict(type='int'))), autoscaling=dict(type='dict', options=dict(enabled=dict(type='bool'), min_node_count=dict(type='int'), max_node_count=dict(type='int'))),
management=dict( management=dict(
type='dict', type='dict', options=dict(auto_upgrade=dict(type='bool'), auto_repair=dict(type='bool'), upgrade_options=dict(type='dict', options=dict()))
options=dict(
auto_upgrade=dict(type='bool'),
auto_repair=dict(type='bool'),
upgrade_options=dict(type='dict', options=dict(auto_upgrade_start_time=dict(type='str'), description=dict(type='str'))),
),
), ),
cluster=dict(required=True), cluster=dict(required=True, type='dict'),
location=dict(required=True, type='str', aliases=['region', 'zone']), location=dict(required=True, type='str', aliases=['region', 'zone']),
) )
) )
@ -526,6 +518,7 @@ def resource_to_request(module):
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'config': NodePoolConfig(module.params.get('config', {}), module).to_request(), u'config': NodePoolConfig(module.params.get('config', {}), module).to_request(),
u'initialNodeCount': module.params.get('initial_node_count'), u'initialNodeCount': module.params.get('initial_node_count'),
u'version': module.params.get('version'),
u'autoscaling': NodePoolAutoscaling(module.params.get('autoscaling', {}), module).to_request(), u'autoscaling': NodePoolAutoscaling(module.params.get('autoscaling', {}), module).to_request(),
u'management': NodePoolManagement(module.params.get('management', {}), module).to_request(), u'management': NodePoolManagement(module.params.get('management', {}), module).to_request(),
} }
@ -604,7 +597,7 @@ def response_to_hash(module, response):
u'name': response.get(u'name'), u'name': response.get(u'name'),
u'config': NodePoolConfig(response.get(u'config', {}), module).from_response(), u'config': NodePoolConfig(response.get(u'config', {}), module).from_response(),
u'initialNodeCount': module.params.get('initial_node_count'), u'initialNodeCount': module.params.get('initial_node_count'),
u'version': response.get(u'version'), u'version': module.params.get('version'),
u'autoscaling': NodePoolAutoscaling(response.get(u'autoscaling', {}), module).from_response(), u'autoscaling': NodePoolAutoscaling(response.get(u'autoscaling', {}), module).from_response(),
u'management': NodePoolManagement(response.get(u'management', {}), module).from_response(), u'management': NodePoolManagement(response.get(u'management', {}), module).from_response(),
} }
@ -755,10 +748,10 @@ class NodePoolUpgradeoptions(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'autoUpgradeStartTime': self.request.get('auto_upgrade_start_time'), u'description': self.request.get('description')}) return remove_nones_from_dict({})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'autoUpgradeStartTime': self.request.get(u'autoUpgradeStartTime'), u'description': self.request.get(u'description')}) return remove_nones_from_dict({})
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -52,21 +52,23 @@ options:
description: description:
- The cluster this node pool belongs to. - The cluster this node pool belongs to.
- 'This field represents a link to a Cluster resource in GCP. It can be specified - 'This field represents a link to a Cluster resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_container_cluster your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this cluster field to "{{ name-of-resource }}"' to a gcp_container_cluster task and then set this cluster field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a node pool facts - name: " a node pool facts"
gcp_container_node_pool_facts: gcp_container_node_pool_facts:
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a location: us-central1-a
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -251,7 +253,7 @@ items:
description: description:
- The cluster this node pool belongs to. - The cluster this node pool belongs to.
returned: success returned: success
type: str type: dict
location: location:
description: description:
- The location where the node pool is deployed. - The location where the node pool is deployed.
@ -271,7 +273,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone']), cluster=dict(required=True))) module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone']), cluster=dict(required=True, type='dict')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform'] module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']

View file

@ -73,6 +73,35 @@ options:
- A set of key/value label pairs to assign to this ManagedZone. - A set of key/value label pairs to assign to this ManagedZone.
required: false required: false
version_added: 2.8 version_added: 2.8
visibility:
description:
- 'The zone''s visibility: public zones are exposed to the Internet, while private
zones are visible only to Virtual Private Cloud resources.'
- 'Must be one of: `public`, `private`.'
required: false
default: public
version_added: 2.8
choices:
- private
- public
private_visibility_config:
description:
- For privately visible zones, the set of Virtual Private Cloud resources that
the zone is visible from.
required: false
version_added: 2.8
suboptions:
networks:
description:
- The list of VPC networks that can see this zone.
required: false
suboptions:
network_url:
description:
- The fully qualified URL of the VPC network to bind to.
- This should be formatted like `U(https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`)
.
required: false
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
- 'API Reference: U(https://cloud.google.com/dns/api/v1/managedZones)' - 'API Reference: U(https://cloud.google.com/dns/api/v1/managedZones)'
@ -126,7 +155,7 @@ nameServerSet:
a set of DNS name servers that all host the same ManagedZones. Most users will a set of DNS name servers that all host the same ManagedZones. Most users will
leave this field unset. leave this field unset.
returned: success returned: success
type: list type: str
creationTime: creationTime:
description: description:
- The time that this resource was created on the server. - The time that this resource was created on the server.
@ -138,13 +167,40 @@ labels:
- A set of key/value label pairs to assign to this ManagedZone. - A set of key/value label pairs to assign to this ManagedZone.
returned: success returned: success
type: dict type: dict
visibility:
description:
- 'The zone''s visibility: public zones are exposed to the Internet, while private
zones are visible only to Virtual Private Cloud resources.'
- 'Must be one of: `public`, `private`.'
returned: success
type: str
privateVisibilityConfig:
description:
- For privately visible zones, the set of Virtual Private Cloud resources that the
zone is visible from.
returned: success
type: complex
contains:
networks:
description:
- The list of VPC networks that can see this zone.
returned: success
type: complex
contains:
networkUrl:
description:
- The fully qualified URL of the VPC network to bind to.
- This should be formatted like `U(https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`)
.
returned: success
type: str
''' '''
################################################################################ ################################################################################
# Imports # 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 json
################################################################################ ################################################################################
@ -161,8 +217,10 @@ def main():
description=dict(required=True, type='str'), description=dict(required=True, type='str'),
dns_name=dict(required=True, type='str'), dns_name=dict(required=True, type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
name_server_set=dict(type='list', elements='str'), name_server_set=dict(type='str'),
labels=dict(type='dict'), labels=dict(type='dict'),
visibility=dict(default='public', type='str', choices=['private', 'public']),
private_visibility_config=dict(type='dict', options=dict(networks=dict(type='list', elements='dict', options=dict(network_url=dict(type='str'))))),
) )
) )
@ -208,7 +266,11 @@ def update(module, link, kind, fetch):
def update_fields(module, request, response): def update_fields(module, request, response):
if response.get('description') != request.get('description') or response.get('labels') != request.get('labels'): if (
response.get('description') != request.get('description')
or response.get('labels') != request.get('labels')
or response.get('privateVisibilityConfig') != request.get('privateVisibilityConfig')
):
description_update(module, request, response) description_update(module, request, response)
@ -216,7 +278,11 @@ def description_update(module, request, response):
auth = GcpSession(module, 'dns') auth = GcpSession(module, 'dns')
auth.patch( auth.patch(
''.join(["https://www.googleapis.com/dns/v1/", "projects/{project}/managedZones/{name}"]).format(**module.params), ''.join(["https://www.googleapis.com/dns/v1/", "projects/{project}/managedZones/{name}"]).format(**module.params),
{u'description': module.params.get('description'), u'labels': module.params.get('labels')}, {
u'description': module.params.get('description'),
u'labels': module.params.get('labels'),
u'privateVisibilityConfig': ManagedZonePrivatevisibilityconfig(module.params.get('private_visibility_config', {}), module).to_request(),
},
) )
@ -233,6 +299,8 @@ def resource_to_request(module):
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'nameServerSet': module.params.get('name_server_set'), u'nameServerSet': module.params.get('name_server_set'),
u'labels': module.params.get('labels'), u'labels': module.params.get('labels'),
u'visibility': module.params.get('visibility'),
u'privateVisibilityConfig': ManagedZonePrivatevisibilityconfig(module.params.get('private_visibility_config', {}), module).to_request(),
} }
return_vals = {} return_vals = {}
for k, v in request.items(): for k, v in request.items():
@ -306,8 +374,52 @@ def response_to_hash(module, response):
u'nameServerSet': response.get(u'nameServerSet'), u'nameServerSet': response.get(u'nameServerSet'),
u'creationTime': response.get(u'creationTime'), u'creationTime': response.get(u'creationTime'),
u'labels': response.get(u'labels'), u'labels': response.get(u'labels'),
u'visibility': response.get(u'visibility'),
u'privateVisibilityConfig': ManagedZonePrivatevisibilityconfig(response.get(u'privateVisibilityConfig', {}), module).from_response(),
} }
class ManagedZonePrivatevisibilityconfig(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'networks': ManagedZoneNetworksArray(self.request.get('networks', []), self.module).to_request()})
def from_response(self):
return remove_nones_from_dict({u'networks': ManagedZoneNetworksArray(self.request.get(u'networks', []), self.module).from_response()})
class ManagedZoneNetworksArray(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'networkUrl': item.get('network_url')})
def _response_from_item(self, item):
return remove_nones_from_dict({u'networkUrl': item.get(u'networkUrl')})
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View file

@ -47,12 +47,13 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a managed zone facts - name: " a managed zone facts"
gcp_dns_managed_zone_facts: gcp_dns_managed_zone_facts:
dns_name: test.somewild2.example.com. dns_name: test.somewild2.example.com.
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -95,7 +96,7 @@ items:
is a set of DNS name servers that all host the same ManagedZones. Most users is a set of DNS name servers that all host the same ManagedZones. Most users
will leave this field unset. will leave this field unset.
returned: success returned: success
type: list type: str
creationTime: creationTime:
description: description:
- The time that this resource was created on the server. - The time that this resource was created on the server.
@ -107,6 +108,33 @@ items:
- A set of key/value label pairs to assign to this ManagedZone. - A set of key/value label pairs to assign to this ManagedZone.
returned: success returned: success
type: dict type: dict
visibility:
description:
- 'The zone''s visibility: public zones are exposed to the Internet, while private
zones are visible only to Virtual Private Cloud resources.'
- 'Must be one of: `public`, `private`.'
returned: success
type: str
privateVisibilityConfig:
description:
- For privately visible zones, the set of Virtual Private Cloud resources that
the zone is visible from.
returned: success
type: complex
contains:
networks:
description:
- The list of VPC networks that can see this zone.
returned: success
type: complex
contains:
networkUrl:
description:
- The fully qualified URL of the VPC network to bind to.
- This should be formatted like `U(https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`)
.
returned: success
type: str
''' '''
################################################################################ ################################################################################

View file

@ -71,6 +71,7 @@ options:
- SOA - SOA
- SPF - SPF
- SRV - SRV
- TLSA
- TXT - TXT
ttl: ttl:
description: description:
@ -83,11 +84,11 @@ options:
managed_zone: managed_zone:
description: description:
- Identifies the managed zone addressed by this request. - Identifies the managed zone addressed by this request.
- Can be the managed zone name or id.
- 'This field represents a link to a ManagedZone resource in GCP. It can be specified - 'This field represents a link to a ManagedZone resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_dns_managed_zone your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this managed_zone field to "{{ name-of-resource }}"' to a gcp_dns_managed_zone task and then set this managed_zone field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -95,13 +96,13 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a managed zone - name: create a managed zone
gcp_dns_managed_zone: gcp_dns_managed_zone:
name: "managedzone-rrs" name: managedzone-rrs
dns_name: testzone-4.com. dns_name: testzone-4.com.
description: test zone description: test zone
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: managed_zone register: managed_zone
- name: create a resource record set - name: create a resource record set
@ -143,9 +144,8 @@ target:
managed_zone: managed_zone:
description: description:
- Identifies the managed zone addressed by this request. - Identifies the managed zone addressed by this request.
- Can be the managed zone name or id.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -170,10 +170,10 @@ def main():
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
type=dict(required=True, type='str', choices=['A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS', 'PTR', 'SOA', 'SPF', 'SRV', 'TXT']), type=dict(required=True, type='str', choices=['A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NAPTR', 'NS', 'PTR', 'SOA', 'SPF', 'SRV', 'TLSA', 'TXT']),
ttl=dict(type='int'), ttl=dict(type='int'),
target=dict(type='list', elements='str'), target=dict(type='list', elements='str'),
managed_zone=dict(required=True), managed_zone=dict(required=True, type='dict'),
) )
) )
@ -325,7 +325,7 @@ def is_different(module, response):
# Remove unnecessary properties from the response. # Remove unnecessary properties from the response.
# This is for doing comparisons with Ansible's current parameters. # This is for doing comparisons with Ansible's current parameters.
def response_to_hash(module, response): def response_to_hash(module, response):
return {u'name': response.get(u'name'), u'type': response.get(u'type'), u'ttl': response.get(u'ttl'), u'rrdatas': response.get(u'target')} return {u'name': response.get(u'name'), u'type': response.get(u'type'), u'ttl': response.get(u'ttl'), u'rrdatas': response.get(u'rrdatas')}
def updated_record(module): def updated_record(module):
@ -357,13 +357,12 @@ class SOAForwardable(object):
def prefetch_soa_resource(module): def prefetch_soa_resource(module):
name = module.params['name'].split('.')[1:]
resource = SOAForwardable( resource = SOAForwardable(
{ {
'type': 'SOA', 'type': 'SOA',
'managed_zone': module.params['managed_zone'], 'managed_zone': module.params['managed_zone'],
'name': '.'.join(name), 'name': replace_resource_dict(module.params['managed_zone'], 'dnsName'),
'project': module.params['project'], 'project': module.params['project'],
'scopes': module.params['scopes'], 'scopes': module.params['scopes'],
'service_account_file': module.params['service_account_file'], 'service_account_file': module.params['service_account_file'],
@ -375,7 +374,7 @@ def prefetch_soa_resource(module):
result = fetch_wrapped_resource(resource, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets') result = fetch_wrapped_resource(resource, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets')
if not result: if not result:
raise ValueError("Google DNS Managed Zone %s not found" % module.params['managed_zone']['name']) raise ValueError("Google DNS Managed Zone %s not found" % replace_resource_dict(module.params['managed_zone'], 'name'))
return result return result

View file

@ -43,22 +43,23 @@ options:
managed_zone: managed_zone:
description: description:
- Identifies the managed zone addressed by this request. - Identifies the managed zone addressed by this request.
- Can be the managed zone name or id.
- 'This field represents a link to a ManagedZone resource in GCP. It can be specified - 'This field represents a link to a ManagedZone resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_dns_managed_zone your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this managed_zone field to "{{ name-of-resource }}"' to a gcp_dns_managed_zone task and then set this managed_zone field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a resource record set facts - name: " a resource record set facts"
gcp_dns_resource_record_set_facts: gcp_dns_resource_record_set_facts:
managed_zone: "{{ managed_zone }}" managed_zone: "{{ managed_zone }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -90,9 +91,8 @@ items:
managed_zone: managed_zone:
description: description:
- Identifies the managed zone addressed by this request. - Identifies the managed zone addressed by this request.
- Can be the managed zone name or id.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -107,7 +107,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(managed_zone=dict(required=True))) module = GcpModule(argument_spec=dict(managed_zone=dict(required=True, type='dict')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite'] module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite']

View file

@ -61,14 +61,12 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a service account - name: create a service account
gcp_iam_service_account: gcp_iam_service_account:
name: '"{{resource_name}}@{{gcp_project}}.google.com.iam.gserviceaccount.com" name: "{{ sa_name }}"
display_name: My Ansible test key
' project: test_project
display_name: My Ansible test key auth_kind: serviceaccount
project: "test_project" service_account_file: "/tmp/auth.pem"
auth_kind: "serviceaccount" state: present
service_account_file: "/tmp/auth.pem"
state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -44,11 +44,12 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a service account facts - name: " a service account facts"
gcp_iam_service_account_facts: gcp_iam_service_account_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -67,9 +67,10 @@ options:
description: description:
- The name of the serviceAccount. - The name of the serviceAccount.
- 'This field represents a link to a ServiceAccount resource in GCP. It can be - 'This field represents a link to a ServiceAccount resource in GCP. It can be
specified in two ways. First, you can place in the name of the resource here specified in two ways. First, you can place a dictionary with key ''name'' and
as a string Alternatively, you can add `register: name-of-resource` to a gcp_iam_service_account value of your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this service_account field to "{{ name-of-resource }}"' to a gcp_iam_service_account task and then set this service_account field to
"{{ name-of-resource }}"'
required: false required: false
path: path:
description: description:
@ -83,23 +84,23 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a service account - name: create a service account
gcp_iam_service_account: gcp_iam_service_account:
name: test-ansible@graphite-playground.google.com.iam.gserviceaccount.com name: test-ansible@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key display_name: My Ansible test key
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: serviceaccount register: serviceaccount
- name: create a service account key - name: create a service account key
gcp_iam_service_account_key: gcp_iam_service_account_key:
service_account: "{{ serviceaccount }}" service_account: "{{ serviceaccount }}"
private_key_type: TYPE_GOOGLE_CREDENTIALS_FILE private_key_type: TYPE_GOOGLE_CREDENTIALS_FILE
path: "~/test_account.json" path: "~/test_account.json"
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''
@ -142,7 +143,7 @@ serviceAccount:
description: description:
- The name of the serviceAccount. - The name of the serviceAccount.
returned: success returned: success
type: str type: dict
path: path:
description: description:
- The full name of the file that will hold the service account private key. The - The full name of the file that will hold the service account private key. The
@ -176,7 +177,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
private_key_type=dict(type='str', choices=['TYPE_UNSPECIFIED', 'TYPE_PKCS12_FILE', 'TYPE_GOOGLE_CREDENTIALS_FILE']), private_key_type=dict(type='str', choices=['TYPE_UNSPECIFIED', 'TYPE_PKCS12_FILE', 'TYPE_GOOGLE_CREDENTIALS_FILE']),
key_algorithm=dict(type='str', choices=['KEY_ALG_UNSPECIFIED', 'KEY_ALG_RSA_1024', 'KEY_ALG_RSA_2048']), key_algorithm=dict(type='str', choices=['KEY_ALG_UNSPECIFIED', 'KEY_ALG_RSA_1024', 'KEY_ALG_RSA_2048']),
service_account=dict(), service_account=dict(type='dict'),
path=dict(type='path'), path=dict(type='path'),
) )
) )

View file

@ -51,15 +51,21 @@ options:
name: name:
description: description:
- Name of the subscription. - Name of the subscription.
required: false required: true
topic: topic:
description: description:
- A reference to a Topic resource. - A reference to a Topic resource.
- 'This field represents a link to a Topic resource in GCP. It can be specified - 'This field represents a link to a Topic resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_pubsub_topic your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this topic field to "{{ name-of-resource }}"' to a gcp_pubsub_topic task and then set this topic field to "{{ name-of-resource
}}"'
required: true
labels:
description:
- A set of key/value label pairs to assign to this Subscription.
required: false required: false
version_added: 2.8
push_config: push_config:
description: description:
- If push delivery is used with this subscription, this field is used to configure - If push delivery is used with this subscription, this field is used to configure
@ -71,6 +77,25 @@ options:
description: description:
- A URL locating the endpoint to which messages should be pushed. - A URL locating the endpoint to which messages should be pushed.
- For example, a Webhook endpoint might use "U(https://example.com/push".) - For example, a Webhook endpoint might use "U(https://example.com/push".)
required: true
attributes:
description:
- Endpoint configuration attributes.
- Every endpoint has a set of API supported attributes that can be used to
control different aspects of the message delivery.
- The currently supported attribute is x-goog-version, which you can use to
change the format of the pushed message. This attribute indicates the version
of the data expected by the endpoint. This controls the shape of the pushed
message (i.e., its fields and metadata). The endpoint version is based on
the version of the Pub/Sub API.
- If not present during the subscriptions.create call, it will default to
the version of the API used to make such call. If not present during a subscriptions.modifyPushConfig
call, its value will not be changed. subscriptions.get calls will always
return a valid version, even if the subscription was created without this
attribute.
- 'The possible values for this attribute are: - v1beta1: uses the push format
defined in the v1beta1 Pub/Sub API.'
- "- v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API."
required: false required: false
ack_deadline_seconds: ack_deadline_seconds:
description: description:
@ -89,23 +114,48 @@ options:
- If the subscriber never acknowledges the message, the Pub/Sub system will eventually - If the subscriber never acknowledges the message, the Pub/Sub system will eventually
redeliver the message. redeliver the message.
required: false required: false
message_retention_duration:
description:
- How long to retain unacknowledged messages in the subscription's backlog, from
the moment a message is published. If retainAckedMessages is true, then this
also configures the retention of acknowledged messages, and thus configures
how far back in time a subscriptions.seek can be done. Defaults to 7 days. Cannot
be more than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`).
- 'A duration in seconds with up to nine fractional digits, terminated by ''s''.
Example: `"600.5s"`.'
required: false
default: 604800s
version_added: 2.8
retain_acked_messages:
description:
- Indicates whether to retain acknowledged messages. If `true`, then messages
are not expunged from the subscription's backlog, even if they are acknowledged,
until they fall out of the messageRetentionDuration window.
required: false
type: bool
version_added: 2.8
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions)'
- 'Managing Subscriptions: U(https://cloud.google.com/pubsub/docs/admin#managing_subscriptions)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: create a topic - name: create a topic
gcp_pubsub_topic: gcp_pubsub_topic:
name: "topic-subscription" name: topic-subscription
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: topic register: topic
- name: create a subscription - name: create a subscription
gcp_pubsub_subscription: gcp_pubsub_subscription:
name: "test_object" name: "test_object"
topic: "{{ topic }}" topic: "{{ topic }}"
push_config:
push_endpoint: https://myapp.graphite.cloudnativeapp.com/webhook/sub1
ack_deadline_seconds: 300 ack_deadline_seconds: 300
project: "test_project" project: "test_project"
auth_kind: "serviceaccount" auth_kind: "serviceaccount"
@ -123,7 +173,12 @@ topic:
description: description:
- A reference to a Topic resource. - A reference to a Topic resource.
returned: success returned: success
type: str type: dict
labels:
description:
- A set of key/value label pairs to assign to this Subscription.
returned: success
type: dict
pushConfig: pushConfig:
description: description:
- If push delivery is used with this subscription, this field is used to configure - If push delivery is used with this subscription, this field is used to configure
@ -138,6 +193,25 @@ pushConfig:
- For example, a Webhook endpoint might use "U(https://example.com/push".) - For example, a Webhook endpoint might use "U(https://example.com/push".)
returned: success returned: success
type: str type: str
attributes:
description:
- Endpoint configuration attributes.
- Every endpoint has a set of API supported attributes that can be used to control
different aspects of the message delivery.
- The currently supported attribute is x-goog-version, which you can use to
change the format of the pushed message. This attribute indicates the version
of the data expected by the endpoint. This controls the shape of the pushed
message (i.e., its fields and metadata). The endpoint version is based on
the version of the Pub/Sub API.
- If not present during the subscriptions.create call, it will default to the
version of the API used to make such call. If not present during a subscriptions.modifyPushConfig
call, its value will not be changed. subscriptions.get calls will always return
a valid version, even if the subscription was created without this attribute.
- 'The possible values for this attribute are: - v1beta1: uses the push format
defined in the v1beta1 Pub/Sub API.'
- "- v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API."
returned: success
type: dict
ackDeadlineSeconds: ackDeadlineSeconds:
description: description:
- This value is the maximum time after a subscriber receives a message before the - This value is the maximum time after a subscriber receives a message before the
@ -156,6 +230,24 @@ ackDeadlineSeconds:
redeliver the message. redeliver the message.
returned: success returned: success
type: int type: int
messageRetentionDuration:
description:
- How long to retain unacknowledged messages in the subscription's backlog, from
the moment a message is published. If retainAckedMessages is true, then this also
configures the retention of acknowledged messages, and thus configures how far
back in time a subscriptions.seek can be done. Defaults to 7 days. Cannot be more
than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`).
- 'A duration in seconds with up to nine fractional digits, terminated by ''s''.
Example: `"600.5s"`.'
returned: success
type: str
retainAckedMessages:
description:
- Indicates whether to retain acknowledged messages. If `true`, then messages are
not expunged from the subscription's backlog, even if they are acknowledged, until
they fall out of the messageRetentionDuration window.
returned: success
type: bool
''' '''
################################################################################ ################################################################################
@ -176,10 +268,13 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(type='str'), name=dict(required=True, type='str'),
topic=dict(), topic=dict(required=True, type='dict'),
push_config=dict(type='dict', options=dict(push_endpoint=dict(type='str'))), labels=dict(type='dict'),
push_config=dict(type='dict', options=dict(push_endpoint=dict(required=True, type='str'), attributes=dict(type='dict'))),
ack_deadline_seconds=dict(type='int'), ack_deadline_seconds=dict(type='int'),
message_retention_duration=dict(default='604800s', type='str'),
retain_acked_messages=dict(type='bool'),
) )
) )
@ -194,7 +289,7 @@ def main():
if fetch: if fetch:
if state == 'present': if state == 'present':
if is_different(module, fetch): if is_different(module, fetch):
update(module, self_link(module)) update(module, self_link(module), fetch)
fetch = fetch_resource(module, self_link(module)) fetch = fetch_resource(module, self_link(module))
changed = True changed = True
else: else:
@ -218,8 +313,27 @@ def create(module, link):
return return_if_object(module, auth.put(link, resource_to_request(module))) return return_if_object(module, auth.put(link, resource_to_request(module)))
def update(module, link): def update(module, link, fetch):
module.fail_json(msg="Subscription cannot be edited") auth = GcpSession(module, 'pubsub')
params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
request = resource_to_request(module)
del request['name']
return return_if_object(module, auth.patch(link, request, params=params))
def updateMask(request, response):
update_mask = []
if request.get('labels') != response.get('labels'):
update_mask.append('labels')
if request.get('pushConfig') != response.get('pushConfig'):
update_mask.append('pushConfig')
if request.get('ackDeadlineSeconds') != response.get('ackDeadlineSeconds'):
update_mask.append('ackDeadlineSeconds')
if request.get('messageRetentionDuration') != response.get('messageRetentionDuration'):
update_mask.append('messageRetentionDuration')
if request.get('retainAckedMessages') != response.get('retainAckedMessages'):
update_mask.append('retainAckedMessages')
return ','.join(update_mask)
def delete(module, link): def delete(module, link):
@ -231,8 +345,11 @@ def resource_to_request(module):
request = { request = {
u'name': module.params.get('name'), u'name': module.params.get('name'),
u'topic': replace_resource_dict(module.params.get(u'topic', {}), 'name'), u'topic': replace_resource_dict(module.params.get(u'topic', {}), 'name'),
u'labels': module.params.get('labels'),
u'pushConfig': SubscriptionPushconfig(module.params.get('push_config', {}), module).to_request(), u'pushConfig': SubscriptionPushconfig(module.params.get('push_config', {}), module).to_request(),
u'ackDeadlineSeconds': module.params.get('ack_deadline_seconds'), u'ackDeadlineSeconds': module.params.get('ack_deadline_seconds'),
u'messageRetentionDuration': module.params.get('message_retention_duration'),
u'retainAckedMessages': module.params.get('retain_acked_messages'),
} }
request = encode_request(request, module) request = encode_request(request, module)
return_vals = {} return_vals = {}
@ -302,10 +419,13 @@ def is_different(module, response):
# This is for doing comparisons with Ansible's current parameters. # This is for doing comparisons with Ansible's current parameters.
def response_to_hash(module, response): def response_to_hash(module, response):
return { return {
u'name': response.get(u'name'), u'name': module.params.get('name'),
u'topic': response.get(u'topic'), u'topic': replace_resource_dict(module.params.get(u'topic', {}), 'name'),
u'labels': response.get(u'labels'),
u'pushConfig': SubscriptionPushconfig(response.get(u'pushConfig', {}), module).from_response(), u'pushConfig': SubscriptionPushconfig(response.get(u'pushConfig', {}), module).from_response(),
u'ackDeadlineSeconds': response.get(u'ackDeadlineSeconds'), u'ackDeadlineSeconds': response.get(u'ackDeadlineSeconds'),
u'messageRetentionDuration': response.get(u'messageRetentionDuration'),
u'retainAckedMessages': response.get(u'retainAckedMessages'),
} }
@ -335,10 +455,10 @@ class SubscriptionPushconfig(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'pushEndpoint': self.request.get('push_endpoint')}) return remove_nones_from_dict({u'pushEndpoint': self.request.get('push_endpoint'), u'attributes': self.request.get('attributes')})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'pushEndpoint': self.request.get(u'pushEndpoint')}) return remove_nones_from_dict({u'pushEndpoint': self.request.get(u'pushEndpoint'), u'attributes': self.request.get(u'attributes')})
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -44,11 +44,12 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a subscription facts - name: " a subscription facts"
gcp_pubsub_subscription_facts: gcp_pubsub_subscription_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -66,7 +67,12 @@ items:
description: description:
- A reference to a Topic resource. - A reference to a Topic resource.
returned: success returned: success
type: str type: dict
labels:
description:
- A set of key/value label pairs to assign to this Subscription.
returned: success
type: dict
pushConfig: pushConfig:
description: description:
- If push delivery is used with this subscription, this field is used to configure - If push delivery is used with this subscription, this field is used to configure
@ -81,6 +87,26 @@ items:
- For example, a Webhook endpoint might use "U(https://example.com/push".) - For example, a Webhook endpoint might use "U(https://example.com/push".)
returned: success returned: success
type: str type: str
attributes:
description:
- Endpoint configuration attributes.
- Every endpoint has a set of API supported attributes that can be used
to control different aspects of the message delivery.
- The currently supported attribute is x-goog-version, which you can use
to change the format of the pushed message. This attribute indicates the
version of the data expected by the endpoint. This controls the shape
of the pushed message (i.e., its fields and metadata). The endpoint version
is based on the version of the Pub/Sub API.
- If not present during the subscriptions.create call, it will default to
the version of the API used to make such call. If not present during a
subscriptions.modifyPushConfig call, its value will not be changed. subscriptions.get
calls will always return a valid version, even if the subscription was
created without this attribute.
- 'The possible values for this attribute are: - v1beta1: uses the push
format defined in the v1beta1 Pub/Sub API.'
- "- v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API."
returned: success
type: dict
ackDeadlineSeconds: ackDeadlineSeconds:
description: description:
- This value is the maximum time after a subscriber receives a message before - This value is the maximum time after a subscriber receives a message before
@ -100,6 +126,24 @@ items:
eventually redeliver the message. eventually redeliver the message.
returned: success returned: success
type: int type: int
messageRetentionDuration:
description:
- How long to retain unacknowledged messages in the subscription's backlog,
from the moment a message is published. If retainAckedMessages is true, then
this also configures the retention of acknowledged messages, and thus configures
how far back in time a subscriptions.seek can be done. Defaults to 7 days.
Cannot be more than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`).
- 'A duration in seconds with up to nine fractional digits, terminated by ''s''.
Example: `"600.5s"`.'
returned: success
type: str
retainAckedMessages:
description:
- Indicates whether to retain acknowledged messages. If `true`, then messages
are not expunged from the subscription's backlog, even if they are acknowledged,
until they fall out of the messageRetentionDuration window.
returned: success
type: bool
''' '''
################################################################################ ################################################################################

View file

@ -50,8 +50,16 @@ options:
name: name:
description: description:
- Name of the topic. - Name of the topic.
required: true
labels:
description:
- A set of key/value label pairs to assign to this Topic.
required: false required: false
version_added: 2.8
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics)'
- 'Managing Topics: U(https://cloud.google.com/pubsub/docs/admin#managing_topics)'
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -70,6 +78,11 @@ name:
- Name of the topic. - Name of the topic.
returned: success returned: success
type: str type: str
labels:
description:
- A set of key/value label pairs to assign to this Topic.
returned: success
type: dict
''' '''
################################################################################ ################################################################################
@ -87,7 +100,11 @@ import json
def main(): def main():
"""Main function""" """Main function"""
module = GcpModule(argument_spec=dict(state=dict(default='present', choices=['present', 'absent'], type='str'), name=dict(type='str'))) module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), name=dict(required=True, type='str'), labels=dict(type='dict')
)
)
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub'] module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub']
@ -125,8 +142,8 @@ def create(module, link):
def update(module, link): def update(module, link):
auth = GcpSession(module, 'pubsub') delete(module, self_link(module))
return return_if_object(module, auth.put(link, resource_to_request(module))) create(module, self_link(module))
def delete(module, link): def delete(module, link):
@ -135,7 +152,7 @@ def delete(module, link):
def resource_to_request(module): def resource_to_request(module):
request = {u'name': module.params.get('name')} request = {u'name': module.params.get('name'), u'labels': module.params.get('labels')}
request = encode_request(request, module) request = encode_request(request, module)
return_vals = {} return_vals = {}
for k, v in request.items(): for k, v in request.items():
@ -203,7 +220,7 @@ def is_different(module, response):
# Remove unnecessary properties from the response. # Remove unnecessary properties from the response.
# This is for doing comparisons with Ansible's current parameters. # This is for doing comparisons with Ansible's current parameters.
def response_to_hash(module, response): def response_to_hash(module, response):
return {u'name': response.get(u'name')} return {u'name': response.get(u'name'), u'labels': response.get(u'labels')}
def decode_request(response, module): def decode_request(response, module):

View file

@ -44,11 +44,12 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a topic facts - name: " a topic facts"
gcp_pubsub_topic_facts: gcp_pubsub_topic_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -62,6 +63,11 @@ items:
- Name of the topic. - Name of the topic.
returned: success returned: success
type: str type: str
labels:
description:
- A set of key/value label pairs to assign to this Topic.
returned: success
type: dict
''' '''
################################################################################ ################################################################################

View file

@ -123,30 +123,30 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a network - name: create a network
gcp_compute_network: gcp_compute_network:
name: "network-instance" name: network-instance
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: network register: network
- name: create a instance - name: create a instance
gcp_redis_instance: gcp_redis_instance:
name: instance37 name: instance37
tier: STANDARD_HA tier: STANDARD_HA
memory_size_gb: 1 memory_size_gb: 1
region: us-central1 region: us-central1
location_id: us-central1-a location_id: us-central1-a
redis_version: REDIS_3_2 redis_version: REDIS_3_2
display_name: Ansible Test Instance display_name: Ansible Test Instance
reserved_ip_range: 192.168.0.0/29 reserved_ip_range: 192.168.0.0/29
labels: labels:
my_key: my_val my_key: my_val
other_key: other_val other_key: other_val
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -48,12 +48,13 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a instance facts - name: " a instance facts"
gcp_redis_instance_facts: gcp_redis_instance_facts:
region: us-central1 region: us-central1
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -90,14 +90,14 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a project - name: create a project
gcp_resourcemanager_project: gcp_resourcemanager_project:
name: My Sample Project name: My Sample Project
id: alextest-{{ 10000000000 | random }} id: alextest-{{ 10000000000 | random }}
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
parent: parent:
type: organization type: organization
id: 636173955921 id: 636173955921
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -44,11 +44,12 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a project facts - name: " a project facts"
gcp_resourcemanager_project_facts: gcp_resourcemanager_project_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''

View file

@ -62,11 +62,11 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a repository - name: create a repository
gcp_sourcerepo_repository: gcp_sourcerepo_repository:
name: projects/test_project/repos/test_object name: projects/test_project/repos/test_object
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''
@ -142,7 +142,8 @@ def create(module, link):
def update(module, link): def update(module, link):
module.fail_json(msg="Repository cannot be edited") delete(module, self_link(module))
create(module, collection(module))
def delete(module, link): def delete(module, link):

View file

@ -44,16 +44,17 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a repository facts - name: " a repository facts"
gcp_sourcerepo_repository_facts: gcp_sourcerepo_repository_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -98,7 +99,7 @@ def main():
items = items.get('repos') items = items.get('repos')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -63,9 +63,10 @@ options:
description: description:
- The instance to create the database on. - The instance to create the database on.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_spanner_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_spanner_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
notes: notes:
@ -76,16 +77,16 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance - name: create a instance
gcp_spanner_instance: gcp_spanner_instance:
name: "instance-database" name: instance-database
display_name: My Spanner Instance display_name: My Spanner Instance
node_count: 2 node_count: 2
labels: labels:
cost_center: ti-1700004 cost_center: ti-1700004
config: regional-us-central1 config: regional-us-central1
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instance register: instance
- name: create a database - name: create a database
@ -117,7 +118,7 @@ instance:
description: description:
- The instance to create the database on. - The instance to create the database on.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -140,7 +141,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
extra_statements=dict(type='list', elements='str'), extra_statements=dict(type='list', elements='str'),
instance=dict(required=True), instance=dict(required=True, type='dict'),
) )
) )
@ -180,7 +181,8 @@ def create(module, link):
def update(module, link): def update(module, link):
module.fail_json(msg="Database cannot be edited") delete(module, self_link(module))
create(module, collection(module))
def delete(module, link): def delete(module, link):

View file

@ -44,25 +44,27 @@ options:
description: description:
- The instance to create the database on. - The instance to create the database on.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_spanner_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_spanner_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a database facts - name: " a database facts"
gcp_spanner_database_facts: gcp_spanner_database_facts:
instance: "{{ instance }}" instance: "{{ instance }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -84,7 +86,7 @@ items:
description: description:
- The instance to create the database on. - The instance to create the database on.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
@ -99,7 +101,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True))) module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']
@ -109,7 +111,7 @@ def main():
items = items.get('databases') items = items.get('databases')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -85,7 +85,7 @@ notes:
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance - name: create a instance
gcp_spanner_instance: gcp_spanner_instance:
name: testinstance name: "test_object"
display_name: My Spanner Instance display_name: My Spanner Instance
node_count: 2 node_count: 2
labels: labels:

View file

@ -44,16 +44,17 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a instance facts - name: " a instance facts"
gcp_spanner_instance_facts: gcp_spanner_instance_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -114,7 +115,7 @@ def main():
items = items.get('instances') items = items.get('instances')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -59,14 +59,10 @@ options:
description: description:
- The name of the database in the Cloud SQL instance. - The name of the database in the Cloud SQL instance.
- This does not include the project ID or instance name. - This does not include the project ID or instance name.
required: false required: true
instance: instance:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
@ -74,18 +70,18 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance - name: create a instance
gcp_sql_instance: gcp_sql_instance:
name: "{{resource_name}}-3" name: "{{resource_name}}-3"
settings: settings:
ip_configuration: ip_configuration:
authorized_networks: authorized_networks:
- name: google dns server - name: google dns server
value: 8.8.8.8/32 value: 8.8.8.8/32
tier: db-n1-standard-1 tier: db-n1-standard-1
region: us-central1 region: us-central1
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instance register: instance
- name: create a database - name: create a database
@ -144,8 +140,8 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
charset=dict(type='str'), charset=dict(type='str'),
collation=dict(type='str'), collation=dict(type='str'),
name=dict(type='str'), name=dict(required=True, type='str'),
instance=dict(required=True), instance=dict(required=True, type='str'),
) )
) )
@ -198,6 +194,7 @@ def delete(module, link, kind):
def resource_to_request(module): def resource_to_request(module):
request = { request = {
u'kind': 'sql#database', u'kind': 'sql#database',
u'instance': module.params.get('instance'),
u'charset': module.params.get('charset'), u'charset': module.params.get('charset'),
u'collation': module.params.get('collation'), u'collation': module.params.get('collation'),
u'name': module.params.get('name'), u'name': module.params.get('name'),
@ -216,13 +213,11 @@ def fetch_resource(module, link, kind, allow_not_found=True):
def self_link(module): def self_link(module):
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name'), 'name': module.params['name']} return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases/{name}".format(**module.params)
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases/{name}".format(**res)
def collection(module): def collection(module):
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')} return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**module.params)
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**res)
def return_if_object(module, response, kind, allow_not_found=False): def return_if_object(module, response, kind, allow_not_found=False):
@ -270,7 +265,7 @@ def is_different(module, response):
# Remove unnecessary properties from the response. # Remove unnecessary properties from the response.
# This is for doing comparisons with Ansible's current parameters. # This is for doing comparisons with Ansible's current parameters.
def response_to_hash(module, response): def response_to_hash(module, response):
return {u'charset': response.get(u'charset'), u'collation': response.get(u'collation'), u'name': response.get(u'name')} return {u'charset': response.get(u'charset'), u'collation': response.get(u'collation'), u'name': module.params.get('name')}
def async_op_url(module, extra_data=None): def async_op_url(module, extra_data=None):

View file

@ -43,26 +43,23 @@ options:
instance: instance:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance
task and then set this instance field to "{{ name-of-resource }}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a database facts - name: " a database facts"
gcp_sql_database_facts: gcp_sql_database_facts:
instance: "{{ instance }}" instance: "{{ instance }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -92,7 +89,7 @@ items:
################################################################################ ################################################################################
# Imports # 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
import json import json
################################################################################ ################################################################################
@ -101,7 +98,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True))) module = GcpModule(argument_spec=dict(instance=dict(required=True, type='str')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
@ -111,13 +108,12 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)
def collection(module): def collection(module):
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')} return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**module.params)
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**res)
def fetch_list(module, link): def fetch_list(module, link):

View file

@ -320,18 +320,18 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance - name: create a instance
gcp_sql_instance: gcp_sql_instance:
name: "{{resource_name}}-2" name: "test_object"
settings: settings:
ip_configuration: ip_configuration:
authorized_networks: authorized_networks:
- name: google dns server - name: google dns server
value: 8.8.8.8/32 value: 8.8.8.8/32
tier: db-n1-standard-1 tier: db-n1-standard-1
region: us-central1 region: us-central1
project: test_project project: "test_project"
auth_kind: serviceaccount auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''

View file

@ -44,16 +44,17 @@ extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a instance facts - name: " a instance facts"
gcp_sql_instance_facts: gcp_sql_instance_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -312,6 +313,34 @@ items:
Generation (recommended) or First Generation. Generation (recommended) or First Generation.
returned: success returned: success
type: str type: str
availabilityType:
description:
- The availabilityType define if your postgres instance is run zonal or
regional.
returned: success
type: str
backupConfiguration:
description:
- The daily backup configuration for the instance.
returned: success
type: complex
contains:
enabled:
description:
- Enable Autobackup for your instance.
returned: success
type: bool
binaryLogEnabled:
description:
- Whether binary log is enabled. If backup configuration is disabled,
binary log must be disabled as well. MySQL only.
returned: success
type: bool
startTime:
description:
- Define the backup start time in UTC (HH:MM) .
returned: success
type: str
settingsVersion: settingsVersion:
description: description:
- The version of instance settings. This is a required field for update - The version of instance settings. This is a required field for update
@ -344,7 +373,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -61,9 +61,10 @@ options:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
password: password:
description: description:
@ -75,18 +76,18 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a instance - name: create a instance
gcp_sql_instance: gcp_sql_instance:
name: "{{resource_name}}-1" name: "{{resource_name}}-1"
settings: settings:
ip_configuration: ip_configuration:
authorized_networks: authorized_networks:
- name: google dns server - name: google dns server
value: 8.8.8.8/32 value: 8.8.8.8/32
tier: db-n1-standard-1 tier: db-n1-standard-1
region: us-central1 region: us-central1
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: instance register: instance
- name: create a user - name: create a user
@ -118,7 +119,7 @@ instance:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
returned: success returned: success
type: str type: dict
password: password:
description: description:
- The password for the user. - The password for the user.
@ -147,7 +148,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
host=dict(required=True, type='str'), host=dict(required=True, type='str'),
name=dict(required=True, type='str'), name=dict(required=True, type='str'),
instance=dict(required=True), instance=dict(required=True, type='dict'),
password=dict(type='str'), password=dict(type='str'),
) )
) )

View file

@ -44,25 +44,27 @@ options:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_sql_instance your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this instance field to "{{ name-of-resource }}"' to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
}}"'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: a user facts - name: " a user facts"
gcp_sql_user_facts: gcp_sql_user_facts:
instance: "{{ instance }}" instance: "{{ instance }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
items: resources:
description: List of items description: List of resources
returned: always returned: always
type: complex type: complex
contains: contains:
@ -82,7 +84,7 @@ items:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
returned: success returned: success
type: str type: dict
password: password:
description: description:
- The password for the user. - The password for the user.
@ -102,7 +104,7 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True))) module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
if not module.params['scopes']: if not module.params['scopes']:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
@ -112,7 +114,7 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {'resources': items}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -61,18 +61,11 @@ options:
description: description:
- The name of the bucket. - The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified - 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a in two ways. First, you can place a dictionary with key ''name'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket of your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this bucket field to "{{ name-of-resource }}"' to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
}}"'
required: true required: true
domain:
description:
- The domain associated with the entity.
required: false
email:
description:
- The email address associated with the entity.
required: false
entity: entity:
description: description:
- 'The entity holding the permission, in one of the following forms: user-userId - 'The entity holding the permission, in one of the following forms: user-userId
@ -87,10 +80,6 @@ options:
description: description:
- The ID for the entity. - The ID for the entity.
required: false required: false
id:
description:
- The ID of the access-control entry.
required: false
project_team: project_team:
description: description:
- The project team associated with the entity. - The project team associated with the entity.
@ -152,18 +141,11 @@ options:
description: description:
- The name of the bucket. - The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified - 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a in two ways. First, you can place a dictionary with key ''name'' and value
string Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket of your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this bucket field to "{{ name-of-resource }}"' to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
}}"'
required: true required: true
domain:
description:
- The domain associated with the entity.
required: false
email:
description:
- The email address associated with the entity.
required: false
entity: entity:
description: description:
- 'The entity holding the permission, in one of the following forms: * user-{{userId}} - 'The entity holding the permission, in one of the following forms: * user-{{userId}}
@ -172,39 +154,10 @@ options:
(such as "domain-example.com") * project-team-{{projectId}} * allUsers * (such as "domain-example.com") * project-team-{{projectId}} * allUsers *
allAuthenticatedUsers .' allAuthenticatedUsers .'
required: true required: true
entity_id:
description:
- The ID for the entity.
required: false
generation:
description:
- The content generation of the object, if applied to an object.
required: false
id:
description:
- The ID of the access-control entry.
required: false
object: object:
description: description:
- The name of the object, if applied to an object. - The name of the object, if applied to an object.
required: false required: false
project_team:
description:
- The project team associated with the entity.
required: false
suboptions:
project_number:
description:
- The project team associated with the entity.
required: false
team:
description:
- The team.
required: false
choices:
- editors
- owners
- viewers
role: role:
description: description:
- The access permission for the entity. - The access permission for the entity.
@ -313,10 +266,6 @@ options:
description: description:
- The entity, in the form project-owner-projectId. - The entity, in the form project-owner-projectId.
required: false required: false
entity_id:
description:
- The ID for the entity.
required: false
storage_class: storage_class:
description: description:
- The bucket's default storage class, used whenever no storageClass is specified - The bucket's default storage class, used whenever no storageClass is specified
@ -412,7 +361,7 @@ acl:
description: description:
- The name of the bucket. - The name of the bucket.
returned: success returned: success
type: str type: dict
domain: domain:
description: description:
- The domain associated with the entity. - The domain associated with the entity.
@ -506,7 +455,7 @@ defaultObjectAcl:
description: description:
- The name of the bucket. - The name of the bucket.
returned: success returned: success
type: str type: dict
domain: domain:
description: description:
- The domain associated with the entity. - The domain associated with the entity.
@ -793,12 +742,9 @@ def main():
type='list', type='list',
elements='dict', elements='dict',
options=dict( options=dict(
bucket=dict(required=True), bucket=dict(required=True, type='dict'),
domain=dict(type='str'),
email=dict(type='str'),
entity=dict(required=True, type='str'), entity=dict(required=True, type='str'),
entity_id=dict(type='str'), entity_id=dict(type='str'),
id=dict(type='str'),
project_team=dict( project_team=dict(
type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers'])) type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']))
), ),
@ -819,17 +765,9 @@ def main():
type='list', type='list',
elements='dict', elements='dict',
options=dict( options=dict(
bucket=dict(required=True), bucket=dict(required=True, type='dict'),
domain=dict(type='str'),
email=dict(type='str'),
entity=dict(required=True, type='str'), entity=dict(required=True, type='str'),
entity_id=dict(type='str'),
generation=dict(type='int'),
id=dict(type='str'),
object=dict(type='str'), object=dict(type='str'),
project_team=dict(
type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']))
),
role=dict(required=True, type='str', choices=['OWNER', 'READER']), role=dict(required=True, type='str', choices=['OWNER', 'READER']),
), ),
), ),
@ -861,7 +799,7 @@ def main():
logging=dict(type='dict', options=dict(log_bucket=dict(type='str'), log_object_prefix=dict(type='str'))), logging=dict(type='dict', options=dict(log_bucket=dict(type='str'), log_object_prefix=dict(type='str'))),
metageneration=dict(type='int'), metageneration=dict(type='int'),
name=dict(type='str'), name=dict(type='str'),
owner=dict(type='dict', options=dict(entity=dict(type='str'), entity_id=dict(type='str'))), owner=dict(type='dict', options=dict(entity=dict(type='str'))),
storage_class=dict(type='str', choices=['MULTI_REGIONAL', 'REGIONAL', 'STANDARD', 'NEARLINE', 'COLDLINE', 'DURABLE_REDUCED_AVAILABILITY']), storage_class=dict(type='str', choices=['MULTI_REGIONAL', 'REGIONAL', 'STANDARD', 'NEARLINE', 'COLDLINE', 'DURABLE_REDUCED_AVAILABILITY']),
versioning=dict(type='dict', options=dict(enabled=dict(type='bool'))), versioning=dict(type='dict', options=dict(enabled=dict(type='bool'))),
website=dict(type='dict', options=dict(main_page_suffix=dict(type='str'), not_found_page=dict(type='str'))), website=dict(type='dict', options=dict(main_page_suffix=dict(type='str'), not_found_page=dict(type='str'))),
@ -1043,11 +981,8 @@ class BucketAclArray(object):
return remove_nones_from_dict( return remove_nones_from_dict(
{ {
u'bucket': replace_resource_dict(item.get(u'bucket', {}), 'name'), u'bucket': replace_resource_dict(item.get(u'bucket', {}), 'name'),
u'domain': item.get('domain'),
u'email': item.get('email'),
u'entity': item.get('entity'), u'entity': item.get('entity'),
u'entityId': item.get('entity_id'), u'entityId': item.get('entity_id'),
u'id': item.get('id'),
u'projectTeam': BucketProjectteam(item.get('project_team', {}), self.module).to_request(), u'projectTeam': BucketProjectteam(item.get('project_team', {}), self.module).to_request(),
u'role': item.get('role'), u'role': item.get('role'),
} }
@ -1057,11 +992,8 @@ class BucketAclArray(object):
return remove_nones_from_dict( return remove_nones_from_dict(
{ {
u'bucket': item.get(u'bucket'), u'bucket': item.get(u'bucket'),
u'domain': item.get(u'domain'),
u'email': item.get(u'email'),
u'entity': item.get(u'entity'), u'entity': item.get(u'entity'),
u'entityId': item.get(u'entityId'), u'entityId': item.get(u'entityId'),
u'id': item.get(u'id'),
u'projectTeam': BucketProjectteam(item.get(u'projectTeam', {}), self.module).from_response(), u'projectTeam': BucketProjectteam(item.get(u'projectTeam', {}), self.module).from_response(),
u'role': item.get(u'role'), u'role': item.get(u'role'),
} }
@ -1148,32 +1080,15 @@ class BucketDefaultobjectaclArray(object):
return remove_nones_from_dict( return remove_nones_from_dict(
{ {
u'bucket': replace_resource_dict(item.get(u'bucket', {}), 'name'), u'bucket': replace_resource_dict(item.get(u'bucket', {}), 'name'),
u'domain': item.get('domain'),
u'email': item.get('email'),
u'entity': item.get('entity'), u'entity': item.get('entity'),
u'entityId': item.get('entity_id'),
u'generation': item.get('generation'),
u'id': item.get('id'),
u'object': item.get('object'), u'object': item.get('object'),
u'projectTeam': BucketProjectteam(item.get('project_team', {}), self.module).to_request(),
u'role': item.get('role'), u'role': item.get('role'),
} }
) )
def _response_from_item(self, item): def _response_from_item(self, item):
return remove_nones_from_dict( return remove_nones_from_dict(
{ {u'bucket': item.get(u'bucket'), u'entity': item.get(u'entity'), u'object': item.get(u'object'), u'role': item.get(u'role')}
u'bucket': item.get(u'bucket'),
u'domain': item.get(u'domain'),
u'email': item.get(u'email'),
u'entity': item.get(u'entity'),
u'entityId': item.get(u'entityId'),
u'generation': item.get(u'generation'),
u'id': item.get(u'id'),
u'object': item.get(u'object'),
u'projectTeam': BucketProjectteam(item.get(u'projectTeam', {}), self.module).from_response(),
u'role': item.get(u'role'),
}
) )
@ -1314,10 +1229,10 @@ class BucketOwner(object):
self.request = {} self.request = {}
def to_request(self): def to_request(self):
return remove_nones_from_dict({u'entity': self.request.get('entity'), u'entityId': self.request.get('entity_id')}) return remove_nones_from_dict({u'entity': self.request.get('entity')})
def from_response(self): def from_response(self):
return remove_nones_from_dict({u'entity': self.request.get(u'entity'), u'entityId': self.request.get(u'entityId')}) return remove_nones_from_dict({u'entity': self.request.get(u'entity')})
class BucketVersioning(object): class BucketVersioning(object):

View file

@ -60,9 +60,10 @@ options:
description: description:
- The name of the bucket. - The name of the bucket.
- 'This field represents a link to a Bucket resource in GCP. It can be specified - 'This field represents a link to a Bucket resource in GCP. It can be specified
in two ways. First, you can place in the name of the resource here as a string in two ways. First, you can place a dictionary with key ''name'' and value of
Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket your resource''s name Alternatively, you can add `register: name-of-resource`
task and then set this bucket field to "{{ name-of-resource }}"' to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
}}"'
required: true required: true
entity: entity:
description: description:
@ -108,16 +109,16 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a bucket - name: create a bucket
gcp_storage_bucket: gcp_storage_bucket:
name: "{{ resource_name }}" name: "{{ resource_name }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
state: present state: present
register: bucket register: bucket
- name: create a bucket access control - name: create a bucket access control
gcp_storage_bucket_access_control: gcp_storage_bucket_access_control:
bucket: "test_object" bucket: "{{ bucket }}"
entity: user-alexstephen@google.com entity: user-alexstephen@google.com
role: WRITER role: WRITER
project: "test_project" project: "test_project"
@ -131,7 +132,7 @@ bucket:
description: description:
- The name of the bucket. - The name of the bucket.
returned: success returned: success
type: str type: dict
domain: domain:
description: description:
- The domain associated with the entity. - The domain associated with the entity.
@ -203,7 +204,7 @@ def main():
module = GcpModule( module = GcpModule(
argument_spec=dict( argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
bucket=dict(required=True), bucket=dict(required=True, type='dict'),
entity=dict(required=True, type='str'), entity=dict(required=True, type='str'),
entity_id=dict(type='str'), entity_id=dict(type='str'),
project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']))), project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str', choices=['editors', 'owners', 'viewers']))),
@ -217,7 +218,10 @@ def main():
state = module.params['state'] state = module.params['state']
kind = 'storage#bucketAccessControl' kind = 'storage#bucketAccessControl'
fetch = fetch_resource(module, self_link(module), kind) if module.params['id']:
fetch = fetch_resource(module, self_link(module), kind)
else:
fetch = {}
changed = False changed = False
if fetch: if fetch:

View file

@ -78,15 +78,15 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a object - name: create a object
gcp_storage_object: gcp_storage_object:
name: ansible-storage-module name: ansible-storage-module
action: download action: download
bucket: ansible-bucket bucket: ansible-bucket
src: modules.zip src: modules.zip
dest: "~/modules.zip" dest: "~/modules.zip"
project: "test_project" project: test_project
auth_kind: "serviceaccount" auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: present state: present
''' '''
RETURN = ''' RETURN = '''