mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Bug fixes for gcp_compute_global_forwarding_rule (#42810)
This commit is contained in:
parent
56cc681d8c
commit
7a92b8c9ed
2 changed files with 113 additions and 109 deletions
|
@ -84,7 +84,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:
|
||||||
|
@ -105,14 +107,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:
|
||||||
|
@ -138,7 +143,12 @@ 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:
|
||||||
|
@ -152,30 +162,26 @@ extends_documentation_fragment: gcp
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: create a global address
|
- name: create a global address
|
||||||
gcp_compute_global_address:
|
gcp_compute_global_address:
|
||||||
name: 'globaladdress-globalforwardingrule'
|
name: "globaladdress-globalforwardingrule"
|
||||||
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: globaladdress
|
register: globaladdress
|
||||||
|
|
||||||
- name: create a instance group
|
- name: create a instance group
|
||||||
gcp_compute_instance_group:
|
gcp_compute_instance_group:
|
||||||
name: 'instancegroup-globalforwardingrule'
|
name: "instancegroup-globalforwardingrule"
|
||||||
zone: 'us-central1-a'
|
zone: us-central1-a
|
||||||
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: instancegroup
|
register: instancegroup
|
||||||
|
|
||||||
- name: create a http health check
|
- name: create a http health check
|
||||||
gcp_compute_http_health_check:
|
gcp_compute_http_health_check:
|
||||||
name: 'httphealthcheck-globalforwardingrule'
|
name: "httphealthcheck-globalforwardingrule"
|
||||||
healthy_threshold: 10
|
healthy_threshold: 10
|
||||||
port: 8080
|
port: 8080
|
||||||
timeout_sec: 2
|
timeout_sec: 2
|
||||||
|
@ -183,63 +189,53 @@ EXAMPLES = '''
|
||||||
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: healthcheck
|
register: healthcheck
|
||||||
|
|
||||||
- name: create a backend service
|
- name: create a backend service
|
||||||
gcp_compute_backend_service:
|
gcp_compute_backend_service:
|
||||||
name: 'backendservice-globalforwardingrule'
|
name: "backendservice-globalforwardingrule"
|
||||||
backends:
|
backends:
|
||||||
- group: "{{ instancegroup }}"
|
- group: "{{ instancegroup }}"
|
||||||
health_checks:
|
health_checks:
|
||||||
- "{{ healthcheck.selfLink }}"
|
- "{{ healthcheck.selfLink }}"
|
||||||
enable_cdn: true
|
enable_cdn: true
|
||||||
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: backendservice
|
register: backendservice
|
||||||
|
|
||||||
- name: create a url map
|
- name: create a url map
|
||||||
gcp_compute_url_map:
|
gcp_compute_url_map:
|
||||||
name: 'urlmap-globalforwardingrule'
|
name: "urlmap-globalforwardingrule"
|
||||||
default_service: "{{ backendservice }}"
|
default_service: "{{ backendservice }}"
|
||||||
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: urlmap
|
register: urlmap
|
||||||
|
|
||||||
- name: create a target http proxy
|
- name: create a target http proxy
|
||||||
gcp_compute_target_http_proxy:
|
gcp_compute_target_http_proxy:
|
||||||
name: 'targethttpproxy-globalforwardingrule'
|
name: "targethttpproxy-globalforwardingrule"
|
||||||
url_map: "{{ urlmap }}"
|
url_map: "{{ urlmap }}"
|
||||||
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: httpproxy
|
register: httpproxy
|
||||||
|
|
||||||
- name: create a global forwarding rule
|
- name: create a global forwarding rule
|
||||||
gcp_compute_global_forwarding_rule:
|
gcp_compute_global_forwarding_rule:
|
||||||
name: testObject
|
name: "test_object"
|
||||||
ip_address: "{{ globaladdress.address }}"
|
ip_address: "{{ globaladdress.address }}"
|
||||||
ip_protocol: 'TCP'
|
ip_protocol: TCP
|
||||||
port_range: '80-80'
|
port_range: 80-80
|
||||||
target: "{{ httpproxy.selfLink }}"
|
target: "{{ httpproxy.selfLink }}"
|
||||||
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
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -290,7 +286,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:
|
||||||
|
@ -312,7 +310,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.
|
||||||
|
@ -320,7 +318,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:
|
||||||
|
@ -349,12 +350,18 @@ 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
|
||||||
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
|
||||||
target:
|
target:
|
||||||
|
@ -400,6 +407,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'
|
||||||
|
|
||||||
|
@ -554,7 +564,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')
|
||||||
|
|
|
@ -15,28 +15,24 @@
|
||||||
# Pre-test setup
|
# Pre-test setup
|
||||||
- name: create a global address
|
- name: create a global address
|
||||||
gcp_compute_global_address:
|
gcp_compute_global_address:
|
||||||
name: 'globaladdress-globalforwardingrule'
|
name: "globaladdress-globalforwardingrule"
|
||||||
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: globaladdress
|
register: globaladdress
|
||||||
- name: create a instance group
|
- name: create a instance group
|
||||||
gcp_compute_instance_group:
|
gcp_compute_instance_group:
|
||||||
name: 'instancegroup-globalforwardingrule'
|
name: "instancegroup-globalforwardingrule"
|
||||||
zone: 'us-central1-a'
|
zone: us-central1-a
|
||||||
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: instancegroup
|
register: instancegroup
|
||||||
- name: create a http health check
|
- name: create a http health check
|
||||||
gcp_compute_http_health_check:
|
gcp_compute_http_health_check:
|
||||||
name: 'httphealthcheck-globalforwardingrule'
|
name: "httphealthcheck-globalforwardingrule"
|
||||||
healthy_threshold: 10
|
healthy_threshold: 10
|
||||||
port: 8080
|
port: 8080
|
||||||
timeout_sec: 2
|
timeout_sec: 2
|
||||||
|
@ -44,73 +40,61 @@
|
||||||
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: healthcheck
|
register: healthcheck
|
||||||
- name: create a backend service
|
- name: create a backend service
|
||||||
gcp_compute_backend_service:
|
gcp_compute_backend_service:
|
||||||
name: 'backendservice-globalforwardingrule'
|
name: "backendservice-globalforwardingrule"
|
||||||
backends:
|
backends:
|
||||||
- group: "{{ instancegroup }}"
|
- group: "{{ instancegroup }}"
|
||||||
health_checks:
|
health_checks:
|
||||||
- "{{ healthcheck.selfLink }}"
|
- "{{ healthcheck.selfLink }}"
|
||||||
enable_cdn: true
|
enable_cdn: true
|
||||||
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: backendservice
|
register: backendservice
|
||||||
- name: create a url map
|
- name: create a url map
|
||||||
gcp_compute_url_map:
|
gcp_compute_url_map:
|
||||||
name: 'urlmap-globalforwardingrule'
|
name: "urlmap-globalforwardingrule"
|
||||||
default_service: "{{ backendservice }}"
|
default_service: "{{ backendservice }}"
|
||||||
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: urlmap
|
register: urlmap
|
||||||
- name: create a target http proxy
|
- name: create a target http proxy
|
||||||
gcp_compute_target_http_proxy:
|
gcp_compute_target_http_proxy:
|
||||||
name: 'targethttpproxy-globalforwardingrule'
|
name: "targethttpproxy-globalforwardingrule"
|
||||||
url_map: "{{ urlmap }}"
|
url_map: "{{ urlmap }}"
|
||||||
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: httpproxy
|
register: httpproxy
|
||||||
- name: delete a global forwarding rule
|
- name: delete a global forwarding rule
|
||||||
gcp_compute_global_forwarding_rule:
|
gcp_compute_global_forwarding_rule:
|
||||||
name: "{{ resource_name }}"
|
name: "{{ resource_name }}"
|
||||||
ip_address: "{{ globaladdress.address }}"
|
ip_address: "{{ globaladdress.address }}"
|
||||||
ip_protocol: 'TCP'
|
ip_protocol: TCP
|
||||||
port_range: '80-80'
|
port_range: 80-80
|
||||||
target: "{{ httpproxy.selfLink }}"
|
target: "{{ httpproxy.selfLink }}"
|
||||||
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: absent
|
state: absent
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
- name: create a global forwarding rule
|
- name: create a global forwarding rule
|
||||||
gcp_compute_global_forwarding_rule:
|
gcp_compute_global_forwarding_rule:
|
||||||
name: "{{ resource_name }}"
|
name: "{{ resource_name }}"
|
||||||
ip_address: "{{ globaladdress.address }}"
|
ip_address: "{{ globaladdress.address }}"
|
||||||
ip_protocol: 'TCP'
|
ip_protocol: TCP
|
||||||
port_range: '80-80'
|
port_range: 80-80
|
||||||
target: "{{ httpproxy.selfLink }}"
|
target: "{{ httpproxy.selfLink }}"
|
||||||
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: result
|
register: result
|
||||||
- name: assert changed is true
|
- name: assert changed is true
|
||||||
|
@ -118,19 +102,31 @@
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- "result.kind == 'compute#forwardingRule'"
|
- "result.kind == 'compute#forwardingRule'"
|
||||||
# ----------------------------------------------------------------------------
|
- name: verify that global_forwarding_rule was created
|
||||||
- name: create a global forwarding rule that already exists
|
gcp_compute_global_forwarding_rule_facts:
|
||||||
gcp_compute_global_forwarding_rule:
|
filters:
|
||||||
name: "{{ resource_name }}"
|
- name = {{ resource_name }}
|
||||||
ip_address: "{{ globaladdress.address }}"
|
|
||||||
ip_protocol: 'TCP'
|
|
||||||
port_range: '80-80'
|
|
||||||
target: "{{ httpproxy.selfLink }}"
|
|
||||||
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:
|
scopes:
|
||||||
- https://www.googleapis.com/auth/compute
|
- https://www.googleapis.com/auth/compute
|
||||||
|
register: results
|
||||||
|
- name: verify that command succeeded
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- results['items'] | length == 1
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
- name: create a global forwarding rule that already exists
|
||||||
|
gcp_compute_global_forwarding_rule:
|
||||||
|
name: "{{ resource_name }}"
|
||||||
|
ip_address: "{{ globaladdress.address }}"
|
||||||
|
ip_protocol: TCP
|
||||||
|
port_range: 80-80
|
||||||
|
target: "{{ httpproxy.selfLink }}"
|
||||||
|
project: "{{ gcp_project }}"
|
||||||
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
|
service_account_file: "{{ gcp_cred_file }}"
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
- name: assert changed is false
|
- name: assert changed is false
|
||||||
|
@ -143,14 +139,12 @@
|
||||||
gcp_compute_global_forwarding_rule:
|
gcp_compute_global_forwarding_rule:
|
||||||
name: "{{ resource_name }}"
|
name: "{{ resource_name }}"
|
||||||
ip_address: "{{ globaladdress.address }}"
|
ip_address: "{{ globaladdress.address }}"
|
||||||
ip_protocol: 'TCP'
|
ip_protocol: TCP
|
||||||
port_range: '80-80'
|
port_range: 80-80
|
||||||
target: "{{ httpproxy.selfLink }}"
|
target: "{{ httpproxy.selfLink }}"
|
||||||
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: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
- name: assert changed is true
|
- name: assert changed is true
|
||||||
|
@ -158,19 +152,31 @@
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
- result.has_key('kind') == False
|
||||||
# ----------------------------------------------------------------------------
|
- name: verify that global_forwarding_rule was deleted
|
||||||
- name: delete a global forwarding rule that does not exist
|
gcp_compute_global_forwarding_rule_facts:
|
||||||
gcp_compute_global_forwarding_rule:
|
filters:
|
||||||
name: "{{ resource_name }}"
|
- name = {{ resource_name }}
|
||||||
ip_address: "{{ globaladdress.address }}"
|
|
||||||
ip_protocol: 'TCP'
|
|
||||||
port_range: '80-80'
|
|
||||||
target: "{{ httpproxy.selfLink }}"
|
|
||||||
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:
|
scopes:
|
||||||
- https://www.googleapis.com/auth/compute
|
- https://www.googleapis.com/auth/compute
|
||||||
|
register: results
|
||||||
|
- name: verify that command succeeded
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- results['items'] | length == 0
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
- name: delete a global forwarding rule that does not exist
|
||||||
|
gcp_compute_global_forwarding_rule:
|
||||||
|
name: "{{ resource_name }}"
|
||||||
|
ip_address: "{{ globaladdress.address }}"
|
||||||
|
ip_protocol: TCP
|
||||||
|
port_range: 80-80
|
||||||
|
target: "{{ httpproxy.selfLink }}"
|
||||||
|
project: "{{ gcp_project }}"
|
||||||
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
|
service_account_file: "{{ gcp_cred_file }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
- name: assert changed is false
|
- name: assert changed is false
|
||||||
|
@ -182,44 +188,38 @@
|
||||||
# Post-test teardown
|
# Post-test teardown
|
||||||
- name: delete a target http proxy
|
- name: delete a target http proxy
|
||||||
gcp_compute_target_http_proxy:
|
gcp_compute_target_http_proxy:
|
||||||
name: 'targethttpproxy-globalforwardingrule'
|
name: "targethttpproxy-globalforwardingrule"
|
||||||
url_map: "{{ urlmap }}"
|
url_map: "{{ urlmap }}"
|
||||||
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: absent
|
state: absent
|
||||||
register: httpproxy
|
register: httpproxy
|
||||||
- name: delete a url map
|
- name: delete a url map
|
||||||
gcp_compute_url_map:
|
gcp_compute_url_map:
|
||||||
name: 'urlmap-globalforwardingrule'
|
name: "urlmap-globalforwardingrule"
|
||||||
default_service: "{{ backendservice }}"
|
default_service: "{{ backendservice }}"
|
||||||
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: absent
|
state: absent
|
||||||
register: urlmap
|
register: urlmap
|
||||||
- name: delete a backend service
|
- name: delete a backend service
|
||||||
gcp_compute_backend_service:
|
gcp_compute_backend_service:
|
||||||
name: 'backendservice-globalforwardingrule'
|
name: "backendservice-globalforwardingrule"
|
||||||
backends:
|
backends:
|
||||||
- group: "{{ instancegroup }}"
|
- group: "{{ instancegroup }}"
|
||||||
health_checks:
|
health_checks:
|
||||||
- "{{ healthcheck.selfLink }}"
|
- "{{ healthcheck.selfLink }}"
|
||||||
enable_cdn: true
|
enable_cdn: true
|
||||||
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: absent
|
state: absent
|
||||||
register: backendservice
|
register: backendservice
|
||||||
- name: delete a http health check
|
- name: delete a http health check
|
||||||
gcp_compute_http_health_check:
|
gcp_compute_http_health_check:
|
||||||
name: 'httphealthcheck-globalforwardingrule'
|
name: "httphealthcheck-globalforwardingrule"
|
||||||
healthy_threshold: 10
|
healthy_threshold: 10
|
||||||
port: 8080
|
port: 8080
|
||||||
timeout_sec: 2
|
timeout_sec: 2
|
||||||
|
@ -227,28 +227,22 @@
|
||||||
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: absent
|
state: absent
|
||||||
register: healthcheck
|
register: healthcheck
|
||||||
- name: delete a instance group
|
- name: delete a instance group
|
||||||
gcp_compute_instance_group:
|
gcp_compute_instance_group:
|
||||||
name: 'instancegroup-globalforwardingrule'
|
name: "instancegroup-globalforwardingrule"
|
||||||
zone: 'us-central1-a'
|
zone: us-central1-a
|
||||||
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: absent
|
state: absent
|
||||||
register: instancegroup
|
register: instancegroup
|
||||||
- name: delete a global address
|
- name: delete a global address
|
||||||
gcp_compute_global_address:
|
gcp_compute_global_address:
|
||||||
name: 'globaladdress-globalforwardingrule'
|
name: "globaladdress-globalforwardingrule"
|
||||||
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: absent
|
state: absent
|
||||||
register: globaladdress
|
register: globaladdress
|
||||||
|
|
Loading…
Reference in a new issue