mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-26 14:41:29 -07:00
parent
5c97cc1da0
commit
d64785e811
80 changed files with 14198 additions and 13862 deletions
|
@ -32,109 +32,111 @@ DOCUMENTATION = '''
|
|||
---
|
||||
module: gcp_compute_subnetwork
|
||||
description:
|
||||
- A VPC network is a virtual version of the traditional physical networks that exist
|
||||
within and between physical data centers. A VPC network provides connectivity for
|
||||
your Compute Engine virtual machine (VM) instances, Container Engine containers,
|
||||
App Engine Flex services, and other network-related resources.
|
||||
- Each GCP project contains one or more VPC networks. Each VPC network is a global
|
||||
entity spanning all GCP regions. This global VPC network allows VM instances and
|
||||
other resources to communicate with each other via internal, private IP addresses.
|
||||
- Each VPC network is subdivided into subnets, and each subnet is contained within
|
||||
a single region. You can have more than one subnet in a region for a given VPC network.
|
||||
Each subnet has a contiguous private RFC1918 IP space. You create instances, containers,
|
||||
and the like in these subnets.
|
||||
- When you create an instance, you must create it in a subnet, and the instance draws
|
||||
its internal IP address from that subnet.
|
||||
- Virtual machine (VM) instances in a VPC network can communicate with instances in
|
||||
all other subnets of the same VPC network, regardless of region, using their RFC1918
|
||||
private IP addresses. You can isolate portions of the network, even entire subnets,
|
||||
using firewall rules.
|
||||
- A VPC network is a virtual version of the traditional physical networks that exist
|
||||
within and between physical data centers. A VPC network provides connectivity for
|
||||
your Compute Engine virtual machine (VM) instances, Container Engine containers,
|
||||
App Engine Flex services, and other network-related resources.
|
||||
- Each GCP project contains one or more VPC networks. Each VPC network is a global
|
||||
entity spanning all GCP regions. This global VPC network allows VM instances and
|
||||
other resources to communicate with each other via internal, private IP addresses.
|
||||
- Each VPC network is subdivided into subnets, and each subnet is contained within
|
||||
a single region. You can have more than one subnet in a region for a given VPC network.
|
||||
Each subnet has a contiguous private RFC1918 IP space. You create instances, containers,
|
||||
and the like in these subnets.
|
||||
- When you create an instance, you must create it in a subnet, and the instance draws
|
||||
its internal IP address from that subnet.
|
||||
- Virtual machine (VM) instances in a VPC network can communicate with instances in
|
||||
all other subnets of the same VPC network, regardless of region, using their RFC1918
|
||||
private IP addresses. You can isolate portions of the network, even entire subnets,
|
||||
using firewall rules.
|
||||
short_description: Creates a GCP Subnetwork
|
||||
version_added: 2.6
|
||||
author: Google Inc. (@googlecloudplatform)
|
||||
requirements:
|
||||
- python >= 2.6
|
||||
- requests >= 2.18.4
|
||||
- google-auth >= 1.3.0
|
||||
- python >= 2.6
|
||||
- requests >= 2.18.4
|
||||
- google-auth >= 1.3.0
|
||||
options:
|
||||
state:
|
||||
description:
|
||||
- Whether the given object should exist in GCP
|
||||
choices: ['present', 'absent']
|
||||
default: 'present'
|
||||
state:
|
||||
description:
|
||||
- Whether the given object should exist in GCP
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
default: present
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource. This field can be set only at resource creation time.
|
||||
required: false
|
||||
ip_cidr_range:
|
||||
description:
|
||||
- The range of internal addresses that are owned by this subnetwork.
|
||||
- Provide this property when you create the subnetwork. For example, 10.0.0.0/8
|
||||
or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network.
|
||||
Only IPv4 is supported.
|
||||
required: true
|
||||
name:
|
||||
description:
|
||||
- The name of the resource, provided by the client when initially creating 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 `[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.
|
||||
required: true
|
||||
network:
|
||||
description:
|
||||
- The network this subnet belongs to.
|
||||
- Only networks that are in the distributed mode can have subnetworks.
|
||||
- 'This field represents a link to a Network resource in GCP. It can be specified
|
||||
in two ways. You can add `register: name-of-resource` to a gcp_compute_network
|
||||
task and then set this network field to "{{ name-of-resource }}" Alternatively,
|
||||
you can set this network to a dictionary with the selfLink key where the value
|
||||
is the selfLink of your Network'
|
||||
required: true
|
||||
enable_flow_logs:
|
||||
description:
|
||||
- Whether to enable flow logging for this subnetwork.
|
||||
required: false
|
||||
type: bool
|
||||
version_added: 2.8
|
||||
secondary_ip_ranges:
|
||||
description:
|
||||
- An array of configurations for secondary IP ranges for VM instances contained
|
||||
in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange
|
||||
of the subnetwork. The alias IPs may belong to either primary or secondary ranges.
|
||||
required: false
|
||||
version_added: 2.8
|
||||
suboptions:
|
||||
range_name:
|
||||
description:
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource. This field can be set only at resource creation time.
|
||||
required: false
|
||||
ip_cidr_range:
|
||||
description:
|
||||
- The range of internal addresses that are owned by this subnetwork.
|
||||
- Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or
|
||||
192.168.0.0/16. Ranges must be unique and non-overlapping within a network. Only
|
||||
IPv4 is supported.
|
||||
- The name associated with this subnetwork secondary range, used when adding
|
||||
an alias IP range to a VM instance. The name must be 1-63 characters long,
|
||||
and comply with RFC1035. The name must be unique within the subnetwork.
|
||||
required: true
|
||||
name:
|
||||
ip_cidr_range:
|
||||
description:
|
||||
- The name of the resource, provided by the client when initially creating 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 `[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.
|
||||
required: true
|
||||
network:
|
||||
description:
|
||||
- The network this subnet belongs to.
|
||||
- Only networks that are in the distributed mode can have subnetworks.
|
||||
- 'This field represents a link to a Network resource in GCP. It can be specified
|
||||
in two ways. You can add `register: name-of-resource` to a gcp_compute_network task
|
||||
and then set this network field to "{{ name-of-resource }}" Alternatively, you can
|
||||
set this network to a dictionary with the selfLink key where the value is the selfLink
|
||||
of your Network.'
|
||||
required: true
|
||||
enable_flow_logs:
|
||||
description:
|
||||
- Whether to enable flow logging for this subnetwork.
|
||||
required: false
|
||||
type: bool
|
||||
version_added: 2.8
|
||||
secondary_ip_ranges:
|
||||
description:
|
||||
- An array of configurations for secondary IP ranges for VM instances contained in
|
||||
this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange
|
||||
of the subnetwork. The alias IPs may belong to either primary or secondary ranges.
|
||||
required: false
|
||||
version_added: 2.8
|
||||
suboptions:
|
||||
range_name:
|
||||
description:
|
||||
- The name associated with this subnetwork secondary range, used when adding an alias
|
||||
IP range to a VM instance. The name must be 1-63 characters long, and comply with
|
||||
RFC1035. The name must be unique within the subnetwork.
|
||||
required: true
|
||||
ip_cidr_range:
|
||||
description:
|
||||
- The range of IP addresses belonging to this subnetwork secondary range. Provide
|
||||
this property when you create the subnetwork.
|
||||
- Ranges must be unique and non-overlapping with all primary and secondary IP ranges
|
||||
within a network. Only IPv4 is supported.
|
||||
required: true
|
||||
private_ip_google_access:
|
||||
description:
|
||||
- Whether the VMs in this subnet can access Google services without assigned external
|
||||
IP addresses.
|
||||
required: false
|
||||
type: bool
|
||||
region:
|
||||
description:
|
||||
- URL of the GCP region for this subnetwork.
|
||||
- The range of IP addresses belonging to this subnetwork secondary range.
|
||||
Provide this property when you create the subnetwork.
|
||||
- Ranges must be unique and non-overlapping with all primary and secondary
|
||||
IP ranges within a network. Only IPv4 is supported.
|
||||
required: true
|
||||
private_ip_google_access:
|
||||
description:
|
||||
- Whether the VMs in this subnet can access Google services without assigned external
|
||||
IP addresses.
|
||||
required: false
|
||||
type: bool
|
||||
region:
|
||||
description:
|
||||
- URL of the GCP region for this subnetwork.
|
||||
required: true
|
||||
extends_documentation_fragment: gcp
|
||||
notes:
|
||||
- "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/subnetworks)"
|
||||
- "Private Google Access: U(https://cloud.google.com/vpc/docs/configure-private-google-access)"
|
||||
- "Cloud Networking: U(https://cloud.google.com/vpc/docs/using-vpc)"
|
||||
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/subnetworks)'
|
||||
- 'Private Google Access: U(https://cloud.google.com/vpc/docs/configure-private-google-access)'
|
||||
- 'Cloud Networking: U(https://cloud.google.com/vpc/docs/using-vpc)'
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -161,97 +163,97 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
RETURN = '''
|
||||
creationTimestamp:
|
||||
description:
|
||||
- Creation timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource. This field can be set only at resource creation time.
|
||||
returned: success
|
||||
type: str
|
||||
gatewayAddress:
|
||||
description:
|
||||
- The gateway address for default routes to reach destination addresses outside this
|
||||
subnetwork.
|
||||
returned: success
|
||||
type: str
|
||||
id:
|
||||
description:
|
||||
- The unique identifier for the resource.
|
||||
returned: success
|
||||
type: int
|
||||
creationTimestamp:
|
||||
description:
|
||||
- Creation timestamp in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
description:
|
||||
description:
|
||||
- An optional description of this resource. Provide this property when you create
|
||||
the resource. This field can be set only at resource creation time.
|
||||
returned: success
|
||||
type: str
|
||||
gatewayAddress:
|
||||
description:
|
||||
- The gateway address for default routes to reach destination addresses outside
|
||||
this subnetwork.
|
||||
returned: success
|
||||
type: str
|
||||
id:
|
||||
description:
|
||||
- The unique identifier for the resource.
|
||||
returned: success
|
||||
type: int
|
||||
ipCidrRange:
|
||||
description:
|
||||
- The range of internal addresses that are owned by this subnetwork.
|
||||
- Provide this property when you create the subnetwork. For example, 10.0.0.0/8
|
||||
or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network.
|
||||
Only IPv4 is supported.
|
||||
returned: success
|
||||
type: str
|
||||
name:
|
||||
description:
|
||||
- The name of the resource, provided by the client when initially creating 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 `[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.
|
||||
returned: success
|
||||
type: str
|
||||
network:
|
||||
description:
|
||||
- The network this subnet belongs to.
|
||||
- Only networks that are in the distributed mode can have subnetworks.
|
||||
returned: success
|
||||
type: dict
|
||||
enableFlowLogs:
|
||||
description:
|
||||
- Whether to enable flow logging for this subnetwork.
|
||||
returned: success
|
||||
type: bool
|
||||
fingerprint:
|
||||
description:
|
||||
- Fingerprint of this resource. This field is used internally during updates of
|
||||
this resource.
|
||||
returned: success
|
||||
type: str
|
||||
secondaryIpRanges:
|
||||
description:
|
||||
- An array of configurations for secondary IP ranges for VM instances contained
|
||||
in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange
|
||||
of the subnetwork. The alias IPs may belong to either primary or secondary ranges.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
rangeName:
|
||||
description:
|
||||
- The name associated with this subnetwork secondary range, used when adding
|
||||
an alias IP range to a VM instance. The name must be 1-63 characters long,
|
||||
and comply with RFC1035. The name must be unique within the subnetwork.
|
||||
returned: success
|
||||
type: str
|
||||
ipCidrRange:
|
||||
description:
|
||||
- The range of internal addresses that are owned by this subnetwork.
|
||||
- Provide this property when you create the subnetwork. For example, 10.0.0.0/8 or
|
||||
192.168.0.0/16. Ranges must be unique and non-overlapping within a network. Only
|
||||
IPv4 is supported.
|
||||
returned: success
|
||||
type: str
|
||||
name:
|
||||
description:
|
||||
- The name of the resource, provided by the client when initially creating 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 `[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.
|
||||
returned: success
|
||||
type: str
|
||||
network:
|
||||
description:
|
||||
- The network this subnet belongs to.
|
||||
- Only networks that are in the distributed mode can have subnetworks.
|
||||
returned: success
|
||||
type: dict
|
||||
enableFlowLogs:
|
||||
description:
|
||||
- Whether to enable flow logging for this subnetwork.
|
||||
returned: success
|
||||
type: bool
|
||||
fingerprint:
|
||||
description:
|
||||
- Fingerprint of this resource. This field is used internally during updates of this
|
||||
resource.
|
||||
returned: success
|
||||
type: str
|
||||
secondaryIpRanges:
|
||||
description:
|
||||
- An array of configurations for secondary IP ranges for VM instances contained in
|
||||
this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange
|
||||
of the subnetwork. The alias IPs may belong to either primary or secondary ranges.
|
||||
returned: success
|
||||
type: complex
|
||||
contains:
|
||||
rangeName:
|
||||
description:
|
||||
- The name associated with this subnetwork secondary range, used when adding an alias
|
||||
IP range to a VM instance. The name must be 1-63 characters long, and comply with
|
||||
RFC1035. The name must be unique within the subnetwork.
|
||||
returned: success
|
||||
type: str
|
||||
ipCidrRange:
|
||||
description:
|
||||
- The range of IP addresses belonging to this subnetwork secondary range. Provide
|
||||
this property when you create the subnetwork.
|
||||
- Ranges must be unique and non-overlapping with all primary and secondary IP ranges
|
||||
within a network. Only IPv4 is supported.
|
||||
returned: success
|
||||
type: str
|
||||
privateIpGoogleAccess:
|
||||
description:
|
||||
- Whether the VMs in this subnet can access Google services without assigned external
|
||||
IP addresses.
|
||||
returned: success
|
||||
type: bool
|
||||
region:
|
||||
description:
|
||||
- URL of the GCP region for this subnetwork.
|
||||
returned: success
|
||||
type: str
|
||||
description:
|
||||
- The range of IP addresses belonging to this subnetwork secondary range. Provide
|
||||
this property when you create the subnetwork.
|
||||
- Ranges must be unique and non-overlapping with all primary and secondary IP
|
||||
ranges within a network. Only IPv4 is supported.
|
||||
returned: success
|
||||
type: str
|
||||
privateIpGoogleAccess:
|
||||
description:
|
||||
- Whether the VMs in this subnet can access Google services without assigned external
|
||||
IP addresses.
|
||||
returned: success
|
||||
type: bool
|
||||
region:
|
||||
description:
|
||||
- URL of the GCP region for this subnetwork.
|
||||
returned: success
|
||||
type: str
|
||||
'''
|
||||
|
||||
################################################################################
|
||||
|
@ -361,7 +363,7 @@ def enable_flow_logs_update(module, request, response):
|
|||
{
|
||||
u'enableFlowLogs': module.params.get('enable_flow_logs'),
|
||||
u'fingerprint': response.get('fingerprint'),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryIpRangesArray(module.params.get('secondary_ip_ranges', []), module).to_request()
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request()
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -392,7 +394,7 @@ def resource_to_request(module):
|
|||
u'name': module.params.get('name'),
|
||||
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
||||
u'enableFlowLogs': module.params.get('enable_flow_logs'),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryIpRangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(),
|
||||
u'privateIpGoogleAccess': module.params.get('private_ip_google_access'),
|
||||
u'region': module.params.get('region')
|
||||
}
|
||||
|
@ -469,7 +471,7 @@ def response_to_hash(module, response):
|
|||
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
||||
u'enableFlowLogs': response.get(u'enableFlowLogs'),
|
||||
u'fingerprint': response.get(u'fingerprint'),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryIpRangesArray(response.get(u'secondaryIpRanges', []), module).from_response(),
|
||||
u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(response.get(u'secondaryIpRanges', []), module).from_response(),
|
||||
u'privateIpGoogleAccess': response.get(u'privateIpGoogleAccess'),
|
||||
u'region': module.params.get('region')
|
||||
}
|
||||
|
@ -499,8 +501,6 @@ def wait_for_completion(status, op_result, module):
|
|||
while status != 'DONE':
|
||||
raise_if_errors(op_result, ['error', 'errors'], 'message')
|
||||
time.sleep(1.0)
|
||||
if status not in ['PENDING', 'RUNNING', 'DONE']:
|
||||
module.fail_json(msg="Invalid result %s" % status)
|
||||
op_result = fetch_resource(module, op_uri, 'compute#operation')
|
||||
status = navigate_hash(op_result, ['status'])
|
||||
return op_result
|
||||
|
@ -512,7 +512,7 @@ def raise_if_errors(response, err_path, module):
|
|||
module.fail_json(msg=errors)
|
||||
|
||||
|
||||
class SubnetworkSecondaryIpRangesArray(object):
|
||||
class SubnetworkSecondaryiprangesArray(object):
|
||||
def __init__(self, request, module):
|
||||
self.module = module
|
||||
if request:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue