|
|
@ -82,7 +82,9 @@ options:
|
|
|
|
choices: ['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP']
|
|
|
|
choices: ['TCP', 'UDP', 'ESP', 'AH', 'SCTP', 'ICMP']
|
|
|
|
backend_service:
|
|
|
|
backend_service:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to BackendService resource.
|
|
|
|
- A reference to a BackendService to receive the matched traffic.
|
|
|
|
|
|
|
|
- This is used for internal load balancing.
|
|
|
|
|
|
|
|
- "(not used for external load balancing) ."
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
ip_version:
|
|
|
|
ip_version:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -103,14 +105,17 @@ options:
|
|
|
|
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
|
|
|
|
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
|
|
|
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])?
|
|
|
|
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 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: true
|
|
|
|
required: true
|
|
|
|
network:
|
|
|
|
network:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Network resource.
|
|
|
|
- For internal load balancing, this field identifies the network that the load balanced
|
|
|
|
|
|
|
|
IP should belong to for this Forwarding Rule. If this field is not specified, the
|
|
|
|
|
|
|
|
default network will be used.
|
|
|
|
|
|
|
|
- This field is not used for external load balancing.
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
port_range:
|
|
|
|
port_range:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -136,57 +141,65 @@ options:
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
subnetwork:
|
|
|
|
subnetwork:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Subnetwork resource.
|
|
|
|
- A reference to a subnetwork.
|
|
|
|
|
|
|
|
- For internal load balancing, this field identifies the subnetwork that the load
|
|
|
|
|
|
|
|
balanced IP should belong to for this Forwarding Rule.
|
|
|
|
|
|
|
|
- If the network specified is in auto subnet mode, this field is optional. However,
|
|
|
|
|
|
|
|
if the network is in custom subnet mode, a subnetwork must be specified.
|
|
|
|
|
|
|
|
- This field is not used for external load balancing.
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
target:
|
|
|
|
target:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to TargetPool resource.
|
|
|
|
- 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
|
|
|
|
|
|
|
|
rule. For global forwarding rules, this target must be a global load balancing resource.
|
|
|
|
|
|
|
|
The forwarded traffic must be of a type appropriate to the target object.
|
|
|
|
|
|
|
|
- This field is not used for internal load balancing.
|
|
|
|
required: false
|
|
|
|
required: false
|
|
|
|
|
|
|
|
version_added: 2.7
|
|
|
|
region:
|
|
|
|
region:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Region resource.
|
|
|
|
- A reference to the region where the regional forwarding rule resides.
|
|
|
|
|
|
|
|
- This field is not applicable to global forwarding rules.
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
extends_documentation_fragment: gcp
|
|
|
|
extends_documentation_fragment: gcp
|
|
|
|
|
|
|
|
notes:
|
|
|
|
|
|
|
|
- "API Reference: U(https://cloud.google.com/compute/docs/reference/latest/forwardingRule)"
|
|
|
|
|
|
|
|
- "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 }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
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 }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
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: testObject
|
|
|
|
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: 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
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
@ -237,7 +250,9 @@ RETURN = '''
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
backend_service:
|
|
|
|
backend_service:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to BackendService resource.
|
|
|
|
- A reference to a BackendService to receive the matched traffic.
|
|
|
|
|
|
|
|
- This is used for internal load balancing.
|
|
|
|
|
|
|
|
- "(not used for external load balancing) ."
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
|
ip_version:
|
|
|
|
ip_version:
|
|
|
@ -259,7 +274,7 @@ RETURN = '''
|
|
|
|
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
|
|
|
|
must be 1-63 characters long, and comply with RFC1035. Specifically, the name must
|
|
|
|
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])?
|
|
|
|
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 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.
|
|
|
@ -267,7 +282,10 @@ RETURN = '''
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
network:
|
|
|
|
network:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Network resource.
|
|
|
|
- For internal load balancing, this field identifies the network that the load balanced
|
|
|
|
|
|
|
|
IP should belong to for this Forwarding Rule. If this field is not specified, the
|
|
|
|
|
|
|
|
default network will be used.
|
|
|
|
|
|
|
|
- This field is not used for external load balancing.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
|
port_range:
|
|
|
|
port_range:
|
|
|
@ -296,17 +314,27 @@ RETURN = '''
|
|
|
|
type: list
|
|
|
|
type: list
|
|
|
|
subnetwork:
|
|
|
|
subnetwork:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Subnetwork resource.
|
|
|
|
- A reference to a subnetwork.
|
|
|
|
|
|
|
|
- For internal load balancing, this field identifies the subnetwork that the load
|
|
|
|
|
|
|
|
balanced IP should belong to for this Forwarding Rule.
|
|
|
|
|
|
|
|
- If the network specified is in auto subnet mode, this field is optional. However,
|
|
|
|
|
|
|
|
if the network is in custom subnet mode, a subnetwork must be specified.
|
|
|
|
|
|
|
|
- This field is not used for external load balancing.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
|
target:
|
|
|
|
target:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to TargetPool resource.
|
|
|
|
- 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
|
|
|
|
|
|
|
|
rule. For global forwarding rules, this target must be a global load balancing resource.
|
|
|
|
|
|
|
|
The forwarded traffic must be of a type appropriate to the target object.
|
|
|
|
|
|
|
|
- This field is not used for internal load balancing.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: dict
|
|
|
|
type: dict
|
|
|
|
region:
|
|
|
|
region:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- A reference to Region resource.
|
|
|
|
- A reference to the region where the regional forwarding rule resides.
|
|
|
|
|
|
|
|
- This field is not applicable to global forwarding rules.
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: str
|
|
|
|
type: str
|
|
|
|
'''
|
|
|
|
'''
|
|
|
@ -346,6 +374,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#forwardingRule'
|
|
|
|
kind = 'compute#forwardingRule'
|
|
|
|
|
|
|
|
|
|
|
@ -499,7 +530,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#forwardingRule')
|
|
|
|
return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#forwardingRule')
|
|
|
|