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 = '''
- name: create a address
gcp_compute_address:
name: test-address1
region: us-west1
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
name: test-address1
region: us-west1
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''

View file

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

View file

@ -55,6 +55,23 @@ options:
description:
- Cloud Storage bucket name.
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:
- An optional textual description of the resource; provided by the client when
@ -76,18 +93,18 @@ options:
required: true
extends_documentation_fragment: gcp
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)'
'''
EXAMPLES = '''
- name: create a bucket
gcp_storage_bucket:
name: "bucket-backendbucket"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: bucket-backendbucket
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: bucket
- name: create a backend bucket
@ -108,6 +125,23 @@ bucketName:
- Cloud Storage bucket name.
returned: success
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:
description:
- Creation timestamp in RFC3339 text format.
@ -145,7 +179,7 @@ name:
# Imports
################################################################################
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
import json
import time
@ -161,6 +195,7 @@ def main():
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], 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'),
enable_cdn=dict(type='bool'),
name=dict(required=True, type='str'),
@ -217,6 +252,7 @@ def resource_to_request(module):
request = {
u'kind': 'compute#backendBucket',
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'enableCdn': module.params.get('enable_cdn'),
u'name': module.params.get('name'),
@ -286,6 +322,7 @@ def is_different(module, response):
def response_to_hash(module, response):
return {
u'bucketName': response.get(u'bucketName'),
u'cdnPolicy': BackendBucketCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(),
u'creationTimestamp': response.get(u'creationTimestamp'),
u'description': response.get(u'description'),
u'enableCdn': response.get(u'enableCdn'),
@ -329,5 +366,20 @@ def raise_if_errors(response, err_path, module):
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__':
main()

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a backend bucket facts
- name: " a backend bucket facts"
gcp_compute_backend_bucket_facts:
filters:
- name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -69,6 +69,23 @@ items:
- Cloud Storage bucket name.
returned: success
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:
description:
- Creation timestamp in RFC3339 text format.
@ -124,7 +141,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -309,7 +309,7 @@ EXAMPLES = '''
timeout_sec: 2
unhealthy_threshold: 5
project: "test_project"
auth_kind: "service_account"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
'''
@ -403,26 +403,26 @@ RETURN = '''
- PROXY_V1
extends_documentation_fragment: gcp
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)'
'''
EXAMPLES = '''
- name: create a health check
gcp_compute_health_check:
name: "test_object"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
name: test_object
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''

View file

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

View file

@ -105,7 +105,7 @@ options:
required: false
extends_documentation_fragment: gcp
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)'
'''

View file

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

View file

@ -102,7 +102,7 @@ options:
required: false
extends_documentation_fragment: gcp
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)'
'''

View file

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

View file

@ -106,11 +106,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
labels:
description:
- Labels to apply to this Image.
@ -158,9 +153,10 @@ options:
- You must provide either this property or the rawDisk.source property but not
both to create an image.
- 'This field represents a link to a Disk resource in GCP. It can be specified
in two ways. 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_disk
task and then set this source_disk field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_disk task and then set this source_disk field to "{{ name-of-resource
}}"'
required: false
source_disk_encryption_key:
description:
@ -173,11 +169,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
source_disk_id:
description:
- The ID value of the disk used to create this image. This value may be used to
@ -193,19 +184,19 @@ options:
- RAW
extends_documentation_fragment: gcp
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)'
'''
EXAMPLES = '''
- name: create a disk
gcp_compute_disk:
name: "disk-image"
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: disk-image
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: disk
- name: create a image
@ -394,7 +385,7 @@ sourceDisk:
- You must provide either this property or the rawDisk.source property but not both
to create an image.
returned: success
type: str
type: dict
sourceDiskEncryptionKey:
description:
- 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
import json
import re
import time
################################################################################
@ -452,7 +444,7 @@ def main():
disk_size_gb=dict(type='int'),
family=dict(type='str'),
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'),
licenses=dict(type='list', elements='str'),
name=dict(required=True, type='str'),
@ -460,8 +452,8 @@ def main():
type='dict',
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_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
source_disk=dict(type='dict'),
source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
source_disk_id=dict(type='str'),
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):
if extra_data is None:
extra_data = {}
@ -730,10 +731,10 @@ class ImageImageencryptionkey(object):
self.request = {}
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):
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):
@ -764,10 +765,10 @@ class ImageSourcediskencryptionkey(object):
self.request = {}
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):
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__':

View file

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

View file

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

View file

@ -42,7 +42,7 @@ requirements:
options:
filters:
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
and filter2) .
zone:
@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a instance facts
- name: " a instance facts"
gcp_compute_instance_facts:
zone: us-central1-a
filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -225,7 +225,7 @@ items:
- If desired, you can also attach existing non-root persistent disks using
this property. This field is only applicable for persistent disks.
returned: success
type: str
type: dict
type:
description:
- 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
live in the same region as the zone of the instance.
returned: success
type: str
type: dict
type:
description:
- 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
subnetwork is specified, the network is inferred.
returned: success
type: str
type: dict
networkIP:
description:
- 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 custom subnet mode, then this field should be specified.
returned: success
type: str
type: dict
scheduling:
description:
- Sets the scheduling options for this instance.
@ -493,7 +493,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

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

View file

@ -70,10 +70,10 @@ options:
group uses this template to create all new instances in the managed instance
group.
- 'This field represents a link to a InstanceTemplate resource in GCP. It can
be specified in two ways. 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_instance_template task and then set this instance_template field
to "{{ name-of-resource }}"'
be specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_instance_template task and then set this
instance_template field to "{{ name-of-resource }}"'
required: true
name:
description:
@ -117,43 +117,43 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "network-instancetemplate"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: network
- name: create a address
gcp_compute_address:
name: "address-instancetemplate"
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: address-instancetemplate
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: address
- name: create a instance template
gcp_compute_instance_template:
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: test-config
type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: test-config
type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancetemplate
- name: create a instance group manager
@ -261,13 +261,13 @@ instanceGroup:
description:
- The instance group being managed.
returned: success
type: str
type: dict
instanceTemplate:
description:
- The instance template that is specified for this managed instance group. The group
uses this template to create all new instances in the managed instance group.
returned: success
type: str
type: dict
name:
description:
- 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'),
base_instance_name=dict(required=True, type='str'),
description=dict(type='str'),
instance_template=dict(required=True),
instance_template=dict(required=True, type='dict'),
name=dict(required=True, type='str'),
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'),
zone=dict(required=True, type='str'),
)
@ -537,32 +537,10 @@ class InstanceGroupManagerCurrentactions(object):
self.request = {}
def to_request(self):
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'),
}
)
return remove_nones_from_dict({})
def from_response(self):
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'),
}
)
return remove_nones_from_dict({})
class InstanceGroupManagerNamedportsArray(object):

View file

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

View file

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

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a instance template facts
- name: " a instance template facts"
gcp_compute_instance_template_facts:
filters:
- name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -250,7 +250,7 @@ items:
- Note that for InstanceTemplate, specify the disk name, not the URL
for the disk.
returned: success
type: str
type: dict
type:
description:
- 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
address, it must live in the same region as the zone of the instance.
returned: success
type: str
type: dict
type:
description:
- 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
but the subnetwork is specified, the network is inferred.
returned: success
type: str
type: dict
networkIP:
description:
- 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
should be specified.
returned: success
type: str
type: dict
scheduling:
description:
- Sets the scheduling options for this instance.
@ -482,7 +482,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

@ -51,12 +51,30 @@ options:
interconnect:
description:
- URL of the underlying Interconnect object that this attachment's traffic will
traverse through.
required: true
traverse through. Required if type is DEDICATED, must not be set if type is
PARTNER.
required: false
description:
description:
- An optional description of this resource.
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:
description:
- 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
the Cloud Router is configured.
- '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
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_router
task and then set this router field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_router task and then set this router field to "{{ name-of-resource
}}"'
required: true
name:
description:
@ -89,7 +108,8 @@ options:
required: false
vlan_tag8021q:
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
region:
description:
@ -101,14 +121,14 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a interconnect attachment
gcp_compute_interconnect_attachment:
name: "test_object"
region: us-central1
project: "test_project"
auth_kind: "serviceaccount"
interconnect: https://googleapis.com/compute/v1/projects/test_project/global/interconnects/...
router: https://googleapis.com/compute/v1/projects/test_project/regions/us-central1/routers/...
service_account_file: "/tmp/auth.pem"
state: present
name: test_object
region: us-central1
project: test_project
auth_kind: serviceaccount
interconnect: https://googleapis.com/compute/v1/projects/test_project/global/interconnects/...
router: https://googleapis.com/compute/v1/projects/test_project/regions/us-central1/routers/...
service_account_file: "/tmp/auth.pem"
state: present
register: disk
'''
@ -128,7 +148,7 @@ customerRouterIpAddress:
interconnect:
description:
- 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
type: str
description:
@ -136,6 +156,30 @@ description:
- An optional description of this resource.
returned: success
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:
description:
- Information specific to an InterconnectAttachment. This property is populated
@ -149,6 +193,16 @@ privateInterconnectInfo:
going to and from this network and region.
returned: success
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:
description:
- 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
Cloud Router is configured.
returned: success
type: str
type: dict
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
@ -196,7 +250,8 @@ candidateSubnets:
type: list
vlanTag8021q:
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
type: int
region:
@ -226,9 +281,11 @@ def main():
module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
interconnect=dict(required=True, type='str'),
interconnect=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'),
candidate_subnets=dict(type='list', elements='str'),
vlan_tag8021q=dict(type='int'),
@ -273,7 +330,8 @@ def create(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):
@ -286,6 +344,8 @@ def resource_to_request(module):
u'kind': 'compute#interconnectAttachment',
u'interconnect': module.params.get('interconnect'),
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'name': module.params.get('name'),
u'candidateSubnets': module.params.get('candidate_subnets'),
@ -359,7 +419,12 @@ def response_to_hash(module, response):
u'customerRouterIpAddress': response.get(u'customerRouterIpAddress'),
u'interconnect': response.get(u'interconnect'),
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'type': response.get(u'type'),
u'state': response.get(u'state'),
u'googleReferenceId': response.get(u'googleReferenceId'),
u'router': response.get(u'router'),
u'creationTimestamp': response.get(u'creationTimestamp'),
@ -423,10 +488,10 @@ class InterconnectAttachmentPrivateinterconnectinfo(object):
self.request = {}
def to_request(self):
return remove_nones_from_dict({u'tag8021q': self.request.get('tag8021q')})
return remove_nones_from_dict({})
def from_response(self):
return remove_nones_from_dict({u'tag8021q': self.request.get(u'tag8021q')})
return remove_nones_from_dict({})
if __name__ == '__main__':

View file

@ -53,19 +53,20 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a interconnect attachment facts
- name: " a interconnect attachment facts"
gcp_compute_interconnect_attachment_facts:
region: us-central1
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
region: us-central1
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -84,7 +85,8 @@ items:
interconnect:
description:
- 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
type: str
description:
@ -92,6 +94,30 @@ items:
- An optional description of this resource.
returned: success
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:
description:
- Information specific to an InterconnectAttachment. This property is populated
@ -105,6 +131,16 @@ items:
customer, going to and from this network and region.
returned: success
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:
description:
- 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
which the Cloud Router is configured.
returned: success
type: str
type: dict
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
@ -153,7 +189,8 @@ items:
type: list
vlanTag8021q:
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
type: int
region:
@ -185,7 +222,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a network facts
- name: " a network facts"
gcp_compute_network_facts:
filters:
- name = test_object
@ -59,22 +59,21 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
description:
description:
- An optional description of this resource. Provide this property when you create
the resource.
- An optional description of this resource. The resource must be recreated to
modify this field.
returned: success
type: str
gateway_ipv4:
description:
- A gateway address for default routing to other networks. This value is read
only and is selected by the Google Compute Engine, typically as the first
usable address in the IPv4Range.
- The gateway address for default routing out of the network. This value is
selected by GCP.
returned: success
type: str
id:
@ -84,9 +83,13 @@ items:
type: int
ipv4_range:
description:
- 'The range of internal addresses that are legal on this network. This range
is a CIDR specification, for example: 192.168.0.0/16. Provided by the client
when the network is created.'
- If this field is specified, a deprecated legacy network is created.
- You will no longer be able to create a legacy network on Feb 1, 2020.
- 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
type: str
name:
@ -106,10 +109,11 @@ items:
type: list
autoCreateSubnetworks:
description:
- When set to true, the network is created in "auto subnet mode". When set to
false, the network is in "custom subnet mode".
- In "auto subnet mode", a newly created network is assigned the default CIDR
of 10.128.0.0/9 and it automatically creates one subnetwork per region.
- When set to `true`, the network is created in "auto subnet mode" and it will
create a subnet for each region automatically across the `10.128.0.0/9` address
range.
- When set to `false`, the network is created in "custom subnet mode" so the
user can explicitly connect subnetwork resources.
returned: success
type: bool
creationTimestamp:
@ -126,9 +130,9 @@ items:
contains:
routingMode:
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
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
regions.
returned: success
@ -157,7 +161,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
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
snapshot.
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:
description:
- 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
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
source_snapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
or full URL to the resource.
- '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
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_snapshot
task and then set this source_snapshot field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_snapshot task and then set this source_snapshot field to "{{
name-of-resource }}"'
required: false
source_snapshot_encryption_key:
description:
@ -143,11 +147,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)'
@ -157,18 +156,18 @@ notes:
EXAMPLES = '''
- name: create a region disk
gcp_compute_region_disk:
name: "test_object"
size_gb: 50
disk_encryption_key:
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
region: us-central1
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-b
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
name: test_object
size_gb: 50
disk_encryption_key:
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
region: us-central1
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-b
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''
@ -240,6 +239,15 @@ users:
.'
returned: success
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:
description:
- 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
or full URL to the resource.
returned: success
type: str
type: dict
sourceSnapshotEncryptionKey:
description:
- 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'),
name=dict(required=True, type='str'),
size_gb=dict(type='int'),
physical_block_size_bytes=dict(type='int'),
replica_zones=dict(required=True, type='list', elements='str'),
type=dict(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'))),
source_snapshot=dict(),
source_snapshot_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(type='dict'),
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'name': module.params.get('name'),
u'sizeGb': module.params.get('size_gb'),
u'physicalBlockSizeBytes': module.params.get('physical_block_size_bytes'),
u'replicaZones': module.params.get('replica_zones'),
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'sizeGb': response.get(u'sizeGb'),
u'users': response.get(u'users'),
u'physicalBlockSizeBytes': response.get(u'physicalBlockSizeBytes'),
u'replicaZones': response.get(u'replicaZones'),
u'type': response.get(u'type'),
}
@ -575,10 +586,10 @@ class RegionDiskDiskencryptionkey(object):
self.request = {}
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):
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):
@ -590,10 +601,10 @@ class RegionDiskSourcesnapshotencryptionkey(object):
self.request = {}
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):
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__':

View file

@ -53,19 +53,20 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a region disk facts
- name: " a region disk facts"
gcp_compute_region_disk_facts:
region: us-central1
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
region: us-central1
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -137,6 +138,15 @@ items:
.'
returned: success
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:
description:
- 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
or full URL to the resource.
returned: success
type: str
type: dict
sourceSnapshotEncryptionKey:
description:
- The customer-supplied encryption key of the source snapshot. Required if the
@ -237,7 +247,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a route facts
- name: " a route facts"
gcp_compute_route_facts:
filters:
- name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -90,7 +90,7 @@ items:
description:
- The network that this route applies to.
returned: success
type: str
type: dict
priority:
description:
- 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
.'
returned: success
type: str
type: dict
nextHopIp:
description:
- Network IP address of an instance that should handle matching packets.
@ -131,7 +131,7 @@ items:
description:
- URL to a VpnTunnel that should handle matching packets.
returned: success
type: str
type: dict
nextHopNetwork:
description:
- URL to a Network that should handle matching packets.
@ -161,7 +161,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

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

View file

@ -216,7 +216,8 @@ def create(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):

View file

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

View file

@ -403,10 +403,10 @@ class SslPolicyWarningsArray(object):
return items
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):
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__':

View file

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

View file

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

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a subnetwork facts
- name: " a subnetwork facts"
gcp_compute_subnetwork_facts:
region: us-west1
filters:
@ -64,8 +64,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -114,7 +114,7 @@ items:
- The network this subnet belongs to.
- Only networks that are in the distributed mode can have subnetworks.
returned: success
type: str
type: dict
enableFlowLogs:
description:
- Whether to enable flow logging for this subnetwork.
@ -152,8 +152,8 @@ items:
type: str
privateIpGoogleAccess:
description:
- Whether the VMs in this subnet can access Google services without assigned
external IP addresses.
- When enabled, VMs in this subnetwork without external IP addresses can access
Google APIs and services by using Private Google Access.
returned: success
type: bool
region:
@ -185,7 +185,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
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
BackendService.
- '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
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_url_map
task and then set this url_map field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_url_map task and then set this url_map field to "{{ name-of-resource
}}"'
required: true
extends_documentation_fragment: gcp
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)'
'''
EXAMPLES = '''
- name: create a instance group
gcp_compute_instance_group:
name: "instancegroup-targethttpproxy"
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: instancegroup-targethttpproxy
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancegroup
- name: create a http health check
gcp_compute_http_health_check:
name: "httphealthcheck-targethttpproxy"
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: httphealthcheck-targethttpproxy
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: healthcheck
- name: create a backend service
gcp_compute_backend_service:
name: "backendservice-targethttpproxy"
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: true
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: backendservice-targethttpproxy
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: backendservice
- name: create a url map
gcp_compute_url_map:
name: "urlmap-targethttpproxy"
default_service: "{{ backendservice }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: urlmap-targethttpproxy
default_service: "{{ backendservice }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: urlmap
- name: create a target http proxy
@ -164,7 +165,7 @@ urlMap:
description:
- A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
returned: success
type: str
type: dict
'''
################################################################################
@ -188,7 +189,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'),
description=dict(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 = '''
- name: a target http proxy facts
- name: " a target http proxy facts"
gcp_compute_target_http_proxy_facts:
filters:
- name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -94,7 +94,7 @@ items:
- A reference to the UrlMap resource that defines the mapping from URL to the
BackendService.
returned: success
type: str
type: dict
'''
################################################################################
@ -119,7 +119,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
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
configured.
- '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
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_ssl_policy
task and then set this ssl_policy field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_ssl_policy task and then set this ssl_policy field to "{{ name-of-resource
}}"'
required: false
version_added: 2.8
url_map:
@ -96,96 +97,85 @@ options:
- A reference to the UrlMap resource that defines the mapping from URL to the
BackendService.
- 'This field represents a link to a UrlMap resource in GCP. It can be specified
in two ways. 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_url_map
task and then set this url_map field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_url_map task and then set this url_map field to "{{ name-of-resource
}}"'
required: true
extends_documentation_fragment: gcp
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)'
'''
EXAMPLES = '''
- name: create a instance group
gcp_compute_instance_group:
name: "instancegroup-targethttpsproxy"
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: instancegroup-targethttpsproxy
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancegroup
- name: create a http health check
gcp_compute_http_health_check:
name: "httphealthcheck-targethttpsproxy"
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: httphealthcheck-targethttpsproxy
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: healthcheck
- name: create a backend service
gcp_compute_backend_service:
name: "backendservice-targethttpsproxy"
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: true
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: backendservice-targethttpsproxy
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: backendservice
- name: create a url map
gcp_compute_url_map:
name: "urlmap-targethttpsproxy"
default_service: "{{ backendservice }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: urlmap-targethttpsproxy
default_service: "{{ backendservice }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: urlmap
- name: create a ssl certificate
gcp_compute_ssl_certificate:
name: "sslcert-targethttpsproxy"
description: A certificate for testing. Do not use this certificate in production
certificate: |
-----BEGIN CERTIFICATE-----
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
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
name: sslcert-targethttpsproxy
description: A certificate for testing. Do not use this certificate in production
certificate: "-----BEGIN CERTIFICATE----- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ 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
- name: create a target https proxy
@ -247,12 +237,12 @@ sslPolicy:
resource. If not set, the TargetHttpsProxy resource will not have any SSL policy
configured.
returned: success
type: str
type: dict
urlMap:
description:
- A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
returned: success
type: str
type: dict
'''
################################################################################
@ -277,9 +267,9 @@ def main():
description=dict(type='str'),
name=dict(required=True, type='str'),
quic_override=dict(type='str', choices=['NONE', 'ENABLE', 'DISABLE']),
ssl_certificates=dict(required=True, type='list'),
ssl_policy=dict(),
url_map=dict(required=True),
ssl_certificates=dict(required=True, type='list', elements='dict'),
ssl_policy=dict(type='dict'),
url_map=dict(required=True, type='dict'),
)
)

View file

@ -49,7 +49,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a target https proxy facts
- name: " a target https proxy facts"
gcp_compute_target_https_proxy_facts:
filters:
- name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -111,13 +111,13 @@ items:
resource. If not set, the TargetHttpsProxy resource will not have any SSL
policy configured.
returned: success
type: str
type: dict
urlMap:
description:
- A reference to the UrlMap resource that defines the mapping from URL to the
BackendService.
returned: success
type: str
type: dict
'''
################################################################################
@ -142,7 +142,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
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
with the best effort, or to all instances when no instance is healthy.
- 'This field represents a link to a TargetPool resource in GCP. It can be specified
in two ways. 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_target_pool
task and then set this backup_pool field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_target_pool task and then set this backup_pool field to "{{
name-of-resource }}"'
required: false
description:
description:
@ -90,10 +91,10 @@ options:
checks pass. If not specified it means all member instances will be considered
healthy at all times.
- 'This field represents a link to a HttpHealthCheck resource in GCP. It can be
specified in two ways. 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_http_health_check task and then set this health_check field to
"{{ name-of-resource }}"'
specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_http_health_check task and then set this
health_check field to "{{ name-of-resource }}"'
required: false
instances:
description:
@ -158,7 +159,7 @@ backupPool:
pool in the "force" mode, where traffic will be spread to the healthy instances
with the best effort, or to all instances when no instance is healthy.
returned: success
type: str
type: dict
creationTimestamp:
description:
- Creation timestamp in RFC3339 text format.
@ -191,7 +192,7 @@ healthCheck:
checks pass. If not specified it means all member instances will be considered
healthy at all times.
returned: success
type: str
type: dict
id:
description:
- The unique identifier for the resource.
@ -249,11 +250,11 @@ def main():
module = GcpModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
backup_pool=dict(),
backup_pool=dict(type='dict'),
description=dict(type='str'),
failover_ratio=dict(type='str'),
health_check=dict(),
instances=dict(type='list'),
health_check=dict(type='dict'),
instances=dict(type='list', elements='dict'),
name=dict(required=True, type='str'),
session_affinity=dict(type='str', choices=['NONE', 'CLIENT_IP', 'CLIENT_IP_PROTO']),
region=dict(required=True, type='str'),

View file

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

View file

@ -73,10 +73,10 @@ options:
description:
- A reference to the BackendService resource.
- 'This field represents a link to a BackendService resource in GCP. It can be
specified in two ways. 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 service field to "{{ name-of-resource
}}"'
specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_backend_service task and then set this service
field to "{{ name-of-resource }}"'
required: true
ssl_certificates:
description:
@ -90,91 +90,80 @@ options:
resource. If not set, the TargetSslProxy resource will not have any SSL policy
configured.
- '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
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_ssl_policy
task and then set this ssl_policy field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''selfLink'' and value
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
to a gcp_compute_ssl_policy task and then set this ssl_policy field to "{{ name-of-resource
}}"'
required: false
version_added: 2.8
extends_documentation_fragment: gcp
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/)'
'''
EXAMPLES = '''
- name: create a instance group
gcp_compute_instance_group:
name: "instancegroup-targetsslproxy"
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: instancegroup-targetsslproxy
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancegroup
- name: create a health check
gcp_compute_health_check:
name: "healthcheck-targetsslproxy"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: healthcheck-targetsslproxy
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: healthcheck
- name: create a backend service
gcp_compute_backend_service:
name: "backendservice-targetsslproxy"
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
protocol: SSL
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: backendservice-targetsslproxy
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
protocol: SSL
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: backendservice
- name: create a ssl certificate
gcp_compute_ssl_certificate:
name: "sslcert-targetsslproxy"
description: A certificate for testing. Do not use this certificate in production
certificate: |
-----BEGIN CERTIFICATE-----
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
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
name: sslcert-targetsslproxy
description: A certificate for testing. Do not use this certificate in production
certificate: "-----BEGIN CERTIFICATE----- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ 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
- name: create a target ssl proxy
@ -225,7 +214,7 @@ service:
description:
- A reference to the BackendService resource.
returned: success
type: str
type: dict
sslCertificates:
description:
- 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
configured.
returned: success
type: str
type: dict
'''
################################################################################
@ -263,9 +252,9 @@ def main():
description=dict(type='str'),
name=dict(required=True, type='str'),
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
service=dict(required=True),
ssl_certificates=dict(required=True, type='list'),
ssl_policy=dict(),
service=dict(required=True, type='dict'),
ssl_certificates=dict(required=True, type='list', elements='dict'),
ssl_policy=dict(type='dict'),
)
)

View file

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

View file

@ -73,57 +73,57 @@ options:
description:
- A reference to the BackendService resource.
- 'This field represents a link to a BackendService resource in GCP. It can be
specified in two ways. 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 service field to "{{ name-of-resource
}}"'
specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_backend_service task and then set this service
field to "{{ name-of-resource }}"'
required: true
extends_documentation_fragment: gcp
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)'
'''
EXAMPLES = '''
- name: create a instance group
gcp_compute_instance_group:
name: "instancegroup-targettcpproxy"
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: instancegroup-targettcpproxy
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancegroup
- name: create a health check
gcp_compute_health_check:
name: "healthcheck-targettcpproxy"
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: healthcheck-targettcpproxy
type: TCP
tcp_health_check:
port_name: service-health
request: ping
response: pong
healthy_threshold: 10
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: healthcheck
- name: create a backend service
gcp_compute_backend_service:
name: "backendservice-targettcpproxy"
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
protocol: TCP
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: backendservice-targettcpproxy
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
protocol: TCP
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: backendservice
- name: create a target tcp proxy
@ -173,7 +173,7 @@ service:
description:
- A reference to the BackendService resource.
returned: success
type: str
type: dict
'''
################################################################################
@ -198,7 +198,7 @@ def main():
description=dict(type='str'),
name=dict(required=True, type='str'),
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 = '''
- name: a target tcp proxy facts
- name: " a target tcp proxy facts"
gcp_compute_target_tcp_proxy_facts:
filters:
- name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -99,7 +99,7 @@ items:
description:
- A reference to the BackendService resource.
returned: success
type: str
type: dict
'''
################################################################################
@ -124,7 +124,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

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

View file

@ -52,10 +52,10 @@ options:
description:
- A reference to BackendService resource if none of the hostRules match.
- 'This field represents a link to a BackendService resource in GCP. It can be
specified in two ways. 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 default_service field to
"{{ name-of-resource }}"'
specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_backend_service task and then set this default_service
field to "{{ name-of-resource }}"'
required: true
description:
description:
@ -102,10 +102,10 @@ options:
- A reference to a BackendService resource. This will be used if none of the
pathRules defined by this PathMatcher is matched by the URL's path portion.
- 'This field represents a link to a BackendService resource in GCP. It can
be specified in two ways. 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 default_service
field to "{{ name-of-resource }}"'
be specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_backend_service task and then set this
default_service field to "{{ name-of-resource }}"'
required: true
description:
description:
@ -131,10 +131,10 @@ options:
description:
- A reference to the BackendService resource if this rule is matched.
- 'This field represents a link to a BackendService resource in GCP. It
can be specified in two ways. 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 service field to "{{ name-of-resource }}"'
can be specified in two ways. First, you can place a dictionary with
key ''selfLink'' and value of your resource''s selfLink Alternatively,
you can add `register: name-of-resource` to a gcp_compute_backend_service
task and then set this service field to "{{ name-of-resource }}"'
required: true
tests:
description:
@ -159,10 +159,10 @@ options:
- A reference to expected BackendService resource the given URL should be
mapped to.
- 'This field represents a link to a BackendService resource in GCP. It can
be specified in two ways. 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 service field to
"{{ name-of-resource }}"'
be specified in two ways. First, you can place a dictionary with key ''selfLink''
and value of your resource''s selfLink Alternatively, you can add `register:
name-of-resource` to a gcp_compute_backend_service task and then set this
service field to "{{ name-of-resource }}"'
required: true
extends_documentation_fragment: gcp
'''
@ -170,39 +170,39 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a instance group
gcp_compute_instance_group:
name: "instancegroup-urlmap"
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: instancegroup-urlmap
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instancegroup
- name: create a http health check
gcp_compute_http_health_check:
name: "httphealthcheck-urlmap"
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: httphealthcheck-urlmap
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: healthcheck
- name: create a backend service
gcp_compute_backend_service:
name: "backendservice-urlmap"
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: true
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: backendservice-urlmap
backends:
- group: "{{ instancegroup }}"
health_checks:
- "{{ healthcheck.selfLink }}"
enable_cdn: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: backendservice
- name: create a url map
@ -225,7 +225,7 @@ defaultService:
description:
- A reference to BackendService resource if none of the hostRules match.
returned: success
type: str
type: dict
description:
description:
- 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
pathRules defined by this PathMatcher is matched by the URL's path portion.
returned: success
type: str
type: dict
description:
description:
- An optional description of this resource.
@ -318,7 +318,7 @@ pathMatchers:
description:
- A reference to the BackendService resource if this rule is matched.
returned: success
type: str
type: dict
tests:
description:
- 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
to.
returned: success
type: str
type: dict
'''
################################################################################
@ -368,7 +368,7 @@ def main():
module = GcpModule(
argument_spec=dict(
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'),
host_rules=dict(
type='list',
@ -382,11 +382,13 @@ def main():
type='list',
elements='dict',
options=dict(
default_service=dict(required=True),
default_service=dict(required=True, type='dict'),
description=dict(type='str'),
name=dict(required=True, type='str'),
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',
elements='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 = '''
- name: a url map facts
- name: " a url map facts"
gcp_compute_url_map_facts:
filters:
- name = test_object
@ -59,8 +59,8 @@ EXAMPLES = '''
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -73,7 +73,7 @@ items:
description:
- A reference to BackendService resource if none of the hostRules match.
returned: success
type: str
type: dict
description:
description:
- 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
portion.
returned: success
type: str
type: dict
description:
description:
- An optional description of this resource.
@ -167,7 +167,7 @@ items:
description:
- A reference to the BackendService resource if this rule is matched.
returned: success
type: str
type: dict
tests:
description:
- 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
mapped to.
returned: success
type: str
type: dict
'''
################################################################################
@ -220,7 +220,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

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

View file

@ -170,20 +170,6 @@ options:
Because the master endpoint is open to the Internet, you should create a
strong password.
required: false
cluster_ca_certificate:
description:
- Base64-encoded public certificate that is the root of trust for the cluster.
required: false
client_certificate:
description:
- Base64-encoded public certificate used by clients to authenticate to the
cluster endpoint.
required: false
client_key:
description:
- Base64-encoded private key used by clients to authenticate to the cluster
endpoint.
required: false
logging_service:
description:
- 'The logging service the cluster should use to write logs. Currently available
@ -210,6 +196,31 @@ options:
- The name of the Google Compute Engine network to which the cluster is connected.
If left unspecified, the default network will be used.
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:
description:
- The IP address range of the container pods in this cluster, in CIDR notation
@ -265,7 +276,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a cluster
gcp_container_cluster:
name: my-cluster
name: "test_object"
initial_node_count: 2
master_auth:
username: cluster_admin
@ -273,7 +284,7 @@ EXAMPLES = '''
node_config:
machine_type: n1-standard-4
disk_size_gb: 500
location: us-central1-a
zone: us-central1-a
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
@ -459,6 +470,42 @@ network:
If left unspecified, the default network will be used.
returned: success
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:
description:
- 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'),
),
),
master_auth=dict(
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'),
),
),
master_auth=dict(type='dict', options=dict(username=dict(type='str'), password=dict(type='str'))),
logging_service=dict(type='str', choices=['logging.googleapis.com', 'none']),
monitoring_service=dict(type='str', choices=['monitoring.googleapis.com', 'none']),
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'),
addons_config=dict(
type='dict',
@ -684,6 +726,7 @@ def resource_to_request(module):
u'loggingService': module.params.get('logging_service'),
u'monitoringService': module.params.get('monitoring_service'),
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'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(),
u'subnetwork': module.params.get('subnetwork'),
@ -761,6 +804,7 @@ def response_to_hash(module, response):
u'loggingService': response.get(u'loggingService'),
u'monitoringService': response.get(u'monitoringService'),
u'network': response.get(u'network'),
u'privateClusterConfig': ClusterPrivateclusterconfig(response.get(u'privateClusterConfig', {}), module).from_response(),
u'clusterIpv4Cidr': response.get(u'clusterIpv4Cidr'),
u'addonsConfig': ClusterAddonsconfig(response.get(u'addonsConfig', {}), module).from_response(),
u'subnetwork': response.get(u'subnetwork'),
@ -874,25 +918,36 @@ class ClusterMasterauth(object):
else:
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):
return remove_nones_from_dict(
{
u'username': self.request.get('username'),
u'password': self.request.get('password'),
u'clusterCaCertificate': self.request.get('cluster_ca_certificate'),
u'clientCertificate': self.request.get('client_certificate'),
u'clientKey': self.request.get('client_key'),
u'enablePrivateNodes': self.request.get('enable_private_nodes'),
u'enablePrivateEndpoint': self.request.get('enable_private_endpoint'),
u'masterIpv4CidrBlock': self.request.get('master_ipv4_cidr_block'),
}
)
def from_response(self):
return remove_nones_from_dict(
{
u'username': self.request.get(u'username'),
u'password': self.request.get(u'password'),
u'clusterCaCertificate': self.request.get(u'clusterCaCertificate'),
u'clientCertificate': self.request.get(u'clientCertificate'),
u'clientKey': self.request.get(u'clientKey'),
u'enablePrivateNodes': self.request.get(u'enablePrivateNodes'),
u'enablePrivateEndpoint': self.request.get(u'enablePrivateEndpoint'),
u'masterIpv4CidrBlock': self.request.get(u'masterIpv4CidrBlock'),
}
)

View file

@ -52,12 +52,13 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a cluster facts
- name: " a cluster facts"
gcp_container_cluster_facts:
location: us-central1-a
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
location: us-central1-a
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
@ -245,6 +246,42 @@ items:
If left unspecified, the default network will be used.
returned: success
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:
description:
- 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
available firewall and routes quota.
required: true
version:
description:
- The version of the Kubernetes of this node.
required: false
version_added: 2.8
autoscaling:
description:
- Autoscaler configuration for this NodePool. Autoscaler is enabled only if a
@ -188,24 +193,15 @@ options:
description:
- Specifies the Auto Upgrade knobs for the node pool.
required: false
suboptions:
auto_upgrade_start_time:
description:
- This field is set when upgrades are about to commence with the approximate
start time for the upgrades, in RFC3339 text format.
required: false
description:
description:
- This field is set when upgrades are about to commence with the description
of the upgrade.
required: false
suboptions: {}
cluster:
description:
- The cluster this node pool belongs to.
- 'This field represents a link to a Cluster resource in GCP. It can be specified
in two ways. 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_container_cluster
task and then set this cluster field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''name'' and value of
your resource''s name Alternatively, you can add `register: name-of-resource`
to a gcp_container_cluster task and then set this cluster field to "{{ name-of-resource
}}"'
required: true
location:
description:
@ -221,21 +217,21 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a cluster
gcp_container_cluster:
name: "cluster-nodepool"
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: cluster-nodepool
initial_node_count: 4
location: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: cluster
- name: create a node pool
gcp_container_node_pool:
name: my-pool
name: "test_object"
initial_node_count: 4
cluster: "{{ cluster }}"
location: us-central1-a
zone: us-central1-a
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
@ -418,7 +414,7 @@ cluster:
description:
- The cluster this node pool belongs to.
returned: success
type: str
type: dict
location:
description:
- The location where the node pool is deployed.
@ -462,16 +458,12 @@ def main():
),
),
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'))),
management=dict(
type='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'))),
),
type='dict', options=dict(auto_upgrade=dict(type='bool'), auto_repair=dict(type='bool'), upgrade_options=dict(type='dict', options=dict()))
),
cluster=dict(required=True),
cluster=dict(required=True, type='dict'),
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'config': NodePoolConfig(module.params.get('config', {}), module).to_request(),
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'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'config': NodePoolConfig(response.get(u'config', {}), module).from_response(),
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'management': NodePoolManagement(response.get(u'management', {}), module).from_response(),
}
@ -755,10 +748,10 @@ class NodePoolUpgradeoptions(object):
self.request = {}
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):
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__':

View file

@ -52,21 +52,23 @@ options:
description:
- The cluster this node pool belongs to.
- 'This field represents a link to a Cluster resource in GCP. It can be specified
in two ways. 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_container_cluster
task and then set this cluster field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''name'' and value of
your resource''s name Alternatively, you can add `register: name-of-resource`
to a gcp_container_cluster task and then set this cluster field to "{{ name-of-resource
}}"'
required: true
extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a node pool facts
- name: " a node pool facts"
gcp_container_node_pool_facts:
cluster: "{{ cluster }}"
location: us-central1-a
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
cluster: "{{ cluster }}"
location: us-central1-a
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
@ -251,7 +253,7 @@ items:
description:
- The cluster this node pool belongs to.
returned: success
type: str
type: dict
location:
description:
- The location where the node pool is deployed.
@ -271,7 +273,7 @@ import json
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']:
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.
required: false
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
notes:
- '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
leave this field unset.
returned: success
type: list
type: str
creationTime:
description:
- 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.
returned: success
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
################################################################################
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
################################################################################
@ -161,8 +217,10 @@ def main():
description=dict(required=True, type='str'),
dns_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'),
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):
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)
@ -216,7 +278,11 @@ def description_update(module, request, response):
auth = GcpSession(module, 'dns')
auth.patch(
''.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'nameServerSet': module.params.get('name_server_set'),
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 = {}
for k, v in request.items():
@ -306,8 +374,52 @@ def response_to_hash(module, response):
u'nameServerSet': response.get(u'nameServerSet'),
u'creationTime': response.get(u'creationTime'),
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__':
main()

View file

@ -47,12 +47,13 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a managed zone facts
- name: " a managed zone facts"
gcp_dns_managed_zone_facts:
dns_name: test.somewild2.example.com.
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
dns_name: test.somewild2.example.com.
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
@ -95,7 +96,7 @@ items:
is a set of DNS name servers that all host the same ManagedZones. Most users
will leave this field unset.
returned: success
type: list
type: str
creationTime:
description:
- 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.
returned: success
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
- SPF
- SRV
- TLSA
- TXT
ttl:
description:
@ -83,11 +84,11 @@ options:
managed_zone:
description:
- Identifies the managed zone addressed by this request.
- Can be the managed zone name or id.
- 'This field represents a link to a ManagedZone resource in GCP. It can be specified
in two ways. 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_dns_managed_zone
task and then set this managed_zone field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''name'' and value of
your resource''s name Alternatively, you can add `register: name-of-resource`
to a gcp_dns_managed_zone task and then set this managed_zone field to "{{ name-of-resource
}}"'
required: true
extends_documentation_fragment: gcp
'''
@ -95,13 +96,13 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a managed zone
gcp_dns_managed_zone:
name: "managedzone-rrs"
dns_name: testzone-4.com.
description: test zone
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: managedzone-rrs
dns_name: testzone-4.com.
description: test zone
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: managed_zone
- name: create a resource record set
@ -143,9 +144,8 @@ target:
managed_zone:
description:
- Identifies the managed zone addressed by this request.
- Can be the managed zone name or id.
returned: success
type: str
type: dict
'''
################################################################################
@ -170,10 +170,10 @@ def main():
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], 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'),
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.
# This is for doing comparisons with Ansible's current parameters.
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):
@ -357,13 +357,12 @@ class SOAForwardable(object):
def prefetch_soa_resource(module):
name = module.params['name'].split('.')[1:]
resource = SOAForwardable(
{
'type': 'SOA',
'managed_zone': module.params['managed_zone'],
'name': '.'.join(name),
'name': replace_resource_dict(module.params['managed_zone'], 'dnsName'),
'project': module.params['project'],
'scopes': module.params['scopes'],
'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')
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

View file

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

View file

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

View file

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

View file

@ -67,9 +67,10 @@ options:
description:
- The name of the serviceAccount.
- '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
as a string Alternatively, you can add `register: name-of-resource` to a gcp_iam_service_account
task and then set this service_account field to "{{ name-of-resource }}"'
specified in two ways. First, you can place a dictionary with key ''name'' and
value of your resource''s name Alternatively, you can add `register: name-of-resource`
to a gcp_iam_service_account task and then set this service_account field to
"{{ name-of-resource }}"'
required: false
path:
description:
@ -83,23 +84,23 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a service account
gcp_iam_service_account:
name: test-ansible@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: test-ansible@graphite-playground.google.com.iam.gserviceaccount.com
display_name: My Ansible test key
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: serviceaccount
- name: create a service account key
gcp_iam_service_account_key:
service_account: "{{ serviceaccount }}"
private_key_type: TYPE_GOOGLE_CREDENTIALS_FILE
path: "~/test_account.json"
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
service_account: "{{ serviceaccount }}"
private_key_type: TYPE_GOOGLE_CREDENTIALS_FILE
path: "~/test_account.json"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''
@ -142,7 +143,7 @@ serviceAccount:
description:
- The name of the serviceAccount.
returned: success
type: str
type: dict
path:
description:
- 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'),
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']),
service_account=dict(),
service_account=dict(type='dict'),
path=dict(type='path'),
)
)

View file

@ -51,15 +51,21 @@ options:
name:
description:
- Name of the subscription.
required: false
required: true
topic:
description:
- A reference to a Topic resource.
- 'This field represents a link to a Topic resource in GCP. It can be specified
in two ways. 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_pubsub_topic
task and then set this topic field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''name'' and value of
your resource''s name Alternatively, you can add `register: 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
version_added: 2.8
push_config:
description:
- If push delivery is used with this subscription, this field is used to configure
@ -71,6 +77,25 @@ options:
description:
- A URL locating the endpoint to which messages should be pushed.
- For example, a Webhook endpoint might use "U(https://example.com/push".)
required: 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
ack_deadline_seconds:
description:
@ -89,23 +114,48 @@ options:
- If the subscriber never acknowledges the message, the Pub/Sub system will eventually
redeliver the message.
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
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 = '''
- name: create a topic
gcp_pubsub_topic:
name: "topic-subscription"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: topic-subscription
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: topic
- name: create a subscription
gcp_pubsub_subscription:
name: "test_object"
topic: "{{ topic }}"
push_config:
push_endpoint: https://myapp.graphite.cloudnativeapp.com/webhook/sub1
ack_deadline_seconds: 300
project: "test_project"
auth_kind: "serviceaccount"
@ -123,7 +173,12 @@ topic:
description:
- A reference to a Topic resource.
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:
description:
- 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".)
returned: success
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:
description:
- This value is the maximum time after a subscriber receives a message before the
@ -156,6 +230,24 @@ ackDeadlineSeconds:
redeliver the message.
returned: success
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(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(type='str'),
topic=dict(),
push_config=dict(type='dict', options=dict(push_endpoint=dict(type='str'))),
name=dict(required=True, type='str'),
topic=dict(required=True, type='dict'),
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'),
message_retention_duration=dict(default='604800s', type='str'),
retain_acked_messages=dict(type='bool'),
)
)
@ -194,7 +289,7 @@ def main():
if fetch:
if state == 'present':
if is_different(module, fetch):
update(module, self_link(module))
update(module, self_link(module), fetch)
fetch = fetch_resource(module, self_link(module))
changed = True
else:
@ -218,8 +313,27 @@ def create(module, link):
return return_if_object(module, auth.put(link, resource_to_request(module)))
def update(module, link):
module.fail_json(msg="Subscription cannot be edited")
def update(module, link, fetch):
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):
@ -231,8 +345,11 @@ def resource_to_request(module):
request = {
u'name': module.params.get('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'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)
return_vals = {}
@ -302,10 +419,13 @@ def is_different(module, response):
# This is for doing comparisons with Ansible's current parameters.
def response_to_hash(module, response):
return {
u'name': response.get(u'name'),
u'topic': response.get(u'topic'),
u'name': module.params.get('name'),
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'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 = {}
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):
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__':

View file

@ -44,11 +44,12 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a subscription facts
- name: " a subscription facts"
gcp_pubsub_subscription_facts:
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
@ -66,7 +67,12 @@ items:
description:
- A reference to a Topic resource.
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:
description:
- 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".)
returned: success
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:
description:
- This value is the maximum time after a subscriber receives a message before
@ -100,6 +126,24 @@ items:
eventually redeliver the message.
returned: success
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:
description:
- Name of the topic.
required: true
labels:
description:
- A set of key/value label pairs to assign to this Topic.
required: false
version_added: 2.8
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 = '''
@ -70,6 +78,11 @@ name:
- Name of the topic.
returned: success
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():
"""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']:
module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub']
@ -125,8 +142,8 @@ def create(module, link):
def update(module, link):
auth = GcpSession(module, 'pubsub')
return return_if_object(module, auth.put(link, resource_to_request(module)))
delete(module, self_link(module))
create(module, self_link(module))
def delete(module, link):
@ -135,7 +152,7 @@ def delete(module, link):
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)
return_vals = {}
for k, v in request.items():
@ -203,7 +220,7 @@ def is_different(module, response):
# Remove unnecessary properties from the response.
# This is for doing comparisons with Ansible's current parameters.
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):

View file

@ -44,11 +44,12 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a topic facts
- name: " a topic facts"
gcp_pubsub_topic_facts:
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
@ -62,6 +63,11 @@ items:
- Name of the topic.
returned: success
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 = '''
- name: create a network
gcp_compute_network:
name: "network-instance"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: network-instance
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: network
- name: create a instance
gcp_redis_instance:
name: instance37
tier: STANDARD_HA
memory_size_gb: 1
region: us-central1
location_id: us-central1-a
redis_version: REDIS_3_2
display_name: Ansible Test Instance
reserved_ip_range: 192.168.0.0/29
labels:
my_key: my_val
other_key: other_val
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
name: instance37
tier: STANDARD_HA
memory_size_gb: 1
region: us-central1
location_id: us-central1-a
redis_version: REDIS_3_2
display_name: Ansible Test Instance
reserved_ip_range: 192.168.0.0/29
labels:
my_key: my_val
other_key: other_val
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''

View file

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

View file

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

View file

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

View file

@ -62,11 +62,11 @@ notes:
EXAMPLES = '''
- name: create a repository
gcp_sourcerepo_repository:
name: projects/test_project/repos/test_object
project: "test_project"
auth_kind: "serviceaccount"
service_account_file: "/tmp/auth.pem"
state: present
name: projects/test_project/repos/test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
RETURN = '''
@ -142,7 +142,8 @@ def create(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):

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -59,14 +59,10 @@ options:
description:
- The name of the database in the Cloud SQL instance.
- This does not include the project ID or instance name.
required: false
required: true
instance:
description:
- The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. 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
extends_documentation_fragment: gcp
'''
@ -74,18 +70,18 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a instance
gcp_sql_instance:
name: "{{resource_name}}-3"
settings:
ip_configuration:
authorized_networks:
- name: google dns server
value: 8.8.8.8/32
tier: db-n1-standard-1
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: "{{resource_name}}-3"
settings:
ip_configuration:
authorized_networks:
- name: google dns server
value: 8.8.8.8/32
tier: db-n1-standard-1
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: instance
- name: create a database
@ -144,8 +140,8 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'),
charset=dict(type='str'),
collation=dict(type='str'),
name=dict(type='str'),
instance=dict(required=True),
name=dict(required=True, type='str'),
instance=dict(required=True, type='str'),
)
)
@ -198,6 +194,7 @@ def delete(module, link, kind):
def resource_to_request(module):
request = {
u'kind': 'sql#database',
u'instance': module.params.get('instance'),
u'charset': module.params.get('charset'),
u'collation': module.params.get('collation'),
u'name': module.params.get('name'),
@ -216,13 +213,11 @@ def fetch_resource(module, link, kind, allow_not_found=True):
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(**res)
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases/{name}".format(**module.params)
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(**res)
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**module.params)
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.
# This is for doing comparisons with Ansible's current parameters.
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):

View file

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

View file

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

View file

@ -44,16 +44,17 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a instance facts
- name: " a instance facts"
gcp_sql_instance_facts:
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
items:
description: List of items
resources:
description: List of resources
returned: always
type: complex
contains:
@ -312,6 +313,34 @@ items:
Generation (recommended) or First Generation.
returned: success
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:
description:
- The version of instance settings. This is a required field for update
@ -344,7 +373,7 @@ def main():
items = items.get('items')
else:
items = []
return_value = {'items': items}
return_value = {'resources': items}
module.exit_json(**return_value)

View file

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

View file

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

View file

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

View file

@ -60,9 +60,10 @@ options:
description:
- The name of the bucket.
- '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
Alternatively, you can add `register: name-of-resource` to a gcp_storage_bucket
task and then set this bucket field to "{{ name-of-resource }}"'
in two ways. First, you can place a dictionary with key ''name'' and value of
your resource''s name Alternatively, you can add `register: name-of-resource`
to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
}}"'
required: true
entity:
description:
@ -108,16 +109,16 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a bucket
gcp_storage_bucket:
name: "{{ resource_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
name: "{{ resource_name }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: bucket
- name: create a bucket access control
gcp_storage_bucket_access_control:
bucket: "test_object"
bucket: "{{ bucket }}"
entity: user-alexstephen@google.com
role: WRITER
project: "test_project"
@ -131,7 +132,7 @@ bucket:
description:
- The name of the bucket.
returned: success
type: str
type: dict
domain:
description:
- The domain associated with the entity.
@ -203,7 +204,7 @@ def main():
module = GcpModule(
argument_spec=dict(
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_id=dict(type='str'),
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']
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
if fetch:

View file

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