diff --git a/plugins/modules/gcp_container_cluster.py b/plugins/modules/gcp_container_cluster.py index d525a1d..d3eb799 100644 --- a/plugins/modules/gcp_container_cluster.py +++ b/plugins/modules/gcp_container_cluster.py @@ -522,6 +522,35 @@ options: required: false type: str version_added: 2.9 + master_authorized_networks_config: + description: + - Configuration for controlling how IPs are allocated in the cluster. + required: false + type: dict + version_added: 2.9 + suboptions: + enabled: + description: + - Whether or not master authorized networks is enabled. + required: false + type: bool + cidr_blocks: + description: + - Define up to 50 external networks that could access Kubernetes master through + HTTPS. + required: false + type: list + suboptions: + display_name: + description: + - Optional field used to identify cidr blocks. + required: false + type: str + cidr_block: + description: + - Block specified in CIDR notation. + required: false + type: str location: description: - The location where the cluster is deployed. @@ -1129,6 +1158,34 @@ conditions: - Human-friendly representation of the condition. returned: success type: str +masterAuthorizedNetworksConfig: + description: + - Configuration for controlling how IPs are allocated in the cluster. + returned: success + type: complex + contains: + enabled: + description: + - Whether or not master authorized networks is enabled. + returned: success + type: bool + cidrBlocks: + description: + - Define up to 50 external networks that could access Kubernetes master through + HTTPS. + returned: success + type: complex + contains: + displayName: + description: + - Optional field used to identify cidr blocks. + returned: success + type: str + cidrBlock: + description: + - Block specified in CIDR notation. + returned: success + type: str location: description: - The location where the cluster is deployed. @@ -1237,6 +1294,13 @@ def main(): ), enable_tpu=dict(type='bool'), tpu_ipv4_cidr_block=dict(type='str'), + master_authorized_networks_config=dict( + type='dict', + options=dict( + enabled=dict(type='bool'), + cidr_blocks=dict(type='list', elements='dict', options=dict(display_name=dict(type='str'), cidr_block=dict(type='str'))), + ), + ), location=dict(required=True, type='str', aliases=['zone']), kubectl_path=dict(type='str'), kubectl_context=dict(type='str'), @@ -1313,6 +1377,9 @@ def resource_to_request(module): u'ipAllocationPolicy': ClusterIpallocationpolicy(module.params.get('ip_allocation_policy', {}), module).to_request(), u'enableTpu': module.params.get('enable_tpu'), u'tpuIpv4CidrBlock': module.params.get('tpu_ipv4_cidr_block'), + u'masterAuthorizedNetworksConfig': ClusterMasterauthorizednetworksconfig( + module.params.get('master_authorized_networks_config', {}), module + ).to_request(), } request = encode_request(request, module) return_vals = {} @@ -1412,6 +1479,7 @@ def response_to_hash(module, response): u'enableTpu': response.get(u'enableTpu'), u'tpuIpv4CidrBlock': response.get(u'tpuIpv4CidrBlock'), u'conditions': ClusterConditionsArray(response.get(u'conditions', []), module).from_response(), + u'masterAuthorizedNetworksConfig': ClusterMasterauthorizednetworksconfig(response.get(u'masterAuthorizedNetworksConfig', {}), module).from_response(), } @@ -1901,5 +1969,51 @@ class ClusterConditionsArray(object): return remove_nones_from_dict({u'code': item.get(u'code'), u'message': item.get(u'message')}) +class ClusterMasterauthorizednetworksconfig(object): + def __init__(self, request, module): + self.module = module + if request: + self.request = request + else: + self.request = {} + + def to_request(self): + return remove_nones_from_dict( + {u'enabled': self.request.get('enabled'), u'cidrBlocks': ClusterCidrblocksArray(self.request.get('cidr_blocks', []), self.module).to_request()} + ) + + def from_response(self): + return remove_nones_from_dict( + {u'enabled': self.request.get(u'enabled'), u'cidrBlocks': ClusterCidrblocksArray(self.request.get(u'cidrBlocks', []), self.module).from_response()} + ) + + +class ClusterCidrblocksArray(object): + def __init__(self, request, module): + self.module = module + if request: + self.request = request + else: + self.request = [] + + def to_request(self): + items = [] + for item in self.request: + items.append(self._request_for_item(item)) + return items + + def from_response(self): + items = [] + for item in self.request: + items.append(self._response_from_item(item)) + return items + + def _request_for_item(self, item): + return remove_nones_from_dict({u'displayName': item.get('display_name'), u'cidrBlock': item.get('cidr_block')}) + + def _response_from_item(self, item): + return remove_nones_from_dict({u'displayName': item.get(u'displayName'), u'cidrBlock': item.get(u'cidrBlock')}) + + if __name__ == '__main__': main() diff --git a/plugins/modules/gcp_container_cluster_info.py b/plugins/modules/gcp_container_cluster_info.py index 30176fe..772d48a 100644 --- a/plugins/modules/gcp_container_cluster_info.py +++ b/plugins/modules/gcp_container_cluster_info.py @@ -632,6 +632,34 @@ resources: - Human-friendly representation of the condition. returned: success type: str + masterAuthorizedNetworksConfig: + description: + - Configuration for controlling how IPs are allocated in the cluster. + returned: success + type: complex + contains: + enabled: + description: + - Whether or not master authorized networks is enabled. + returned: success + type: bool + cidrBlocks: + description: + - Define up to 50 external networks that could access Kubernetes master + through HTTPS. + returned: success + type: complex + contains: + displayName: + description: + - Optional field used to identify cidr blocks. + returned: success + type: str + cidrBlock: + description: + - Block specified in CIDR notation. + returned: success + type: str location: description: - The location where the cluster is deployed.