|
|
@ -46,8 +46,8 @@ description:
|
|
|
|
to another virtual machine destination, a virtual machine gateway or a Compute Engine-operated
|
|
|
|
to another virtual machine destination, a virtual machine gateway or a Compute Engine-operated
|
|
|
|
gateway. Packets that do not match any route in the sending virtual machine's routing
|
|
|
|
gateway. Packets that do not match any route in the sending virtual machine's routing
|
|
|
|
table will be dropped.
|
|
|
|
table will be dropped.
|
|
|
|
- A Routes resources must have exactly one specification of either nextHopGateway,
|
|
|
|
- A Route resource must have exactly one specification of either nextHopGateway, nextHopInstance,
|
|
|
|
nextHopInstance, nextHopIp, or nextHopVpnTunnel.
|
|
|
|
nextHopIp, or nextHopVpnTunnel.
|
|
|
|
short_description: Creates a GCP Route
|
|
|
|
short_description: Creates a GCP Route
|
|
|
|
version_added: 2.6
|
|
|
|
version_added: 2.6
|
|
|
|
author: Google Inc. (@googlecloudplatform)
|
|
|
|
author: Google Inc. (@googlecloudplatform)
|
|
|
@ -65,7 +65,13 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The destination range of outgoing packets that this route applies to.
|
|
|
|
- The destination range of outgoing packets that this route applies to.
|
|
|
|
- Only IPv4 is supported.
|
|
|
|
- Only IPv4 is supported.
|
|
|
|
|
|
|
|
required: true
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- An optional description of this resource. Provide this property when you create
|
|
|
|
|
|
|
|
the resource.
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
version_added: 2.7
|
|
|
|
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. The name
|
|
|
@ -74,11 +80,11 @@ options:
|
|
|
|
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 characters
|
|
|
|
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
|
|
|
must be a dash, lowercase letter, or digit, except the last character, which cannot
|
|
|
|
be a dash.
|
|
|
|
be a dash.
|
|
|
|
required: false
|
|
|
|
required: true
|
|
|
|
network:
|
|
|
|
network:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Network resource.
|
|
|
|
- The network that this route applies to.
|
|
|
|
required: false
|
|
|
|
required: true
|
|
|
|
priority:
|
|
|
|
priority:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The priority of this route. Priority is used to break ties in cases where there
|
|
|
|
- The priority of this route. Priority is used to break ties in cases where there
|
|
|
@ -102,11 +108,9 @@ options:
|
|
|
|
next_hop_instance:
|
|
|
|
next_hop_instance:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- URL to an instance that should handle matching packets.
|
|
|
|
- URL to an instance that should handle matching packets.
|
|
|
|
- 'You can specify this as a full or partial URL. For example: *
|
|
|
|
- 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/)
|
|
|
|
U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/)
|
|
|
|
instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance
|
|
|
|
instances/instance *
|
|
|
|
.'
|
|
|
|
projects/project/zones/zone/instances/instance *
|
|
|
|
|
|
|
|
zones/zone/instances/instance .'
|
|
|
|
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
next_hop_ip:
|
|
|
|
next_hop_ip:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -117,34 +121,33 @@ options:
|
|
|
|
- URL to a VpnTunnel that should handle matching packets.
|
|
|
|
- URL to a VpnTunnel that should handle matching packets.
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
extends_documentation_fragment: gcp
|
|
|
|
extends_documentation_fragment: gcp
|
|
|
|
|
|
|
|
notes:
|
|
|
|
|
|
|
|
- "API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/routes)"
|
|
|
|
|
|
|
|
- "Using Routes: U(https://cloud.google.com/vpc/docs/using-routes)"
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = '''
|
|
|
|
- name: create a network
|
|
|
|
- name: create a network
|
|
|
|
gcp_compute_network:
|
|
|
|
gcp_compute_network:
|
|
|
|
name: 'network-route'
|
|
|
|
name: "network-route"
|
|
|
|
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 }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
register: network
|
|
|
|
register: network
|
|
|
|
|
|
|
|
|
|
|
|
- name: create a route
|
|
|
|
- name: create a route
|
|
|
|
gcp_compute_route:
|
|
|
|
gcp_compute_route:
|
|
|
|
name: testObject
|
|
|
|
name: "test_object"
|
|
|
|
dest_range: '192.168.6.0/24'
|
|
|
|
dest_range: 192.168.6.0/24
|
|
|
|
next_hop_gateway: 'global/gateways/default-internet-gateway'
|
|
|
|
next_hop_gateway: global/gateways/default-internet-gateway
|
|
|
|
network: "{{ network }}"
|
|
|
|
network: "{{ network }}"
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- backends
|
|
|
|
- backends
|
|
|
|
- databases
|
|
|
|
- databases
|
|
|
|
project: testProject
|
|
|
|
project: "test_project"
|
|
|
|
auth_kind: service_account
|
|
|
|
auth_kind: "service_account"
|
|
|
|
service_account_file: /tmp/auth.pem
|
|
|
|
service_account_file: "/tmp/auth.pem"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
@ -155,6 +158,12 @@ RETURN = '''
|
|
|
|
- Only IPv4 is supported.
|
|
|
|
- Only IPv4 is supported.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- An optional description of this resource. Provide this property when you create
|
|
|
|
|
|
|
|
the resource.
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
|
|
|
|
type: str
|
|
|
|
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. The name
|
|
|
@ -167,7 +176,7 @@ RETURN = '''
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
network:
|
|
|
|
network:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Network resource.
|
|
|
|
- The network that this route applies to.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
|
priority:
|
|
|
|
priority:
|
|
|
@ -196,11 +205,9 @@ RETURN = '''
|
|
|
|
next_hop_instance:
|
|
|
|
next_hop_instance:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- URL to an instance that should handle matching packets.
|
|
|
|
- URL to an instance that should handle matching packets.
|
|
|
|
- 'You can specify this as a full or partial URL. For example: *
|
|
|
|
- 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/)
|
|
|
|
U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/)
|
|
|
|
instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance
|
|
|
|
instances/instance *
|
|
|
|
.'
|
|
|
|
projects/project/zones/zone/instances/instance *
|
|
|
|
|
|
|
|
zones/zone/instances/instance .'
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
next_hop_ip:
|
|
|
|
next_hop_ip:
|
|
|
@ -213,6 +220,11 @@ RETURN = '''
|
|
|
|
- URL to a VpnTunnel that should handle matching packets.
|
|
|
|
- URL to a VpnTunnel that should handle matching packets.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
|
|
|
|
next_hop_network:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- URL to a Network that should handle matching packets.
|
|
|
|
|
|
|
|
returned: success
|
|
|
|
|
|
|
|
type: str
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
@ -234,9 +246,10 @@ def main():
|
|
|
|
module = GcpModule(
|
|
|
|
module = GcpModule(
|
|
|
|
argument_spec=dict(
|
|
|
|
argument_spec=dict(
|
|
|
|
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
|
|
|
state=dict(default='present', choices=['present', 'absent'], type='str'),
|
|
|
|
dest_range=dict(type='str'),
|
|
|
|
dest_range=dict(required=True, type='str'),
|
|
|
|
name=dict(type='str'),
|
|
|
|
description=dict(type='str'),
|
|
|
|
network=dict(type='dict'),
|
|
|
|
name=dict(required=True, type='str'),
|
|
|
|
|
|
|
|
network=dict(required=True, type='dict'),
|
|
|
|
priority=dict(type='int'),
|
|
|
|
priority=dict(type='int'),
|
|
|
|
tags=dict(type='list', elements='str'),
|
|
|
|
tags=dict(type='list', elements='str'),
|
|
|
|
next_hop_gateway=dict(type='str'),
|
|
|
|
next_hop_gateway=dict(type='str'),
|
|
|
@ -246,6 +259,9 @@ def main():
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not module.params['scopes']:
|
|
|
|
|
|
|
|
module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
|
|
|
|
|
|
|
|
|
|
|
|
state = module.params['state']
|
|
|
|
state = module.params['state']
|
|
|
|
kind = 'compute#route'
|
|
|
|
kind = 'compute#route'
|
|
|
|
|
|
|
|
|
|
|
@ -292,6 +308,7 @@ def resource_to_request(module):
|
|
|
|
request = {
|
|
|
|
request = {
|
|
|
|
u'kind': 'compute#route',
|
|
|
|
u'kind': 'compute#route',
|
|
|
|
u'destRange': module.params.get('dest_range'),
|
|
|
|
u'destRange': module.params.get('dest_range'),
|
|
|
|
|
|
|
|
u'description': module.params.get('description'),
|
|
|
|
u'name': module.params.get('name'),
|
|
|
|
u'name': module.params.get('name'),
|
|
|
|
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
|
|
|
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
|
|
|
u'priority': module.params.get('priority'),
|
|
|
|
u'priority': module.params.get('priority'),
|
|
|
@ -368,6 +385,7 @@ def is_different(module, response):
|
|
|
|
def response_to_hash(module, response):
|
|
|
|
def response_to_hash(module, response):
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
u'destRange': response.get(u'destRange'),
|
|
|
|
u'destRange': response.get(u'destRange'),
|
|
|
|
|
|
|
|
u'description': response.get(u'description'),
|
|
|
|
u'name': response.get(u'name'),
|
|
|
|
u'name': response.get(u'name'),
|
|
|
|
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
|
|
|
u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
|
|
|
|
u'priority': module.params.get('priority'),
|
|
|
|
u'priority': module.params.get('priority'),
|
|
|
@ -375,7 +393,8 @@ def response_to_hash(module, response):
|
|
|
|
u'nextHopGateway': module.params.get('next_hop_gateway'),
|
|
|
|
u'nextHopGateway': module.params.get('next_hop_gateway'),
|
|
|
|
u'nextHopInstance': module.params.get('next_hop_instance'),
|
|
|
|
u'nextHopInstance': module.params.get('next_hop_instance'),
|
|
|
|
u'nextHopIp': module.params.get('next_hop_ip'),
|
|
|
|
u'nextHopIp': module.params.get('next_hop_ip'),
|
|
|
|
u'nextHopVpnTunnel': module.params.get('next_hop_vpn_tunnel')
|
|
|
|
u'nextHopVpnTunnel': module.params.get('next_hop_vpn_tunnel'),
|
|
|
|
|
|
|
|
u'nextHopNetwork': response.get(u'nextHopNetwork')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -391,7 +410,7 @@ def async_op_url(module, extra_data=None):
|
|
|
|
def wait_for_operation(module, response):
|
|
|
|
def wait_for_operation(module, response):
|
|
|
|
op_result = return_if_object(module, response, 'compute#operation')
|
|
|
|
op_result = return_if_object(module, response, 'compute#operation')
|
|
|
|
if op_result is None:
|
|
|
|
if op_result is None:
|
|
|
|
return None
|
|
|
|
return {}
|
|
|
|
status = navigate_hash(op_result, ['status'])
|
|
|
|
status = navigate_hash(op_result, ['status'])
|
|
|
|
wait_done = wait_for_completion(status, op_result, module)
|
|
|
|
wait_done = wait_for_completion(status, op_result, module)
|
|
|
|
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#route')
|
|
|
|
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#route')
|
|
|
|