Skip to content

Commit cf65973

Browse files
Support CDW VW changes
1 parent df23de8 commit cf65973

File tree

5 files changed

+145
-23
lines changed

5 files changed

+145
-23
lines changed

roles/common/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ common__env_name_suffix: "{{ env.suffix | default(common__env_s
121121

122122
common__datalake_name: "{{ env.datalake.name | default([common__namespace_cdp, common__datalake_name_suffix] | join('-')) }}"
123123
common__datalake_name_suffix: "{{ env.datalake.suffix | default(common__datalake_suffix) }}"
124-
common__tunnel: "{{ env.tunnel | default(False) }}"
124+
common__tunnel: "{{ env.tunnel | default(True) }}"
125125
common__public_endpoint_access: "{{ env.public_endpoint_access | default(not common__tunnel) }}"
126126

127127
common__env_admin_password: "{{ globals.admin_password | mandatory }}"

roles/runtime/defaults/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ run__ml_tags: "{{ ml.tags | default(common__tags) }}"
5959
run__ml_public_loadbalancer: "{{ ml.public_loadbalancer | default(run__public_endpoint_access) }}"
6060

6161
run__dw_definitions: "{{ dw.definitions | default([{}]) }}"
62-
run__dw_suffix: "{{ dw.suffix | default('dw') }}"
62+
run__dw_dbc_suffix: "{{ dw.dbc.suffix | default('dbc') }}"
63+
run__dw_vw_suffix: "{{ dw.vw.suffix | default('vw') }}"
64+
run__dw_tags: "{{ dw.tags | default(common__tags) }}"
65+
run__dw_overlay_network: "{{ dw.overlay_network | bool }}"
66+
run__dw_private_load_balancer: "{{ dw.private_load_balancer | default(not run__public_endpoint_access) }}"
67+
run__dw_private_worker_nodes: "{{ dw.private_worker_nodes | bool }}"
6368

6469
run__df_nodes_min: "{{ df.min_k8s_nodes | default(3) }}"
6570
run__df_nodes_max: "{{ df.max_k8s_nodes | default(5) }}"

roles/runtime/tasks/initialize_base.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,42 @@
188188
- name: Prepare for CDP DW experiences
189189
when: run__include_dw
190190
block:
191-
- name: Retrieve CDP DW experiences
192-
cloudera.cloud.dw_cluster_info:
193-
env: "{{ run__env_name }}"
194-
register: run__dw_list
191+
- name: Construct CDP DW Data catalog configurations
192+
ansible.builtin.set_fact:
193+
run__dw_dbc_configs: "{{ run__dw_dbc_configs | default([]) | union([config]) }}"
194+
vars:
195+
include: "{{ lookup('template', __dw_config.include | default('experiences_config_placeholder.j2')) | from_yaml }}"
196+
use_default_dbc: "{{ __dw_config.use_default_dbc | default(False) | bool }}"
197+
default_dbc_name: "{{ None if use_default_dbc else [run__namespace, run__dw_dbc_suffix, __dw_config_index] | join('-') }}"
198+
config:
199+
name: "{{ __dw_config.name | default(default_dbc_name) }}"
200+
load_demo_data: "{{ __dw_config.load_demo_data | default(False) | bool }}"
201+
use_default_dbc: "{{ use_default_dbc }}"
202+
virtual_warehouses: "{{ __dw_config.virtual_warehouses | default([]) }}"
203+
loop: "{{ run__dw_definitions }}"
204+
loop_control:
205+
loop_var: __dw_config
206+
index_var: __dw_config_index
207+
208+
- name: Construct CDP DW Virtual warehouse configurations
209+
ansible.builtin.set_fact:
210+
run__dw_vw_configs: "{{ run__dw_vw_configs | default([]) | union([config]) }}"
211+
vars:
212+
dbc_name: "{{ item.0.name }}"
213+
use_default_dbc: "{{ item.0.use_default_dbc }}"
214+
config:
215+
name: "{{ item.1.name | default([dbc_name, run__dw_vw_suffix ,__dw_dbc_index] | join('-')) }}"
216+
dbc_name: "{{ dbc_name }}"
217+
use_default_dbc: "{{ use_default_dbc }}"
218+
vw_type: "{{ item.1.vw_type | default('hive') }}"
219+
template: "{{ item.1.template | default('xsmall') }}"
220+
autoscaling_min_cluster: "{{ item.1.autoscaling.min_cluster | default(None) }}"
221+
autoscaling_max_cluster: "{{ item.1.autoscaling.max_cluster | default(None) }}"
222+
common_configs: "{{ item.1.configs.common_configs | default({}) }}"
223+
application_configs: "{{ item.1.configs.application_configs | default({}) }}"
224+
ldap_groups: "{{ item.1.configs.ldap_groups | default(None) }}"
225+
enable_sso: "{{ item.1.configs.enable_sso | default(None) }}"
226+
tags: "{{ item.1.tags | default({}) | combine(run__dw_tags) }}"
227+
loop: "{{ run__dw_dbc_configs | subelements('virtual_warehouses')}}"
228+
loop_control:
229+
index_var: __dw_dbc_index

roles/runtime/tasks/initialize_setup_aws.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@
4949
label: "{{ __aws_private_subnet_item.subnet_id }}"
5050
loop: "{{ __aws_private_subnets_info.subnets }}"
5151

52+
- name: Assign AWS Private Subnet IDs in not assinged
53+
when: run__datahub_private_subnet_ids is undefined
54+
ansible.builtin.set_fact:
55+
run__datahub_private_subnet_ids: "{{ [] }}"
56+
5257
- name: Set fact for AWS Subnet IDs
5358
when: __aws_public_subnets_info is defined or __aws_private_subnets_info is defined
5459
ansible.builtin.set_fact:
55-
run__datahub_subnet_ids: "{{ run__datahub_public_subnet_ids | default([]) | union(run__datahub_private_subnet_ids) }}"
60+
run__datahub_subnet_ids: "{{ run__datahub_private_subnet_ids | default([]) | union(run__datahub_public_subnet_ids) }}"
5661

5762
- name: Set fact for AWS Subnet IDs by assignment
5863
when: infra__aws_subnet_ids is defined

roles/runtime/tasks/setup_aws.yml

Lines changed: 93 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,104 @@
3737
- name: Setup CDP DW cluster on AWS
3838
when: run__include_dw
3939
block:
40-
- name: Execute CDP DW cluster setup
41-
cloudera.cloud.dw_cluster:
40+
# - name: Execute CDP DW cluster setup
41+
# cloudera.cloud.dw_cluster:
42+
# env: "{{ run__env_name }}"
43+
# overlay: "{{ run__dw_overlay_network }}"
44+
# aws_public_subnets: "{{ run__datahub_public_subnet_ids }}"
45+
# aws_private_subnets: "{{ run__datahub_private_subnet_ids }}"
46+
# state: present
47+
# wait: yes
48+
# async: 3600 # 1 hour timeout
49+
# poll: 0
50+
# register: __dw_builds
51+
#
52+
# - name: Wait for CDP DW cluster setup to complete
53+
# ansible.builtin.async_status:
54+
# jid: "{{ __dw_builds.ansible_job_id }}"
55+
# #loop_control:
56+
# # loop_var: __opdb_build
57+
# # label: "{{ __opdb_build.__opdb_config.name }}"
58+
# #loop: "{{ __opdb_builds.results }}"
59+
# register: __dw_builds_async
60+
# until: __dw_builds_async.finished
61+
# retries: 120
62+
# delay: 30
63+
64+
- name: Retrieve CDP DW experiences
65+
cloudera.cloud.dw_cluster_info:
4266
env: "{{ run__env_name }}"
43-
overlay: no
44-
# TODO - Allow direct assignment (will need to coordinate with infra role)
45-
aws_public_subnets: "{{ run__datahub_public_subnet_ids }}"
46-
aws_private_subnets: "{{ run__datahub_private_subnet_ids }}"
67+
register: run__dw_list
68+
69+
- name: Create CDP DW Database catalogs
70+
when: not __dw_dbc_config.use_default_dbc
71+
cloudera.cloud.dw_dbc:
72+
cluster_id : "{{ run__dw_list.clusters[0].id }}"
73+
name: "{{ __dw_dbc_config.name }}"
74+
load_demo_data: "{{ __dw_dbc_config.load_demo_data }}"
4775
state: present
4876
wait: yes
4977
async: 3600 # 1 hour timeout
5078
poll: 0
51-
register: __dw_builds
79+
loop: "{{ run__dw_dbc_configs }}"
80+
loop_control:
81+
loop_var: __dw_dbc_config
82+
register: __dw_dbc_builds
5283

53-
- name: Wait for CDP DW cluster setup to complete
84+
- name: Wait for CDP DW Database catalogs setup to complete
85+
when: __dw_dbc_build.ansible_job_id is defined
5486
ansible.builtin.async_status:
55-
jid: "{{ __dw_builds.ansible_job_id }}"
56-
#loop_control:
57-
# loop_var: __opdb_build
58-
# label: "{{ __opdb_build.__opdb_config.name }}"
59-
#loop: "{{ __opdb_builds.results }}"
60-
register: __dw_builds_async
61-
until: __dw_builds_async.finished
87+
jid: "{{ __dw_dbc_build.ansible_job_id }}"
88+
register: __dw_dbc_builds_async
89+
until: __dw_dbc_builds_async.finished
6290
retries: 120
63-
delay: 30
91+
delay: 30
92+
loop: "{{ __dw_dbc_builds.results }}"
93+
loop_control:
94+
loop_var: __dw_dbc_build
95+
96+
- name: Set CDP DW Database catalog name to id map
97+
when: __dw_dbc_build_async.dbcs is defined
98+
ansible.builtin.set_fact:
99+
run__dw_dbc_ids: "{{ run__dw_dbc_ids | default({}) | combine({ __dw_dbc_build_async.dbcs[0].name : __dw_dbc_build_async.dbcs[0].id}) }}"
100+
loop: "{{ __dw_dbc_builds_async.results }}"
101+
loop_control:
102+
loop_var: __dw_dbc_build_async
103+
104+
- name: Create CDP DW Virtual warehouse
105+
cloudera.cloud.dw_vw:
106+
cluster_id: "{{ run__dw_list.clusters[0].id }}"
107+
dbc_id: "{{ run__dw_dbc_ids[__dw_vw_config.dbc_name] if not __dw_vw_config.use_default_dbc else run__dw_list.clusters[0].dbcs[0].id}}"
108+
vw_type: "{{ __dw_vw_config.vw_type }}"
109+
name: "{{ __dw_vw_config.name }}"
110+
template: "{{ __dw_vw_config.template }}"
111+
autoscaling_min_cluster: "{{ __dw_vw_config.autoscaling_min_cluster | int }}"
112+
autoscaling_max_cluster: "{{ __dw_vw_config.autoscaling_max_cluster | int }}"
113+
common_configs: "{{ __dw_vw_config.common_configs }}"
114+
application_configs: "{{ __dw_vw_config.application_configs }}"
115+
ldap_groups: "{{ __dw_vw_config.ldap_groups }}"
116+
enable_sso: "{{ __dw_vw_config.enable_sso | bool }}"
117+
tags: "{{ __dw_vw_config.tags }}"
118+
wait: yes
119+
async: 3600 # 1 hour timeout
120+
poll: 0
121+
register: __dw_vw_builds
122+
loop: "{{ run__dw_vw_configs }}"
123+
loop_control:
124+
loop_var: __dw_vw_config
125+
126+
- name: Wait for CDP DW Virtual warehouse setup to complete
127+
when: __dw_vw_build.ansible_job_id is defined
128+
ansible.builtin.async_status:
129+
jid: "{{ __dw_vw_build.ansible_job_id }}"
130+
register: __dw_vw_builds_async
131+
until: __dw_vw_builds_async.finished
132+
retries: 120
133+
delay: 30
134+
loop: "{{ __dw_vw_builds.results }}"
135+
loop_control:
136+
loop_var: __dw_vw_build
137+
138+
- name: Print Virtual Warehouses
139+
ansible.builtin.debug:
140+
msg: "Database Cluster : {{ __dw_vw_builds_async }}"

0 commit comments

Comments
 (0)