diff --git a/plugins/module_utils/cdp_common.py b/plugins/module_utils/cdp_common.py index 0703f01f..701c75d2 100644 --- a/plugins/module_utils/cdp_common.py +++ b/plugins/module_utils/cdp_common.py @@ -78,6 +78,14 @@ def _get_param(self, param, default=None): return self.module.params[param] if param in self.module.params else default return default + def _get_nested_param(self, param, suboption, default=None): + """Fetches an nested suboption from an Ansible Input Parameter if it exists, else returns optional default or None""" + if self.module is not None: + if param in self.module.params and self.module.params[param] is not None: + param_suboptions = self.module.params[param] + return param_suboptions.get(suboption, default) + return default + def _cdp_module_throw_error(self, error: "CdpError"): """Error handler for CDPy SDK""" self.module.fail_json( diff --git a/plugins/modules/dw_cluster.py b/plugins/modules/dw_cluster.py index d92d1869..805f57ce 100644 --- a/plugins/modules/dw_cluster.py +++ b/plugins/modules/dw_cluster.py @@ -74,16 +74,64 @@ - Required if I(state=present) and the I(env) is deployed to AWS. type: list elements: str - az_subnet: + azure: description: - - The Azure Subnet Name. - - Required if I(state=present) and the I(env) is deployed to Azure. - type: str - az_enable_az: - description: - - Flag to enable Availability Zone mode. - - Required if I(state=present) and the I(env) is deployed to Azure. - type: bool + - Options for activating an Azure CDW Cluster + type: dict + elements: dict + required: False + suboptions: + subnet: + description: + - The Azure Subnet Name. + - Required if I(state=present) and the I(env) is deployed to Azure. + type: str + enable_az: + description: + - Flag to enable Availability Zone mode. + - Required if I(state=present) and the I(env) is deployed to Azure. + type: bool + managed_identity: + description: + - Resource ID of the managed identity used by AKS. + - Required if I(state=present) and the I(env) is deployed to Azure. + type: str + enable_private_aks: + description: + - Flag to enable Azure Private AKS mode. + type: bool + enable_private_sql: + description: + - Flag to enable private SQL for the cluster deployment. + type: bool + enable_spot_instances: + description: + - Flag to enable spot instances for Virtual warehouses. + type: bool + log_analytics_workspace_id: + description: + - Workspace ID for Azure log analytics. + - Used to monitor the Azure Kubernetes Service (AKS) cluster. + type: str + network_outbound_type: + description: + - Network outbound type. + - This setting controls the egress traffic for cluster nodes in Azure Kubernetes Service + type: str + choices: + - LoadBalancer + - UserAssignedNATGateway + - UserDefinedRouting + aks_private_dns_zone: + description: + - ID for the private DNS zone used by AKS. + type: str + compute_instance_types: + description: + - List of Azure Compute Instance Types that the AKS environment is restricted to use. + - Only a single instance type can be listed. + type: list + elements: str state: description: The state of the Data Warehouse Cluster type: str @@ -130,8 +178,10 @@ # Request Azure Cluster creation - cloudera.cloud.dw_cluster: env_crn: crn:cdp:environments... - az_subnet: my-subnet-name - az_enable_az: yes + azure: + subnet: my-subnet-name + enable_az: yes + managed_identity: my-aks-managed-identity # Request AWS Cluster Creation - cloudera.cloud.dw_cluster: @@ -222,8 +272,6 @@ def __init__(self, module): self.env = self._get_param('env') self.overlay = self._get_param('overlay') self.private_load_balancer = self._get_param('private_load_balancer') - self.az_subnet = self._get_param('az_subnet') - self.az_enable_az = self._get_param('az_enable_az') self.aws_lb_subnets = self._get_param('aws_lb_subnets') self.aws_worker_subnets = self._get_param('aws_worker_subnets') self.force = self._get_param('force') @@ -231,6 +279,17 @@ def __init__(self, module): self.wait = self._get_param('wait') self.delay = self._get_param('delay') self.timeout = self._get_param('timeout') + # Azure nested parameters + self.az_compute_instance_types = self._get_nested_param('azure', 'compute_instance_types') + self.az_enable_az = self._get_nested_param('azure', 'enable_az') + self.az_enable_private_aks = self._get_nested_param('azure', 'enable_private_aks') + self.az_enable_private_sql = self._get_nested_param('azure', 'enable_private_sql') + self.az_enable_spot_instances = self._get_nested_param('azure', 'enable_spot_instances') + self.az_log_analytics_workspace_id = self._get_nested_param('azure', 'log_analytics_workspace_id') + self.az_network_outbound_type = self._get_nested_param('azure', 'network_outbound_type') + self.az_aks_private_dns_zone = self._get_nested_param('azure', 'aks_private_dns_zone') + self.az_subnet = self._get_nested_param('azure', 'subnet') + self.az_managed_identity = self._get_nested_param('azure', 'managed_identity') # Initialize return values self.cluster = {} @@ -312,7 +371,11 @@ def process(self): self.name = self.cdpy.dw.create_cluster( env_crn=env_crn, overlay=self.overlay, private_load_balancer=self.private_load_balancer, aws_lb_subnets=self.aws_lb_subnets, aws_worker_subnets=self.aws_worker_subnets, - az_subnet=self.az_subnet, az_enable_az=self.az_enable_az + az_subnet=self.az_subnet, az_enable_az=self.az_enable_az, az_managed_identity=self.az_managed_identity, + az_enable_private_aks=self.az_enable_private_aks, az_enable_private_sql=self.az_enable_private_sql, + az_enable_spot_instances=self.az_enable_spot_instances, az_log_analytics_workspace_id=self.az_log_analytics_workspace_id, + az_network_outbound_type=self.az_network_outbound_type, az_aks_private_dns_zone=self.az_aks_private_dns_zone, + az_compute_instance_types=self.az_compute_instance_types ) if self.wait: self.cluster = self.cdpy.sdk.wait_for_state( @@ -335,8 +398,21 @@ def main(): env=dict(type='str', aliases=['environment', 'env_crn']), overlay=dict(type='bool', default=False), private_load_balancer=dict(type='bool', default=False), - az_subnet=dict(type='str'), - az_enable_az=dict(type='bool'), + azure=dict( + type='dict', + options=dict( + subnet=dict(type='str'), + enable_az=dict(type='bool'), + managed_identity=dict(type='str'), + enable_private_aks=dict(type='bool'), + enable_private_sql=dict(type='bool'), + enable_spot_instances=dict(type='bool'), + log_analytics_workspace_id=dict(type='str'), + network_outbound_type=dict(type='str', choices=['LoadBalancer','UserAssignedNATGateway','UserDefinedRouting']), + aks_private_dns_zone=dict(type='str'), + compute_instance_types=dict(type='list') + ) + ), aws_lb_subnets=dict(type='list', aliases=['aws_public_subnets']), aws_worker_subnets=dict(type='list', aliases=['aws_private_subnets']), state=dict(type='str', choices=['present', 'absent'], default='present'), @@ -346,7 +422,6 @@ def main(): timeout=dict(type='int', aliases=['polling_timeout'], default=3600) ), required_together=[ - ['az_subnet', 'az_enable_az'], ['aws_lb_subnets', 'aws_worker_subnets'] ], required_if=[