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