mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-09 04:10:27 -07:00
Partial updates (#63)
This commit is contained in:
parent
3382f7f7b2
commit
2837b2f836
13 changed files with 1165 additions and 877 deletions
|
@ -204,6 +204,12 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
|
label_fingerprint:
|
||||||
|
description:
|
||||||
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
|
updates.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
creation_timestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
|
@ -430,8 +436,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind, fetch)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -455,7 +460,8 @@ def create(module, link, kind):
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind, fetch):
|
def update(module, link, kind, fetch):
|
||||||
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
|
update_fields(module, resource_to_request(module),
|
||||||
|
response_to_hash(module, fetch))
|
||||||
return fetch_resource(module, self_link(module), kind)
|
return fetch_resource(module, self_link(module), kind)
|
||||||
|
|
||||||
|
|
||||||
|
@ -469,16 +475,27 @@ def update_fields(module, request, response):
|
||||||
def label_fingerprint_update(module, request, response):
|
def label_fingerprint_update(module, request, response):
|
||||||
auth = GcpSession(module, 'compute')
|
auth = GcpSession(module, 'compute')
|
||||||
auth.post(
|
auth.post(
|
||||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/setLabels"]).format(**module.params),
|
''.join([
|
||||||
{u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/zones/{zone}/disks/{name}/setLabels"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'labelFingerprint': response.get('labelFingerprint'),
|
||||||
|
u'labels': module.params.get('labels')
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def size_gb_update(module, request, response):
|
def size_gb_update(module, request, response):
|
||||||
auth = GcpSession(module, 'compute')
|
auth = GcpSession(module, 'compute')
|
||||||
auth.post(
|
auth.post(
|
||||||
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/resize"]).format(**module.params),
|
''.join([
|
||||||
{u'sizeGb': module.params.get('size_gb')},
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/zones/{zone}/disks/{name}/resize"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'sizeGb': module.params.get('size_gb')
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,220 +53,205 @@ extends_documentation_fragment: gcp
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: a disk facts
|
- name: " a disk facts"
|
||||||
gcp_compute_disk_facts:
|
gcp_compute_disk_facts:
|
||||||
zone: us-central1-a
|
zone: us-central1-a
|
||||||
filters:
|
filters:
|
||||||
- name = test_object
|
- name = test_object
|
||||||
project: test_project
|
project: test_project
|
||||||
auth_kind: serviceaccount
|
auth_kind: serviceaccount
|
||||||
service_account_file: "/tmp/auth.pem"
|
service_account_file: "/tmp/auth.pem"
|
||||||
|
state: facts
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
items:
|
items:
|
||||||
description: List of items
|
description: List of items
|
||||||
returned: always
|
returned: always
|
||||||
type: complex
|
type: complex
|
||||||
contains:
|
contains:
|
||||||
labelFingerprint:
|
label_fingerprint:
|
||||||
description:
|
description:
|
||||||
- The fingerprint used for optimistic locking of this resource. Used internally
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
during updates.
|
updates.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
creationTimestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional description of this resource. Provide this property when you create
|
- An optional description of this resource. Provide this property when you create
|
||||||
the resource.
|
the resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
id:
|
id:
|
||||||
description:
|
description:
|
||||||
- The unique identifier for the resource.
|
- The unique identifier for the resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: int
|
type: int
|
||||||
lastAttachTimestamp:
|
last_attach_timestamp:
|
||||||
description:
|
description:
|
||||||
- Last attach timestamp in RFC3339 text format.
|
- Last attach timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
lastDetachTimestamp:
|
last_detach_timestamp:
|
||||||
description:
|
description:
|
||||||
- Last dettach timestamp in RFC3339 text format.
|
- Last dettach timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
labels:
|
labels:
|
||||||
description:
|
description:
|
||||||
- Labels to apply to this disk. A list of key->value pairs.
|
- Labels to apply to this disk. A list of key->value pairs.
|
||||||
returned: success
|
returned: success
|
||||||
type: dict
|
type: dict
|
||||||
licenses:
|
licenses:
|
||||||
description:
|
description:
|
||||||
- Any applicable publicly visible licenses.
|
- Any applicable publicly visible licenses.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Name of the resource. Provided by the client when the resource is created.
|
- Name of the resource. Provided by the client when the resource is created. The name
|
||||||
The name must be 1-63 characters long, and comply with RFC1035. Specifically,
|
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||||
the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||||
which means the first character must be a lowercase letter, and all following
|
which means the first character must be a lowercase letter, and all following characters
|
||||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||||
which cannot be a dash.
|
be a dash.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sizeGb:
|
size_gb:
|
||||||
description:
|
description:
|
||||||
- Size of the persistent disk, specified in GB. You can specify this field when
|
- Size of the persistent disk, specified in GB. You can specify this field when creating
|
||||||
creating a persistent disk using the sourceImage or sourceSnapshot parameter,
|
a persistent disk using the sourceImage or sourceSnapshot parameter, or specify
|
||||||
or specify it alone to create an empty persistent disk.
|
it alone to create an empty persistent disk.
|
||||||
- If you specify this field along with sourceImage or sourceSnapshot, the value
|
- If you specify this field along with sourceImage or sourceSnapshot, the value of
|
||||||
of sizeGb must not be less than the size of the sourceImage or the size of
|
sizeGb must not be less than the size of the sourceImage or the size of the snapshot.
|
||||||
the snapshot.
|
returned: success
|
||||||
returned: success
|
type: int
|
||||||
type: int
|
users:
|
||||||
users:
|
description:
|
||||||
description:
|
- 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
|
||||||
- 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
|
.'
|
||||||
.'
|
returned: success
|
||||||
returned: success
|
type: list
|
||||||
type: list
|
type:
|
||||||
type:
|
description:
|
||||||
description:
|
- URL of the disk type resource describing which disk type to use to create the disk.
|
||||||
- URL of the disk type resource describing which disk type to use to create
|
Provide this when creating the disk.
|
||||||
the disk. Provide this when creating the disk.
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
source_image:
|
||||||
sourceImage:
|
description:
|
||||||
description:
|
- The source image used to create this disk. If the source image is deleted, this
|
||||||
- The source image used to create this disk. If the source image is deleted,
|
field will not be set.
|
||||||
this field will not be set.
|
- 'To create a disk with one of the public operating system images, specify the image
|
||||||
- 'To create a disk with one of the public operating system images, specify
|
by its family name. For example, specify family/debian-8 to use the latest Debian
|
||||||
the image by its family name. For example, specify family/debian-8 to use
|
8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively, use
|
||||||
the latest Debian 8 image: projects/debian-cloud/global/images/family/debian-8
|
a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To
|
||||||
Alternatively, use a specific version of a public operating system image:
|
create a disk with a private image that you created, specify the image name in the
|
||||||
projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To create a
|
following format: global/images/my-private-image You can also specify a private
|
||||||
disk with a private image that you created, specify the image name in the
|
image by its image family, which returns the latest version of the image in that
|
||||||
following format: global/images/my-private-image You can also specify a private
|
family. Replace the image name with family/family-name: global/images/family/my-private-family
|
||||||
image by its image family, which returns the latest version of the image in
|
.'
|
||||||
that family. Replace the image name with family/family-name: global/images/family/my-private-family
|
returned: success
|
||||||
.'
|
type: str
|
||||||
returned: success
|
zone:
|
||||||
type: str
|
description:
|
||||||
zone:
|
- A reference to the zone where the disk resides.
|
||||||
description:
|
returned: success
|
||||||
- A reference to the zone where the disk resides.
|
type: str
|
||||||
returned: success
|
source_image_encryption_key:
|
||||||
type: str
|
description:
|
||||||
sourceImageEncryptionKey:
|
- The customer-supplied encryption key of the source image. Required if the source
|
||||||
description:
|
image is protected by a customer-supplied encryption key.
|
||||||
- The customer-supplied encryption key of the source image. Required if the
|
returned: success
|
||||||
source image is protected by a customer-supplied encryption key.
|
type: complex
|
||||||
returned: success
|
contains:
|
||||||
type: complex
|
raw_key:
|
||||||
contains:
|
description:
|
||||||
rawKey:
|
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64
|
||||||
description:
|
to either encrypt or decrypt this resource.
|
||||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
returned: success
|
||||||
base64 to either encrypt or decrypt this resource.
|
type: str
|
||||||
returned: success
|
sha256:
|
||||||
type: str
|
description:
|
||||||
sha256:
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key
|
||||||
description:
|
that protects this resource.
|
||||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
returned: success
|
||||||
key that protects this resource.
|
type: str
|
||||||
returned: success
|
source_image_id:
|
||||||
type: str
|
description:
|
||||||
kmsKeyName:
|
- The ID value of the image used to create this disk. This value identifies the exact
|
||||||
description:
|
image that was used to create this persistent disk. For example, if you created
|
||||||
- The name of the encryption key that is stored in Google Cloud KMS.
|
the persistent disk from an image that was later deleted and recreated under the
|
||||||
returned: success
|
same name, the source image ID would identify the exact version of the image that
|
||||||
type: str
|
was used.
|
||||||
sourceImageId:
|
returned: success
|
||||||
description:
|
type: str
|
||||||
- The ID value of the image used to create this disk. This value identifies
|
disk_encryption_key:
|
||||||
the exact image that was used to create this persistent disk. For example,
|
description:
|
||||||
if you created the persistent disk from an image that was later deleted and
|
- Encrypts the disk using a customer-supplied encryption key.
|
||||||
recreated under the same name, the source image ID would identify the exact
|
- After you encrypt a disk with a customer-supplied key, you must provide the same
|
||||||
version of the image that was used.
|
key if you use the disk later (e.g. to create a disk snapshot or an image, or to
|
||||||
returned: success
|
attach the disk to a virtual machine).
|
||||||
type: str
|
- Customer-supplied encryption keys do not protect access to metadata of the disk.
|
||||||
diskEncryptionKey:
|
- If you do not provide an encryption key when creating the disk, then the disk will
|
||||||
description:
|
be encrypted using an automatically generated key and you do not need to provide
|
||||||
- Encrypts the disk using a customer-supplied encryption key.
|
a key to use the disk later.
|
||||||
- After you encrypt a disk with a customer-supplied key, you must provide the
|
returned: success
|
||||||
same key if you use the disk later (e.g. to create a disk snapshot or an image,
|
type: complex
|
||||||
or to attach the disk to a virtual machine).
|
contains:
|
||||||
- Customer-supplied encryption keys do not protect access to metadata of the
|
raw_key:
|
||||||
disk.
|
description:
|
||||||
- If you do not provide an encryption key when creating the disk, then the disk
|
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64
|
||||||
will be encrypted using an automatically generated key and you do not need
|
to either encrypt or decrypt this resource.
|
||||||
to provide a key to use the disk later.
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: complex
|
sha256:
|
||||||
contains:
|
description:
|
||||||
rawKey:
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key
|
||||||
description:
|
that protects this resource.
|
||||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
returned: success
|
||||||
base64 to either encrypt or decrypt this resource.
|
type: str
|
||||||
returned: success
|
source_snapshot:
|
||||||
type: str
|
description:
|
||||||
sha256:
|
- 'The source snapshot used to create this disk. You can provide this as a partial
|
||||||
description:
|
or full URL to the resource. For example, the following are valid values: *
|
||||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
`U(https://www.googleapis.com/compute/v1/projects/project/global/snapshots/snapshot`)
|
||||||
key that protects this resource.
|
* `projects/project/global/snapshots/snapshot` * `global/snapshots/snapshot` .'
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: dict
|
||||||
kmsKeyName:
|
source_snapshot_encryption_key:
|
||||||
description:
|
description:
|
||||||
- The name of the encryption key that is stored in Google Cloud KMS.
|
- The customer-supplied encryption key of the source snapshot. Required if the source
|
||||||
returned: success
|
snapshot is protected by a customer-supplied encryption key.
|
||||||
type: str
|
returned: success
|
||||||
sourceSnapshot:
|
type: complex
|
||||||
description:
|
contains:
|
||||||
- The source snapshot used to create this disk. You can provide this as a partial
|
raw_key:
|
||||||
or full URL to the resource.
|
description:
|
||||||
returned: success
|
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64
|
||||||
type: str
|
to either encrypt or decrypt this resource.
|
||||||
sourceSnapshotEncryptionKey:
|
returned: success
|
||||||
description:
|
type: str
|
||||||
- The customer-supplied encryption key of the source snapshot. Required if the
|
sha256:
|
||||||
source snapshot is protected by a customer-supplied encryption key.
|
description:
|
||||||
returned: success
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key
|
||||||
type: complex
|
that protects this resource.
|
||||||
contains:
|
returned: success
|
||||||
rawKey:
|
type: str
|
||||||
description:
|
source_snapshot_id:
|
||||||
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
|
description:
|
||||||
base64 to either encrypt or decrypt this resource.
|
- The unique ID of the snapshot used to create this disk. This value identifies the
|
||||||
returned: success
|
exact snapshot that was used to create this persistent disk. For example, if you
|
||||||
type: str
|
created the persistent disk from a snapshot that was later deleted and recreated
|
||||||
kmsKeyName:
|
under the same name, the source snapshot ID would identify the exact version of
|
||||||
description:
|
the snapshot that was used.
|
||||||
- The name of the encryption key that is stored in Google Cloud KMS.
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
|
||||||
sha256:
|
|
||||||
description:
|
|
||||||
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
|
||||||
key that protects this resource.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
sourceSnapshotId:
|
|
||||||
description:
|
|
||||||
- The unique ID of the snapshot used to create this disk. This value identifies
|
|
||||||
the exact snapshot that was used to create this persistent disk. For example,
|
|
||||||
if you created the persistent disk from a snapshot that was later deleted
|
|
||||||
and recreated under the same name, the source snapshot ID would identify the
|
|
||||||
exact version of the snapshot that was used.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -291,7 +276,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {'items': items}
|
return_value = {'resources': items}
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -91,19 +91,17 @@ options:
|
||||||
- ICMP
|
- ICMP
|
||||||
backend_service:
|
backend_service:
|
||||||
description:
|
description:
|
||||||
- A reference to a BackendService to receive the matched traffic.
|
- A BackendService to receive the matched traffic. This is used only for INTERNAL
|
||||||
- This is used for internal load balancing.
|
load balancing.
|
||||||
- "(not used for external load balancing) ."
|
|
||||||
- 'This field represents a link to a BackendService resource in GCP. It can be
|
- 'This field represents a link to a BackendService resource in GCP. It can be
|
||||||
specified in two ways. First, you can place in the selfLink of the resource
|
specified in two ways. First, you can place a dictionary with key ''selfLink''
|
||||||
here as a string Alternatively, you can add `register: name-of-resource` to
|
and value of your resource''s selfLink Alternatively, you can add `register:
|
||||||
a gcp_compute_backend_service task and then set this backend_service field to
|
name-of-resource` to a gcp_compute_backend_service task and then set this backend_service
|
||||||
"{{ name-of-resource }}"'
|
field to "{{ name-of-resource }}"'
|
||||||
required: false
|
required: false
|
||||||
ip_version:
|
ip_version:
|
||||||
description:
|
description:
|
||||||
- The IP Version that will be used by this forwarding rule. Valid options are
|
- ipVersion is not a valid field for regional forwarding rules.
|
||||||
IPV4 or IPV6. This can only be specified for a global forwarding rule.
|
|
||||||
required: false
|
required: false
|
||||||
choices:
|
choices:
|
||||||
- IPV4
|
- IPV4
|
||||||
|
@ -133,11 +131,12 @@ options:
|
||||||
- For internal load balancing, this field identifies the network that the load
|
- 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
|
balanced IP should belong to for this Forwarding Rule. If this field is not
|
||||||
specified, the default network will be used.
|
specified, the default network will be used.
|
||||||
- This field is not used for external load balancing.
|
- This field is only used for INTERNAL load balancing.
|
||||||
- 'This field represents a link to a Network resource in GCP. It can be specified
|
- 'This field represents a link to a Network resource in GCP. It can be specified
|
||||||
in two ways. First, you can place in the selfLink of the resource here as a
|
in two ways. First, you can place a dictionary with key ''selfLink'' and value
|
||||||
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_network
|
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
|
||||||
task and then set this network field to "{{ name-of-resource }}"'
|
to a gcp_compute_network task and then set this network field to "{{ name-of-resource
|
||||||
|
}}"'
|
||||||
required: false
|
required: false
|
||||||
port_range:
|
port_range:
|
||||||
description:
|
description:
|
||||||
|
@ -163,31 +162,38 @@ options:
|
||||||
required: false
|
required: false
|
||||||
subnetwork:
|
subnetwork:
|
||||||
description:
|
description:
|
||||||
- A reference to a subnetwork.
|
- The subnetwork that the load balanced IP should belong to for this Forwarding
|
||||||
- For internal load balancing, this field identifies the subnetwork that the load
|
Rule. This field is only used for INTERNAL load balancing.
|
||||||
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 specified is in auto subnet mode, this field is optional. However,
|
||||||
if the network is in custom subnet mode, a subnetwork must be specified.
|
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
|
- '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
|
in two ways. First, you can place a dictionary with key ''selfLink'' and value
|
||||||
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_subnetwork
|
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
|
||||||
task and then set this subnetwork field to "{{ name-of-resource }}"'
|
to a gcp_compute_subnetwork task and then set this subnetwork field to "{{ name-of-resource
|
||||||
|
}}"'
|
||||||
required: false
|
required: false
|
||||||
target:
|
target:
|
||||||
description:
|
description:
|
||||||
|
- This field is only used for EXTERNAL load balancing.
|
||||||
- A reference to a TargetPool resource to receive the matched traffic.
|
- A reference to a TargetPool resource to receive the matched traffic.
|
||||||
- For regional forwarding rules, this target must live in the same region as the
|
- This target must live in the same region as the forwarding rule.
|
||||||
forwarding rule. For global forwarding rules, this target must be a global load
|
- The forwarded traffic must be of a type appropriate to the target object.
|
||||||
balancing resource. The forwarded traffic must be of a type appropriate to the
|
|
||||||
target object.
|
|
||||||
- This field is not used for internal load balancing.
|
|
||||||
- 'This field represents a link to a TargetPool resource in GCP. It can be specified
|
- 'This field represents a link to a TargetPool resource in GCP. It can be specified
|
||||||
in two ways. First, you can place in the selfLink of the resource here as a
|
in two ways. First, you can place a dictionary with key ''selfLink'' and value
|
||||||
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_target_pool
|
of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
|
||||||
task and then set this target field to "{{ name-of-resource }}"'
|
to a gcp_compute_target_pool task and then set this target field to "{{ name-of-resource
|
||||||
|
}}"'
|
||||||
required: false
|
required: false
|
||||||
version_added: 2.7
|
version_added: 2.7
|
||||||
|
all_ports:
|
||||||
|
description:
|
||||||
|
- For internal TCP/UDP load balancing (i.e. load balancing scheme is INTERNAL
|
||||||
|
and protocol is TCP/UDP), set this to true to allow packets addressed to any
|
||||||
|
ports to be forwarded to the backends configured with this forwarding rule.
|
||||||
|
Used with backend service. Cannot be set if port or portRange are set.
|
||||||
|
required: false
|
||||||
|
type: bool
|
||||||
|
version_added: 2.8
|
||||||
network_tier:
|
network_tier:
|
||||||
description:
|
description:
|
||||||
- 'The networking tier used for configuring this address. This field can take
|
- 'The networking tier used for configuring this address. This field can take
|
||||||
|
@ -198,6 +204,18 @@ options:
|
||||||
choices:
|
choices:
|
||||||
- PREMIUM
|
- PREMIUM
|
||||||
- STANDARD
|
- STANDARD
|
||||||
|
service_label:
|
||||||
|
description:
|
||||||
|
- An optional prefix to the service name for this Forwarding Rule.
|
||||||
|
- If specified, will be the first label of the fully qualified service name.
|
||||||
|
- The label must be 1-63 characters long, and comply with RFC1035.
|
||||||
|
- Specifically, the label must be 1-63 characters long and match the regular expression
|
||||||
|
`[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
|
||||||
|
letter, and all following characters must be a dash, lowercase letter, or digit,
|
||||||
|
except the last character, which cannot be a dash.
|
||||||
|
- This field is only used for INTERNAL load balancing.
|
||||||
|
required: false
|
||||||
|
version_added: 2.8
|
||||||
region:
|
region:
|
||||||
description:
|
description:
|
||||||
- A reference to the region where the regional forwarding rule resides.
|
- A reference to the region where the regional forwarding rule resides.
|
||||||
|
@ -205,188 +223,185 @@ options:
|
||||||
required: true
|
required: true
|
||||||
extends_documentation_fragment: gcp
|
extends_documentation_fragment: gcp
|
||||||
notes:
|
notes:
|
||||||
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/forwardingRule)'
|
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/forwardingRule)'
|
||||||
- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules)'
|
- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules)'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: create a address
|
- name: create a address
|
||||||
gcp_compute_address:
|
gcp_compute_address:
|
||||||
name: "address-forwardingrule"
|
name: address-forwardingrule
|
||||||
region: us-west1
|
region: us-west1
|
||||||
project: "{{ gcp_project }}"
|
project: "{{ gcp_project }}"
|
||||||
auth_kind: "{{ gcp_cred_kind }}"
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
service_account_file: "{{ gcp_cred_file }}"
|
service_account_file: "{{ gcp_cred_file }}"
|
||||||
state: present
|
state: present
|
||||||
register: address
|
register: address
|
||||||
|
|
||||||
- name: create a target pool
|
- name: create a target pool
|
||||||
gcp_compute_target_pool:
|
gcp_compute_target_pool:
|
||||||
name: "targetpool-forwardingrule"
|
name: targetpool-forwardingrule
|
||||||
region: us-west1
|
region: us-west1
|
||||||
project: "{{ gcp_project }}"
|
project: "{{ gcp_project }}"
|
||||||
auth_kind: "{{ gcp_cred_kind }}"
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
service_account_file: "{{ gcp_cred_file }}"
|
service_account_file: "{{ gcp_cred_file }}"
|
||||||
state: present
|
state: present
|
||||||
register: targetpool
|
register: targetpool
|
||||||
|
|
||||||
- name: create a forwarding rule
|
- name: create a forwarding rule
|
||||||
gcp_compute_forwarding_rule:
|
gcp_compute_forwarding_rule:
|
||||||
name: "test_object"
|
name: test_object
|
||||||
region: us-west1
|
region: us-west1
|
||||||
target: "{{ targetpool }}"
|
target: "{{ targetpool }}"
|
||||||
ip_protocol: TCP
|
ip_protocol: TCP
|
||||||
port_range: 80-80
|
port_range: 80-80
|
||||||
ip_address: "{{ address.address }}"
|
ip_address: "{{ address.address }}"
|
||||||
project: "test_project"
|
project: test_project
|
||||||
auth_kind: "serviceaccount"
|
auth_kind: serviceaccount
|
||||||
service_account_file: "/tmp/auth.pem"
|
service_account_file: "/tmp/auth.pem"
|
||||||
state: present
|
state: present
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
creationTimestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional description of this resource. Provide this property when you create
|
- An optional description of this resource. Provide this property when you create
|
||||||
the resource.
|
the resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
id:
|
id:
|
||||||
description:
|
description:
|
||||||
- The unique identifier for the resource.
|
- The unique identifier for the resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: int
|
type: int
|
||||||
IPAddress:
|
ip_address:
|
||||||
description:
|
description:
|
||||||
- The IP address that this forwarding rule is serving on behalf of.
|
- The IP address that this forwarding rule is serving on behalf of.
|
||||||
- Addresses are restricted based on the forwarding rule's load balancing scheme
|
- Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL
|
||||||
(EXTERNAL or INTERNAL) and scope (global or regional).
|
or INTERNAL) and scope (global or regional).
|
||||||
- When the load balancing scheme is EXTERNAL, for global forwarding rules, the address
|
- When the load balancing scheme is EXTERNAL, for global forwarding rules, the address
|
||||||
must be a global IP, and for regional forwarding rules, the address must live
|
must be a global IP, and for regional forwarding rules, the address must live in
|
||||||
in the same region as the forwarding rule. If this field is empty, an ephemeral
|
the same region as the forwarding rule. If this field is empty, an ephemeral IPv4
|
||||||
IPv4 address from the same scope (global or regional) will be assigned. A regional
|
address from the same scope (global or regional) will be assigned. A regional forwarding
|
||||||
forwarding rule supports IPv4 only. A global forwarding rule supports either IPv4
|
rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6.
|
||||||
or IPv6.
|
- When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address
|
||||||
- When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address
|
belonging to the network/subnet configured for the forwarding rule. By default,
|
||||||
belonging to the network/subnet configured for the forwarding rule. By default,
|
if this field is empty, an ephemeral internal IP address will be automatically allocated
|
||||||
if this field is empty, an ephemeral internal IP address will be automatically
|
from the IP range of the subnet or network configured for this forwarding rule.
|
||||||
allocated from the IP range of the subnet or network configured for this forwarding
|
- 'An address can be specified either by a literal IP address or a URL reference to
|
||||||
rule.
|
an existing Address resource. The following examples are all valid: * 100.1.2.3
|
||||||
- 'An address can be specified either by a literal IP address or a URL reference
|
* U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
|
||||||
to an existing Address resource. The following examples are all valid: * 100.1.2.3
|
* projects/project/regions/region/addresses/address * regions/region/addresses/address
|
||||||
* U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
|
* global/addresses/address * address .'
|
||||||
* projects/project/regions/region/addresses/address * regions/region/addresses/address
|
returned: success
|
||||||
* global/addresses/address * address .'
|
type: str
|
||||||
returned: success
|
ip_protocol:
|
||||||
type: str
|
description:
|
||||||
IPProtocol:
|
- The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH,
|
||||||
description:
|
SCTP or ICMP.
|
||||||
- The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH,
|
- When the load balancing scheme is INTERNAL, only TCP and UDP are valid.
|
||||||
SCTP or ICMP.
|
returned: success
|
||||||
- When the load balancing scheme is INTERNAL, only TCP and UDP are valid.
|
type: str
|
||||||
returned: success
|
backend_service:
|
||||||
type: str
|
description:
|
||||||
backendService:
|
- A reference to a BackendService to receive the matched traffic.
|
||||||
description:
|
- This is used for internal load balancing.
|
||||||
- A reference to a BackendService to receive the matched traffic.
|
- "(not used for external load balancing) ."
|
||||||
- This is used for internal load balancing.
|
returned: success
|
||||||
- "(not used for external load balancing) ."
|
type: dict
|
||||||
returned: success
|
ip_version:
|
||||||
type: str
|
description:
|
||||||
ipVersion:
|
- The IP Version that will be used by this forwarding rule. Valid options are IPV4
|
||||||
description:
|
or IPV6. This can only be specified for a global forwarding rule.
|
||||||
- The IP Version that will be used by this forwarding rule. Valid options are IPV4
|
returned: success
|
||||||
or IPV6. This can only be specified for a global forwarding rule.
|
type: str
|
||||||
returned: success
|
load_balancing_scheme:
|
||||||
type: str
|
description:
|
||||||
loadBalancingScheme:
|
- 'This signifies what the ForwardingRule will be used for and can only take the following
|
||||||
description:
|
values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for
|
||||||
- 'This signifies what the ForwardingRule will be used for and can only take the
|
Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this
|
||||||
following values: INTERNAL, EXTERNAL The value of INTERNAL means that this will
|
will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy)
|
||||||
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
|
returned: success
|
||||||
TCP/UDP LB, SSL Proxy) .'
|
type: str
|
||||||
returned: success
|
name:
|
||||||
type: str
|
description:
|
||||||
name:
|
- Name of the resource; provided by the client when the resource is created. The name
|
||||||
description:
|
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||||
- Name of the resource; provided by the client when the resource is created. The
|
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||||
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
|
which means the first character must be a lowercase letter, and all following characters
|
||||||
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||||
which means the first character must be a lowercase letter, and all following
|
be a dash.
|
||||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
returned: success
|
||||||
which cannot be a dash.
|
type: str
|
||||||
returned: success
|
network:
|
||||||
type: str
|
description:
|
||||||
network:
|
- For internal load balancing, this field identifies the network that the load balanced
|
||||||
description:
|
IP should belong to for this Forwarding Rule. If this field is not specified, the
|
||||||
- For internal load balancing, this field identifies the network that the load balanced
|
default network will be used.
|
||||||
IP should belong to for this Forwarding Rule. If this field is not specified,
|
- This field is not used for external load balancing.
|
||||||
the default network will be used.
|
returned: success
|
||||||
- This field is not used for external load balancing.
|
type: dict
|
||||||
returned: success
|
port_range:
|
||||||
type: str
|
description:
|
||||||
portRange:
|
- This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
|
||||||
description:
|
TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
|
||||||
- This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
|
- Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to
|
||||||
TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
|
ports in the specified range will be forwarded to target.
|
||||||
- Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to
|
- Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port
|
||||||
ports in the specified range will be forwarded to target.
|
ranges.
|
||||||
- Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
|
- 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy:
|
||||||
port ranges.
|
80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465,
|
||||||
- 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy:
|
587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110,
|
||||||
80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443,
|
143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
|
||||||
465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, 143, 195, 443,
|
500, 4500 .'
|
||||||
465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500 .'
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
ports:
|
||||||
ports:
|
description:
|
||||||
description:
|
- This field is used along with the backend_service field for internal load balancing.
|
||||||
- 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
|
||||||
- When the load balancing scheme is INTERNAL, a single port or a comma separated
|
of ports can be configured. Only packets addressed to these ports will be forwarded
|
||||||
list of ports can be configured. Only packets addressed to these ports will be
|
to the backends configured with this forwarding rule.
|
||||||
forwarded to the backends configured with this forwarding rule.
|
- You may specify a maximum of up to 5 ports.
|
||||||
- You may specify a maximum of up to 5 ports.
|
returned: success
|
||||||
returned: success
|
type: list
|
||||||
type: list
|
subnetwork:
|
||||||
subnetwork:
|
description:
|
||||||
description:
|
- A reference to a subnetwork.
|
||||||
- A reference to a subnetwork.
|
- For internal load balancing, this field identifies the subnetwork that the load
|
||||||
- For internal load balancing, this field identifies the subnetwork that the load
|
balanced IP should belong to for this Forwarding Rule.
|
||||||
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 specified is in auto subnet mode, this field is optional. However,
|
if the network is in custom subnet mode, a subnetwork must be specified.
|
||||||
if the network is in custom subnet mode, a subnetwork must be specified.
|
- This field is not used for external load balancing.
|
||||||
- This field is not used for external load balancing.
|
returned: success
|
||||||
returned: success
|
type: dict
|
||||||
type: str
|
target:
|
||||||
target:
|
description:
|
||||||
description:
|
- A reference to a TargetPool resource to receive the matched traffic.
|
||||||
- A reference to a TargetPool resource to receive the matched traffic.
|
- For regional forwarding rules, this target must live in the same region as the forwarding
|
||||||
- For regional forwarding rules, this target must live in the same region as the
|
rule. For global forwarding rules, this target must be a global load balancing resource.
|
||||||
forwarding rule. For global forwarding rules, this target must be a global load
|
The forwarded traffic must be of a type appropriate to the target object.
|
||||||
balancing resource. The forwarded traffic must be of a type appropriate to the
|
- This field is not used for internal load balancing.
|
||||||
target object.
|
returned: success
|
||||||
- This field is not used for internal load balancing.
|
type: dict
|
||||||
returned: success
|
label_fingerprint:
|
||||||
type: str
|
description:
|
||||||
networkTier:
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
description:
|
updates.
|
||||||
- 'The networking tier used for configuring this address. This field can take the
|
returned: success
|
||||||
following values: PREMIUM or STANDARD. If this field is not specified, it is assumed
|
type: str
|
||||||
to be PREMIUM.'
|
region:
|
||||||
returned: success
|
description:
|
||||||
type: str
|
- A reference to the region where the regional forwarding rule resides.
|
||||||
region:
|
- This field is not applicable to global forwarding rules.
|
||||||
description:
|
returned: success
|
||||||
- A reference to the region where the regional forwarding rule resides.
|
type: str
|
||||||
- This field is not applicable to global forwarding rules.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -411,16 +426,18 @@ def main():
|
||||||
description=dict(type='str'),
|
description=dict(type='str'),
|
||||||
ip_address=dict(type='str'),
|
ip_address=dict(type='str'),
|
||||||
ip_protocol=dict(type='str', choices=['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP']),
|
ip_protocol=dict(type='str', choices=['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP']),
|
||||||
backend_service=dict(),
|
backend_service=dict(type='dict'),
|
||||||
ip_version=dict(type='str', choices=['IPV4', 'IPV6']),
|
ip_version=dict(type='str', choices=['IPV4', 'IPV6']),
|
||||||
load_balancing_scheme=dict(type='str', choices=['INTERNAL', 'EXTERNAL']),
|
load_balancing_scheme=dict(type='str', choices=['INTERNAL', 'EXTERNAL']),
|
||||||
name=dict(required=True, type='str'),
|
name=dict(required=True, type='str'),
|
||||||
network=dict(),
|
network=dict(type='dict'),
|
||||||
port_range=dict(type='str'),
|
port_range=dict(type='str'),
|
||||||
ports=dict(type='list', elements='str'),
|
ports=dict(type='list', elements='str'),
|
||||||
subnetwork=dict(),
|
subnetwork=dict(type='dict'),
|
||||||
target=dict(),
|
target=dict(type='dict'),
|
||||||
|
all_ports=dict(type='bool'),
|
||||||
network_tier=dict(type='str', choices=['PREMIUM', 'STANDARD']),
|
network_tier=dict(type='str', choices=['PREMIUM', 'STANDARD']),
|
||||||
|
service_label=dict(type='str'),
|
||||||
region=dict(required=True, type='str'),
|
region=dict(required=True, type='str'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -437,7 +454,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
fetch = update(module, self_link(module), kind)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -460,8 +477,41 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="ForwardingRule cannot be edited")
|
update_fields(module, resource_to_request(module),
|
||||||
|
response_to_hash(module, fetch))
|
||||||
|
return fetch_resource(module, self_link(module), kind)
|
||||||
|
|
||||||
|
|
||||||
|
def update_fields(module, request, response):
|
||||||
|
if response.get('target') != request.get('target'):
|
||||||
|
target_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
|
def target_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/regions/{region}/forwardingRules/{name}/setTarget"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def label_fingerprint_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/regions/{region}/forwardingRules/{name}/setLabels"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'labelFingerprint': response.get('labelFingerprint')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
@ -484,7 +534,9 @@ def resource_to_request(module):
|
||||||
u'ports': module.params.get('ports'),
|
u'ports': module.params.get('ports'),
|
||||||
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
|
u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
|
||||||
u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink'),
|
u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink'),
|
||||||
|
u'allPorts': module.params.get('all_ports'),
|
||||||
u'networkTier': module.params.get('network_tier'),
|
u'networkTier': module.params.get('network_tier'),
|
||||||
|
u'serviceLabel': module.params.get('service_label'),
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -564,7 +616,7 @@ def response_to_hash(module, response):
|
||||||
u'ports': response.get(u'ports'),
|
u'ports': response.get(u'ports'),
|
||||||
u'subnetwork': response.get(u'subnetwork'),
|
u'subnetwork': response.get(u'subnetwork'),
|
||||||
u'target': response.get(u'target'),
|
u'target': response.get(u'target'),
|
||||||
u'networkTier': module.params.get('network_tier'),
|
u'labelFingerprint': response.get(u'labelFingerprint')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,166 +54,162 @@ extends_documentation_fragment: gcp
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: a forwarding rule facts
|
- name: " a forwarding rule facts"
|
||||||
gcp_compute_forwarding_rule_facts:
|
gcp_compute_forwarding_rule_facts:
|
||||||
region: us-west1
|
region: us-west1
|
||||||
filters:
|
filters:
|
||||||
- name = test_object
|
- name = test_object
|
||||||
project: test_project
|
project: test_project
|
||||||
auth_kind: serviceaccount
|
auth_kind: serviceaccount
|
||||||
service_account_file: "/tmp/auth.pem"
|
service_account_file: "/tmp/auth.pem"
|
||||||
|
state: facts
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
items:
|
items:
|
||||||
description: List of items
|
description: List of items
|
||||||
returned: always
|
returned: always
|
||||||
type: complex
|
type: complex
|
||||||
contains:
|
contains:
|
||||||
creationTimestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional description of this resource. Provide this property when you create
|
- An optional description of this resource. Provide this property when you create
|
||||||
the resource.
|
the resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
id:
|
id:
|
||||||
description:
|
description:
|
||||||
- The unique identifier for the resource.
|
- The unique identifier for the resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: int
|
type: int
|
||||||
IPAddress:
|
ip_address:
|
||||||
description:
|
description:
|
||||||
- The IP address that this forwarding rule is serving on behalf of.
|
- The IP address that this forwarding rule is serving on behalf of.
|
||||||
- Addresses are restricted based on the forwarding rule's load balancing scheme
|
- Addresses are restricted based on the forwarding rule's load balancing scheme (EXTERNAL
|
||||||
(EXTERNAL or INTERNAL) and scope (global or regional).
|
or INTERNAL) and scope (global or regional).
|
||||||
- When the load balancing scheme is EXTERNAL, for global forwarding rules, the
|
- When the load balancing scheme is EXTERNAL, for global forwarding rules, the address
|
||||||
address must be a global IP, and for regional forwarding rules, the address
|
must be a global IP, and for regional forwarding rules, the address must live in
|
||||||
must live in the same region as the forwarding rule. If this field is empty,
|
the same region as the forwarding rule. If this field is empty, an ephemeral IPv4
|
||||||
an ephemeral IPv4 address from the same scope (global or regional) will be
|
address from the same scope (global or regional) will be assigned. A regional forwarding
|
||||||
assigned. A regional forwarding rule supports IPv4 only. A global forwarding
|
rule supports IPv4 only. A global forwarding rule supports either IPv4 or IPv6.
|
||||||
rule supports either IPv4 or IPv6.
|
- When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address
|
||||||
- When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP
|
belonging to the network/subnet configured for the forwarding rule. By default,
|
||||||
address belonging to the network/subnet configured for the forwarding rule.
|
if this field is empty, an ephemeral internal IP address will be automatically allocated
|
||||||
By default, if this field is empty, an ephemeral internal IP address will
|
from the IP range of the subnet or network configured for this forwarding rule.
|
||||||
be automatically allocated from the IP range of the subnet or network configured
|
- 'An address can be specified either by a literal IP address or a URL reference to
|
||||||
for this forwarding rule.
|
an existing Address resource. The following examples are all valid: * 100.1.2.3
|
||||||
- 'An address can be specified either by a literal IP address or a URL reference
|
* U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
|
||||||
to an existing Address resource. The following examples are all valid: * 100.1.2.3
|
* projects/project/regions/region/addresses/address * regions/region/addresses/address
|
||||||
* U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
|
* global/addresses/address * address .'
|
||||||
* projects/project/regions/region/addresses/address * regions/region/addresses/address
|
returned: success
|
||||||
* global/addresses/address * address .'
|
type: str
|
||||||
returned: success
|
ip_protocol:
|
||||||
type: str
|
description:
|
||||||
IPProtocol:
|
- The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH,
|
||||||
description:
|
SCTP or ICMP.
|
||||||
- The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP,
|
- When the load balancing scheme is INTERNAL, only TCP and UDP are valid.
|
||||||
AH, SCTP or ICMP.
|
returned: success
|
||||||
- When the load balancing scheme is INTERNAL, only TCP and UDP are valid.
|
type: str
|
||||||
returned: success
|
backend_service:
|
||||||
type: str
|
description:
|
||||||
backendService:
|
- A reference to a BackendService to receive the matched traffic.
|
||||||
description:
|
- This is used for internal load balancing.
|
||||||
- A reference to a BackendService to receive the matched traffic.
|
- "(not used for external load balancing) ."
|
||||||
- This is used for internal load balancing.
|
returned: success
|
||||||
- "(not used for external load balancing) ."
|
type: dict
|
||||||
returned: success
|
ip_version:
|
||||||
type: str
|
description:
|
||||||
ipVersion:
|
- The IP Version that will be used by this forwarding rule. Valid options are IPV4
|
||||||
description:
|
or IPV6. This can only be specified for a global forwarding rule.
|
||||||
- The IP Version that will be used by this forwarding rule. Valid options are
|
returned: success
|
||||||
IPV4 or IPV6. This can only be specified for a global forwarding rule.
|
type: str
|
||||||
returned: success
|
load_balancing_scheme:
|
||||||
type: str
|
description:
|
||||||
loadBalancingScheme:
|
- 'This signifies what the ForwardingRule will be used for and can only take the following
|
||||||
description:
|
values: INTERNAL, EXTERNAL The value of INTERNAL means that this will be used for
|
||||||
- 'This signifies what the ForwardingRule will be used for and can only take
|
Internal Network Load Balancing (TCP, UDP). The value of EXTERNAL means that this
|
||||||
the following values: INTERNAL, EXTERNAL The value of INTERNAL means that
|
will be used for External Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy)
|
||||||
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)
|
returned: success
|
||||||
LB, External TCP/UDP LB, SSL Proxy) .'
|
type: str
|
||||||
returned: success
|
name:
|
||||||
type: str
|
description:
|
||||||
name:
|
- Name of the resource; provided by the client when the resource is created. The name
|
||||||
description:
|
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||||
- Name of the resource; provided by the client when the resource is created.
|
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||||
The name must be 1-63 characters long, and comply with RFC1035. Specifically,
|
which means the first character must be a lowercase letter, and all following characters
|
||||||
the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||||
which means the first character must be a lowercase letter, and all following
|
be a dash.
|
||||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
returned: success
|
||||||
which cannot be a dash.
|
type: str
|
||||||
returned: success
|
network:
|
||||||
type: str
|
description:
|
||||||
network:
|
- For internal load balancing, this field identifies the network that the load balanced
|
||||||
description:
|
IP should belong to for this Forwarding Rule. If this field is not specified, the
|
||||||
- For internal load balancing, this field identifies the network that the load
|
default network will be used.
|
||||||
balanced IP should belong to for this Forwarding Rule. If this field is not
|
- This field is not used for external load balancing.
|
||||||
specified, the default network will be used.
|
returned: success
|
||||||
- This field is not used for external load balancing.
|
type: dict
|
||||||
returned: success
|
port_range:
|
||||||
type: str
|
description:
|
||||||
portRange:
|
- This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
|
||||||
description:
|
TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
|
||||||
- This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
|
- Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to
|
||||||
TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
|
ports in the specified range will be forwarded to target.
|
||||||
- Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed
|
- Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint port
|
||||||
to ports in the specified range will be forwarded to target.
|
ranges.
|
||||||
- Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
|
- 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy:
|
||||||
port ranges.
|
80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443, 465,
|
||||||
- 'Some types of forwarding target have constraints on the acceptable ports:
|
587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110,
|
||||||
* TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25,
|
143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
|
||||||
43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy:
|
500, 4500 .'
|
||||||
25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
|
returned: success
|
||||||
500, 4500 .'
|
type: str
|
||||||
returned: success
|
ports:
|
||||||
type: str
|
description:
|
||||||
ports:
|
- This field is used along with the backend_service field for internal load balancing.
|
||||||
description:
|
- When the load balancing scheme is INTERNAL, a single port or a comma separated list
|
||||||
- This field is used along with the backend_service field for internal load
|
of ports can be configured. Only packets addressed to these ports will be forwarded
|
||||||
balancing.
|
to the backends configured with this forwarding rule.
|
||||||
- When the load balancing scheme is INTERNAL, a single port or a comma separated
|
- You may specify a maximum of up to 5 ports.
|
||||||
list of ports can be configured. Only packets addressed to these ports will
|
returned: success
|
||||||
be forwarded to the backends configured with this forwarding rule.
|
type: list
|
||||||
- You may specify a maximum of up to 5 ports.
|
subnetwork:
|
||||||
returned: success
|
description:
|
||||||
type: list
|
- A reference to a subnetwork.
|
||||||
subnetwork:
|
- For internal load balancing, this field identifies the subnetwork that the load
|
||||||
description:
|
balanced IP should belong to for this Forwarding Rule.
|
||||||
- A reference to a subnetwork.
|
- If the network specified is in auto subnet mode, this field is optional. However,
|
||||||
- For internal load balancing, this field identifies the subnetwork that the
|
if the network is in custom subnet mode, a subnetwork must be specified.
|
||||||
load balanced IP should belong to for this Forwarding Rule.
|
- This field is not used for external load balancing.
|
||||||
- If the network specified is in auto subnet mode, this field is optional. However,
|
returned: success
|
||||||
if the network is in custom subnet mode, a subnetwork must be specified.
|
type: dict
|
||||||
- This field is not used for external load balancing.
|
target:
|
||||||
returned: success
|
description:
|
||||||
type: str
|
- A reference to a TargetPool resource to receive the matched traffic.
|
||||||
target:
|
- For regional forwarding rules, this target must live in the same region as the forwarding
|
||||||
description:
|
rule. For global forwarding rules, this target must be a global load balancing resource.
|
||||||
- A reference to a TargetPool resource to receive the matched traffic.
|
The forwarded traffic must be of a type appropriate to the target object.
|
||||||
- For regional forwarding rules, this target must live in the same region as
|
- This field is not used for internal load balancing.
|
||||||
the forwarding rule. For global forwarding rules, this target must be a global
|
returned: success
|
||||||
load balancing resource. The forwarded traffic must be of a type appropriate
|
type: dict
|
||||||
to the target object.
|
label_fingerprint:
|
||||||
- This field is not used for internal load balancing.
|
description:
|
||||||
returned: success
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
type: str
|
updates.
|
||||||
networkTier:
|
returned: success
|
||||||
description:
|
type: str
|
||||||
- 'The networking tier used for configuring this address. This field can take
|
region:
|
||||||
the following values: PREMIUM or STANDARD. If this field is not specified,
|
description:
|
||||||
it is assumed to be PREMIUM.'
|
- A reference to the region where the regional forwarding rule resides.
|
||||||
returned: success
|
- This field is not applicable to global forwarding rules.
|
||||||
type: str
|
returned: success
|
||||||
region:
|
type: str
|
||||||
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
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -238,7 +234,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {'items': items}
|
return_value = {'resources': items}
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -102,54 +102,54 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
address:
|
address:
|
||||||
description:
|
description:
|
||||||
- The static external IP address represented by this resource.
|
- The static external IP address represented by this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
creationTimestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional description of this resource.
|
- An optional description of this resource.
|
||||||
returned: success
|
- Provide this property when you create the resource.
|
||||||
type: str
|
returned: success
|
||||||
id:
|
type: str
|
||||||
description:
|
id:
|
||||||
- The unique identifier for the resource. This identifier is defined by the server.
|
description:
|
||||||
returned: success
|
- The unique identifier for the resource. This identifier is defined by the server.
|
||||||
type: int
|
returned: success
|
||||||
name:
|
type: int
|
||||||
description:
|
name:
|
||||||
- Name of the resource. Provided by the client when the resource is created. The
|
description:
|
||||||
name must be 1-63 characters long, and comply with RFC1035. Specifically, the
|
- Name of the resource. Provided by the client when the resource is created. The name
|
||||||
name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||||
which means the first character must be a lowercase letter, and all following
|
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
which means the first character must be a lowercase letter, and all following characters
|
||||||
which cannot be a dash.
|
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||||
returned: success
|
be a dash.
|
||||||
type: str
|
returned: success
|
||||||
ipVersion:
|
type: str
|
||||||
description:
|
label_fingerprint:
|
||||||
- The IP Version that will be used by this address. Valid options are `IPV4` or
|
description:
|
||||||
`IPV6`. The default value is `IPV4`.
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
returned: success
|
updates.
|
||||||
type: str
|
returned: success
|
||||||
region:
|
type: str
|
||||||
description:
|
ip_version:
|
||||||
- A reference to the region where the regional address resides.
|
description:
|
||||||
returned: success
|
- The IP Version that will be used by this address. Valid options are IPV4 or IPV6.
|
||||||
type: str
|
The default value is IPV4.
|
||||||
addressType:
|
returned: success
|
||||||
description:
|
type: str
|
||||||
- The type of the address to reserve, default is EXTERNAL.
|
region:
|
||||||
- "* EXTERNAL indicates public/external single IP address."
|
description:
|
||||||
- "* INTERNAL indicates internal IP ranges belonging to some network."
|
- A reference to the region where the regional address resides.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -192,8 +192,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -216,8 +215,27 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="GlobalAddress cannot be edited")
|
update_fields(module, resource_to_request(module),
|
||||||
|
response_to_hash(module, fetch))
|
||||||
|
return fetch_resource(module, self_link(module), kind)
|
||||||
|
|
||||||
|
|
||||||
|
def update_fields(module, request, response):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def label_fingerprint_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/addresses/{name}/setLabels"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'labelFingerprint': response.get('labelFingerprint')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
@ -303,6 +321,7 @@ def response_to_hash(module, response):
|
||||||
u'description': response.get(u'description'),
|
u'description': response.get(u'description'),
|
||||||
u'id': response.get(u'id'),
|
u'id': response.get(u'id'),
|
||||||
u'name': response.get(u'name'),
|
u'name': response.get(u'name'),
|
||||||
|
u'labelFingerprint': response.get(u'labelFingerprint'),
|
||||||
u'ipVersion': response.get(u'ipVersion'),
|
u'ipVersion': response.get(u'ipVersion'),
|
||||||
u'region': response.get(u'region'),
|
u'region': response.get(u'region'),
|
||||||
u'addressType': response.get(u'addressType'),
|
u'addressType': response.get(u'addressType'),
|
||||||
|
|
|
@ -49,71 +49,70 @@ extends_documentation_fragment: gcp
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: a global address facts
|
- name: " a global address facts"
|
||||||
gcp_compute_global_address_facts:
|
gcp_compute_global_address_facts:
|
||||||
filters:
|
filters:
|
||||||
- name = test_object
|
- name = test_object
|
||||||
project: test_project
|
project: test_project
|
||||||
auth_kind: serviceaccount
|
auth_kind: serviceaccount
|
||||||
service_account_file: "/tmp/auth.pem"
|
service_account_file: "/tmp/auth.pem"
|
||||||
|
state: facts
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
items:
|
items:
|
||||||
description: List of items
|
description: List of items
|
||||||
returned: always
|
returned: always
|
||||||
type: complex
|
type: complex
|
||||||
contains:
|
contains:
|
||||||
address:
|
address:
|
||||||
description:
|
description:
|
||||||
- The static external IP address represented by this resource.
|
- The static external IP address represented by this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
creationTimestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional description of this resource.
|
- An optional description of this resource.
|
||||||
- Provide this property when you create the resource.
|
- Provide this property when you create the resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
id:
|
id:
|
||||||
description:
|
description:
|
||||||
- The unique identifier for the resource. This identifier is defined by the
|
- The unique identifier for the resource. This identifier is defined by the server.
|
||||||
server.
|
returned: success
|
||||||
returned: success
|
type: int
|
||||||
type: int
|
name:
|
||||||
name:
|
description:
|
||||||
description:
|
- Name of the resource. Provided by the client when the resource is created. The name
|
||||||
- Name of the resource. Provided by the client when the resource is created.
|
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
||||||
The name must be 1-63 characters long, and comply with RFC1035. Specifically,
|
be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
||||||
the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
|
which means the first character must be a lowercase letter, and all following characters
|
||||||
which means the first character must be a lowercase letter, and all following
|
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
||||||
characters must be a dash, lowercase letter, or digit, except the last character,
|
be a dash.
|
||||||
which cannot be a dash.
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
label_fingerprint:
|
||||||
ipVersion:
|
description:
|
||||||
description:
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
- The IP Version that will be used by this address. Valid options are IPV4 or
|
updates.
|
||||||
IPV6. The default value is IPV4.
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
ip_version:
|
||||||
region:
|
description:
|
||||||
description:
|
- The IP Version that will be used by this address. Valid options are IPV4 or IPV6.
|
||||||
- A reference to the region where the regional address resides.
|
The default value is IPV4.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
addressType:
|
region:
|
||||||
description:
|
description:
|
||||||
- The type of the address to reserve, default is EXTERNAL.
|
- A reference to the region where the regional address resides.
|
||||||
- "* EXTERNAL indicates public/external single IP address."
|
returned: success
|
||||||
- "* INTERNAL indicates internal IP ranges belonging to some network."
|
type: str
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -138,7 +137,7 @@ def main():
|
||||||
items = items.get('items')
|
items = items.get('items')
|
||||||
else:
|
else:
|
||||||
items = []
|
items = []
|
||||||
return_value = {'items': items}
|
return_value = {'resources': items}
|
||||||
module.exit_json(**return_value)
|
module.exit_json(**return_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -298,8 +298,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind, fetch)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -322,8 +321,43 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="Subnetwork cannot be edited")
|
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('ipCidrRange') != request.get('ipCidrRange'):
|
||||||
|
ip_cidr_range_update(module, request, response)
|
||||||
|
if response.get('privateIpGoogleAccess') != request.get('privateIpGoogleAccess'):
|
||||||
|
private_ip_google_access_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
|
def ip_cidr_range_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/regions/{region}/subnetworks/{name}/expandIpCidrRange"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'ipCidrRange': module.params.get('ip_cidr_range')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def private_ip_google_access_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/regions/{region}/subnetworks/{name}/setPrivateIpGoogleAccess"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'privateIpGoogleAccess': module.params.get('private_ip_google_access')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
|
|
@ -204,8 +204,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind, fetch)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -228,8 +227,28 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="TargetHttpProxy cannot be edited")
|
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('urlMap') != request.get('urlMap'):
|
||||||
|
url_map_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
|
def url_map_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/targetHttpProxies/{name}/setUrlMap"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
|
|
@ -295,8 +295,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind, fetch)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -319,8 +318,58 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="TargetHttpsProxy cannot be edited")
|
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('quicOverride') != request.get('quicOverride'):
|
||||||
|
quic_override_update(module, request, response)
|
||||||
|
if response.get('sslCertificates') != request.get('sslCertificates'):
|
||||||
|
ssl_certificates_update(module, request, response)
|
||||||
|
if response.get('urlMap') != request.get('urlMap'):
|
||||||
|
url_map_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
|
def quic_override_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetHttpsProxies/{name}/setQuicOverride"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'quicOverride': module.params.get('quic_override')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def ssl_certificates_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/targetHttpsProxies/{name}/setSslCertificates"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def url_map_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/targetHttpsProxies/{name}/setUrlMap"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
|
|
@ -281,8 +281,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind, fetch)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -305,8 +304,58 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="TargetSslProxy cannot be edited")
|
update_fields(module, resource_to_request(module),
|
||||||
|
response_to_hash(module, fetch))
|
||||||
|
return fetch_resource(module, self_link(module), kind)
|
||||||
|
|
||||||
|
|
||||||
|
def update_fields(module, request, response):
|
||||||
|
if response.get('proxyHeader') != request.get('proxyHeader'):
|
||||||
|
proxy_header_update(module, request, response)
|
||||||
|
if response.get('service') != request.get('service'):
|
||||||
|
service_update(module, request, response)
|
||||||
|
if response.get('sslCertificates') != request.get('sslCertificates'):
|
||||||
|
ssl_certificates_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
|
def proxy_header_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetSslProxies/{name}/setProxyHeader"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'proxyHeader': module.params.get('proxy_header')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def service_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetSslProxies/{name}/setBackendService"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def ssl_certificates_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetSslProxies/{name}/setSslCertificates"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
|
|
@ -214,7 +214,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
fetch = update(module, self_link(module), kind)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -237,8 +237,43 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="TargetTcpProxy cannot be edited")
|
update_fields(module, resource_to_request(module),
|
||||||
|
response_to_hash(module, fetch))
|
||||||
|
return fetch_resource(module, self_link(module), kind)
|
||||||
|
|
||||||
|
|
||||||
|
def update_fields(module, request, response):
|
||||||
|
if response.get('proxyHeader') != request.get('proxyHeader'):
|
||||||
|
proxy_header_update(module, request, response)
|
||||||
|
if response.get('service') != request.get('service'):
|
||||||
|
service_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
|
def proxy_header_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetTcpProxies/{name}/setProxyHeader"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'proxyHeader': module.params.get('proxy_header')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def service_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetTcpProxies/{name}/setBackendService"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
|
|
@ -171,78 +171,89 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
creationTimestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Name of the resource. The name must be 1-63 characters long, and comply with RFC1035.
|
- Name of the resource. The name must be 1-63 characters long, and comply with RFC1035.
|
||||||
Specifically, the name must be 1-63 characters long and match the regular expression
|
Specifically, the name must be 1-63 characters long and match the regular expression
|
||||||
`[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
|
`[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
|
||||||
letter, and all following characters must be a dash, lowercase letter, or digit,
|
letter, and all following characters must be a dash, lowercase letter, or digit,
|
||||||
except the last character, which cannot be a dash.
|
except the last character, which cannot be a dash.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional description of this resource.
|
- An optional description of this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
targetVpnGateway:
|
target_vpn_gateway:
|
||||||
description:
|
description:
|
||||||
- URL of the Target VPN gateway with which this VPN tunnel is associated.
|
- URL of the Target VPN gateway with which this VPN tunnel is associated.
|
||||||
returned: success
|
returned: success
|
||||||
type: dict
|
type: dict
|
||||||
router:
|
router:
|
||||||
description:
|
description:
|
||||||
- URL of router resource to be used for dynamic routing.
|
- URL of router resource to be used for dynamic routing.
|
||||||
returned: success
|
returned: success
|
||||||
type: dict
|
type: str
|
||||||
peerIp:
|
peer_ip:
|
||||||
description:
|
description:
|
||||||
- IP address of the peer VPN gateway. Only IPv4 is supported.
|
- IP address of the peer VPN gateway. Only IPv4 is supported.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sharedSecret:
|
shared_secret:
|
||||||
description:
|
description:
|
||||||
- Shared secret used to set the secure session between the Cloud VPN gateway and
|
- Shared secret used to set the secure session between the Cloud VPN gateway and the
|
||||||
the peer VPN gateway.
|
peer VPN gateway.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sharedSecretHash:
|
shared_secret_hash:
|
||||||
description:
|
description:
|
||||||
- Hash of the shared secret.
|
- Hash of the shared secret.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
ikeVersion:
|
ike_version:
|
||||||
description:
|
description:
|
||||||
- IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway.
|
- IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway.
|
||||||
- Acceptable IKE versions are 1 or 2. Default version is 2.
|
- Acceptable IKE versions are 1 or 2. Default version is 2.
|
||||||
returned: success
|
returned: success
|
||||||
type: int
|
type: int
|
||||||
localTrafficSelector:
|
local_traffic_selector:
|
||||||
description:
|
description:
|
||||||
- Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway.
|
- Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway.
|
||||||
The value should be a CIDR formatted string, for example `192.168.0.0/16`. The
|
The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges
|
||||||
ranges should be disjoint.
|
should be disjoint.
|
||||||
- Only IPv4 is supported.
|
- Only IPv4 is supported.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
remoteTrafficSelector:
|
remote_traffic_selector:
|
||||||
description:
|
description:
|
||||||
- Remote traffic selector to use when establishing the VPN tunnel with peer VPN
|
- Remote traffic selector to use when establishing the VPN tunnel with peer VPN gateway.
|
||||||
gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
|
The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges
|
||||||
The ranges should be disjoint.
|
should be disjoint.
|
||||||
- Only IPv4 is supported.
|
- Only IPv4 is supported.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
region:
|
labels:
|
||||||
description:
|
description:
|
||||||
- The region where the tunnel is located.
|
- Labels to apply to this VpnTunnel.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: dict
|
||||||
|
label_fingerprint:
|
||||||
|
description:
|
||||||
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
|
updates.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
|
region:
|
||||||
|
description:
|
||||||
|
- The region where the tunnel is located.
|
||||||
|
returned: success
|
||||||
|
type: str
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -289,8 +300,7 @@ def main():
|
||||||
if fetch:
|
if fetch:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
if is_different(module, fetch):
|
if is_different(module, fetch):
|
||||||
update(module, self_link(module), kind)
|
fetch = update(module, self_link(module), kind, fetch)
|
||||||
fetch = fetch_resource(module, self_link(module), kind)
|
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
delete(module, self_link(module), kind)
|
delete(module, self_link(module), kind)
|
||||||
|
@ -299,6 +309,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
fetch = create(module, collection(module), kind)
|
fetch = create(module, collection(module), kind)
|
||||||
|
labels_update(module, module.params, fetch)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
fetch = {}
|
fetch = {}
|
||||||
|
@ -313,8 +324,29 @@ def create(module, link, kind):
|
||||||
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
||||||
|
|
||||||
|
|
||||||
def update(module, link, kind):
|
def update(module, link, kind, fetch):
|
||||||
module.fail_json(msg="VpnTunnel cannot be edited")
|
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('labels') != request.get('labels'):
|
||||||
|
labels_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
|
def labels_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/regions/{region}/vpnTunnels/{name}/setLabels"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'labels': module.params.get('labels'),
|
||||||
|
u'labelFingerprint': response.get('labelFingerprint')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
|
@ -410,6 +442,8 @@ def response_to_hash(module, response):
|
||||||
u'ikeVersion': response.get(u'ikeVersion'),
|
u'ikeVersion': response.get(u'ikeVersion'),
|
||||||
u'localTrafficSelector': response.get(u'localTrafficSelector'),
|
u'localTrafficSelector': response.get(u'localTrafficSelector'),
|
||||||
u'remoteTrafficSelector': response.get(u'remoteTrafficSelector'),
|
u'remoteTrafficSelector': response.get(u'remoteTrafficSelector'),
|
||||||
|
u'labels': response.get(u'labels'),
|
||||||
|
u'labelFingerprint': response.get(u'labelFingerprint')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,106 +53,106 @@ extends_documentation_fragment: gcp
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: a vpn tunnel facts
|
- name: " a vpn tunnel facts"
|
||||||
gcp_compute_vpn_tunnel_facts:
|
gcp_compute_vpn_tunnel_facts:
|
||||||
region: us-west1
|
region: us-west1
|
||||||
filters:
|
filters:
|
||||||
- name = test_object
|
- name = test_object
|
||||||
project: test_project
|
project: test_project
|
||||||
auth_kind: serviceaccount
|
auth_kind: serviceaccount
|
||||||
service_account_file: "/tmp/auth.pem"
|
service_account_file: "/tmp/auth.pem"
|
||||||
|
state: facts
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
items:
|
items:
|
||||||
description: List of items
|
description: List of items
|
||||||
returned: always
|
returned: always
|
||||||
type: complex
|
type: complex
|
||||||
contains:
|
contains:
|
||||||
creationTimestamp:
|
creation_timestamp:
|
||||||
description:
|
description:
|
||||||
- Creation timestamp in RFC3339 text format.
|
- Creation timestamp in RFC3339 text format.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- Name of the resource. The name must be 1-63 characters long, and comply with
|
- Name of the resource. The name must be 1-63 characters long, and comply with RFC1035.
|
||||||
RFC1035. Specifically, the name must be 1-63 characters long and match the
|
Specifically, the name must be 1-63 characters long and match the regular expression
|
||||||
regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character
|
`[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
|
||||||
must be a lowercase letter, and all following characters must be a dash, lowercase
|
letter, and all following characters must be a dash, lowercase letter, or digit,
|
||||||
letter, or digit, except the last character, which cannot be a dash.
|
except the last character, which cannot be a dash.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
||||||
- An optional description of this resource.
|
- An optional description of this resource.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
targetVpnGateway:
|
target_vpn_gateway:
|
||||||
description:
|
description:
|
||||||
- URL of the Target VPN gateway with which this VPN tunnel is associated.
|
- URL of the Target VPN gateway with which this VPN tunnel is associated.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: dict
|
||||||
router:
|
router:
|
||||||
description:
|
description:
|
||||||
- URL of router resource to be used for dynamic routing.
|
- URL of router resource to be used for dynamic routing.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
peerIp:
|
peer_ip:
|
||||||
description:
|
description:
|
||||||
- IP address of the peer VPN gateway. Only IPv4 is supported.
|
- IP address of the peer VPN gateway. Only IPv4 is supported.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sharedSecret:
|
shared_secret:
|
||||||
description:
|
description:
|
||||||
- Shared secret used to set the secure session between the Cloud VPN gateway
|
- Shared secret used to set the secure session between the Cloud VPN gateway and the
|
||||||
and the peer VPN gateway.
|
peer VPN gateway.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
sharedSecretHash:
|
shared_secret_hash:
|
||||||
description:
|
description:
|
||||||
- Hash of the shared secret.
|
- Hash of the shared secret.
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
ikeVersion:
|
ike_version:
|
||||||
description:
|
description:
|
||||||
- IKE protocol version to use when establishing the VPN tunnel with peer VPN
|
- IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway.
|
||||||
gateway.
|
- Acceptable IKE versions are 1 or 2. Default version is 2.
|
||||||
- Acceptable IKE versions are 1 or 2. Default version is 2.
|
returned: success
|
||||||
returned: success
|
type: int
|
||||||
type: int
|
local_traffic_selector:
|
||||||
localTrafficSelector:
|
description:
|
||||||
description:
|
- Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway.
|
||||||
- Local traffic selector to use when establishing the VPN tunnel with peer VPN
|
The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges
|
||||||
gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
|
should be disjoint.
|
||||||
The ranges should be disjoint.
|
- Only IPv4 is supported.
|
||||||
- Only IPv4 is supported.
|
returned: success
|
||||||
returned: success
|
type: list
|
||||||
type: list
|
remote_traffic_selector:
|
||||||
remoteTrafficSelector:
|
description:
|
||||||
description:
|
- Remote traffic selector to use when establishing the VPN tunnel with peer VPN gateway.
|
||||||
- Remote traffic selector to use when establishing the VPN tunnel with peer
|
The value should be a CIDR formatted string, for example `192.168.0.0/16`. The ranges
|
||||||
VPN gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
|
should be disjoint.
|
||||||
The ranges should be disjoint.
|
- Only IPv4 is supported.
|
||||||
- Only IPv4 is supported.
|
returned: success
|
||||||
returned: success
|
type: list
|
||||||
type: list
|
labels:
|
||||||
labels:
|
description:
|
||||||
description:
|
- Labels to apply to this VpnTunnel.
|
||||||
- Labels to apply to this VpnTunnel.
|
returned: success
|
||||||
returned: success
|
type: dict
|
||||||
type: dict
|
label_fingerprint:
|
||||||
labelFingerprint:
|
description:
|
||||||
description:
|
- The fingerprint used for optimistic locking of this resource. Used internally during
|
||||||
- The fingerprint used for optimistic locking of this resource. Used internally
|
updates.
|
||||||
during updates.
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
region:
|
||||||
region:
|
description:
|
||||||
description:
|
- The region where the tunnel is located.
|
||||||
- The region where the tunnel is located.
|
returned: success
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Add table
Reference in a new issue