From 2eb8bf83f2fdf6779eb094275cb6b59a66feef8d Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 22 Apr 2019 11:10:48 -0700 Subject: [PATCH] Allow BackendService backends.group to ref multiple resource types (#232) /cc @rileykarson --- .../modules/gcp_compute_backend_service.py | 51 +++++++++++-------- .../gcp_compute_backend_service_facts.py | 22 +++++--- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/plugins/modules/gcp_compute_backend_service.py b/plugins/modules/gcp_compute_backend_service.py index 047575e..9eb96bb 100644 --- a/plugins/modules/gcp_compute_backend_service.py +++ b/plugins/modules/gcp_compute_backend_service.py @@ -90,18 +90,21 @@ options: required: false group: description: - - This instance group defines the list of instances that serve traffic. Member - virtual machine instances from each instance group must live in the same - zone as the instance group itself. - - No two backends in a backend service are allowed to use same Instance Group - resource. + - The fully-qualified URL of an Instance Group or Network Endpoint Group resource. + In case of instance group this defines the list of instances that serve + traffic. Member virtual machine instances from each instance group must + live in the same zone as the instance group itself. No two backends in a + backend service are allowed to use same Instance Group resource. + - For Network Endpoint Groups this defines list of endpoints. All endpoints + of Network Endpoint Group must be hosted on instances located in the same + zone as the Network Endpoint Group. + - Backend service can not contain mix of Instance Group and Network Endpoint + Group backends. + - Note that you must specify an Instance Group or Network Endpoint Group resource + using the fully-qualified URL, rather than a partial URL. - When the BackendService has load balancing scheme INTERNAL, the instance - group must be in a zone within the same region as the BackendService. - - 'This field represents a link to a InstanceGroup resource in GCP. It can - be specified in two ways. First, you can place a dictionary with key ''selfLink'' - and value of your resource''s selfLink Alternatively, you can add `register: - name-of-resource` to a gcp_compute_instance_group task and then set this - group field to "{{ name-of-resource }}"' + group must be within the same region as the BackendService. Network Endpoint + Groups are not supported for INTERNAL load balancing scheme. required: false max_connections: description: @@ -394,15 +397,23 @@ backends: type: str group: description: - - This instance group defines the list of instances that serve traffic. Member - virtual machine instances from each instance group must live in the same zone - as the instance group itself. - - No two backends in a backend service are allowed to use same Instance Group - resource. + - The fully-qualified URL of an Instance Group or Network Endpoint Group resource. + In case of instance group this defines the list of instances that serve traffic. + Member virtual machine instances from each instance group must live in the + same zone as the instance group itself. No two backends in a backend service + are allowed to use same Instance Group resource. + - For Network Endpoint Groups this defines list of endpoints. All endpoints + of Network Endpoint Group must be hosted on instances located in the same + zone as the Network Endpoint Group. + - Backend service can not contain mix of Instance Group and Network Endpoint + Group backends. + - Note that you must specify an Instance Group or Network Endpoint Group resource + using the fully-qualified URL, rather than a partial URL. - When the BackendService has load balancing scheme INTERNAL, the instance group - must be in a zone within the same region as the BackendService. + must be within the same region as the BackendService. Network Endpoint Groups + are not supported for INTERNAL load balancing scheme. returned: success - type: dict + type: str maxConnections: description: - The max number of simultaneous connections for the group. Can be used with @@ -659,7 +670,7 @@ def main(): balancing_mode=dict(default='UTILIZATION', type='str', choices=['UTILIZATION', 'RATE', 'CONNECTION']), capacity_scaler=dict(default=1.0, type='str'), description=dict(type='str'), - group=dict(type='dict'), + group=dict(type='str'), max_connections=dict(type='int'), max_connections_per_instance=dict(type='int'), max_rate=dict(type='int'), @@ -926,7 +937,7 @@ class BackendServiceBackendsArray(object): u'balancingMode': item.get('balancing_mode'), u'capacityScaler': item.get('capacity_scaler'), u'description': item.get('description'), - u'group': replace_resource_dict(item.get(u'group', {}), 'selfLink'), + u'group': item.get('group'), u'maxConnections': item.get('max_connections'), u'maxConnectionsPerInstance': item.get('max_connections_per_instance'), u'maxRate': item.get('max_rate'), diff --git a/plugins/modules/gcp_compute_backend_service_facts.py b/plugins/modules/gcp_compute_backend_service_facts.py index 3851ed0..c1efa95 100644 --- a/plugins/modules/gcp_compute_backend_service_facts.py +++ b/plugins/modules/gcp_compute_backend_service_facts.py @@ -107,15 +107,23 @@ items: type: str group: description: - - This instance group defines the list of instances that serve traffic. - Member virtual machine instances from each instance group must live in - the same zone as the instance group itself. - - No two backends in a backend service are allowed to use same Instance - Group resource. + - The fully-qualified URL of an Instance Group or Network Endpoint Group + resource. In case of instance group this defines the list of instances + that serve traffic. Member virtual machine instances from each instance + group must live in the same zone as the instance group itself. No two + backends in a backend service are allowed to use same Instance Group resource. + - For Network Endpoint Groups this defines list of endpoints. All endpoints + of Network Endpoint Group must be hosted on instances located in the same + zone as the Network Endpoint Group. + - Backend service can not contain mix of Instance Group and Network Endpoint + Group backends. + - Note that you must specify an Instance Group or Network Endpoint Group + resource using the fully-qualified URL, rather than a partial URL. - When the BackendService has load balancing scheme INTERNAL, the instance - group must be in a zone within the same region as the BackendService. + group must be within the same region as the BackendService. Network Endpoint + Groups are not supported for INTERNAL load balancing scheme. returned: success - type: dict + type: str maxConnections: description: - The max number of simultaneous connections for the group. Can be used