diff --git a/docs/configuration.yml b/docs/configuration.yml index 264a848d..ba824f30 100644 --- a/docs/configuration.yml +++ b/docs/configuration.yml @@ -25,7 +25,33 @@ df: persist: dw: definitions: + - name: + use_default_dbc: + load_demo_data: + virtual_warehouses: + - name: + type: + template: + autoscaling: + min_nodes: + max_nodes: + tags: + configs: + common_configs: + application_configs: + enable_sso: + ldap_groups: suffix: + vw: + suffix: + tags: + overlay_network: + private_load_balancer: + private_worker_nodes: + force_delete: + default_vw_type: + default_template_type: + default_dbc_suffix: env: aws: policy: diff --git a/roles/runtime/defaults/main.yml b/roles/runtime/defaults/main.yml index 8cce89e2..bbe40419 100644 --- a/roles/runtime/defaults/main.yml +++ b/roles/runtime/defaults/main.yml @@ -65,8 +65,16 @@ run__ml_remove_storage: "{{ ml.remove_storage | default (run__force_ run__ml_public_loadbalancer: "{{ ml.public_loadbalancer | default(run__public_endpoint_access) }}" run__dw_definitions: "{{ dw.definitions | default([{}]) }}" -run__dw_suffix: "{{ dw.suffix | default('dw') }}" +run__dw_dbc_suffix: "{{ dw.dbc.suffix | default('dbc') }}" +run__dw_vw_suffix: "{{ dw.vw.suffix | default('vw') }}" +run__dw_tags: "{{ dw.tags | default(common__tags) }}" +run__dw_overlay_network: "{{ dw.overlay_network | default(False) | bool }}" +run__dw_private_load_balancer: "{{ dw.private_load_balancer | default(not run__public_endpoint_access) }}" +run__dw_private_worker_nodes: "{{ dw.private_worker_nodes | default(False) | bool }}" run__dw_force_delete: "{{ dw.force_delete | default (run__force_teardown) }}" +run__dw_default_vw_type: "{{ dw.default_vw_type | default('hive') }}" +run__dw_default_template_type: "{{ dw.default_template_type | default('xsmall') }}" +run__dw_default_dbc_suffix: "{{ dw.default_dbc_suffix | default('-dl-default') }}" run__df_nodes_min: "{{ df.min_k8s_nodes | default(3) }}" run__df_nodes_max: "{{ df.max_k8s_nodes | default(5) }}" diff --git a/roles/runtime/tasks/initialize_base.yml b/roles/runtime/tasks/initialize_base.yml index e0bc0ade..e17ee5f2 100644 --- a/roles/runtime/tasks/initialize_base.yml +++ b/roles/runtime/tasks/initialize_base.yml @@ -161,3 +161,40 @@ loop_control: loop_var: __ml_config label: "{{ config.name }}" + +- name: Prepare for CDP DW experiences + when: run__include_dw + block: + - name: Construct CDP DW Data catalog configurations + ansible.builtin.set_fact: + run__dw_dbc_configs: "{{ run__dw_dbc_configs | default([]) | union([config]) }}" + vars: + include: "{{ lookup('template', __dw_config.include | default('experiences_config_placeholder.j2')) | from_yaml }}" + config: + name: "{{ __dw_config.name | default('') }}" + load_demo_data: "{{ __dw_config.load_demo_data | default(False) | bool }}" + use_default_dbc: "{{ __dw_config.name is undefined | bool }}" + virtual_warehouses: "{{ __dw_config.virtual_warehouses | default([]) }}" + loop: "{{ run__dw_definitions }}" + loop_control: + loop_var: __dw_config + index_var: __dw_config_index + + - name: Construct CDP DW Virtual warehouse configurations + ansible.builtin.set_fact: + run__dw_vw_configs: "{{ run__dw_vw_configs | default([]) | union([config]) }}" + vars: + config: + name: "{{ __dw_config.1.name | default([run__namespace, run__dw_vw_suffix ,__dw_dbc_index] | join('-')) }}" + dbc_name: "{{ __dw_config.0.name }}" + use_default_dbc: "{{ __dw_config.0.use_default_dbc }}" + type: "{{ __dw_config.1.type | default(run__dw_default_vw_type) }}" + template: "{{ __dw_config.1.template | default(run__dw_default_template_type) }}" + tags: "{{ __dw_config.1.tags | default({}) | combine(run__dw_tags) }}" + autoscaling: "{{ __dw_config.1.autoscaling | default({}) }}" + configs: "{{ __dw_config.1.configs | default({}) }}" + loop: "{{ run__dw_dbc_configs | subelements('virtual_warehouses')}}" + loop_control: + loop_var: __dw_config + index_var: __dw_dbc_index + label: "{{ __dw_config.0.name }}" \ No newline at end of file diff --git a/roles/runtime/tasks/initialize_setup_aws.yml b/roles/runtime/tasks/initialize_setup_aws.yml index 69d417a2..d5519c8a 100644 --- a/roles/runtime/tasks/initialize_setup_aws.yml +++ b/roles/runtime/tasks/initialize_setup_aws.yml @@ -15,7 +15,7 @@ # limitations under the License. - name: Discover AWS Public and Private VPC Subnets - when: not infra__aws_subnet_ids + when: infra__aws_subnet_ids is undefined block: - name: Query AWS Public Subnets amazon.aws.ec2_vpc_subnet_info: @@ -49,13 +49,17 @@ label: "{{ __aws_private_subnet_item.subnet_id }}" loop: "{{ __aws_private_subnets_info.subnets }}" + - name: Set default AWS Private Subnet if there are no Private Subnets + ansible.builtin.set_fact: + run__datahub_private_subnet_ids: "{{ run__datahub_private_subnet_ids | default([]) }}" + - name: Set fact for AWS Subnet IDs when: __aws_public_subnets_info is defined or __aws_private_subnets_info is defined ansible.builtin.set_fact: - run__datahub_subnet_ids: "{{ run__datahub_public_subnet_ids | default([]) | union(run__datahub_private_subnet_ids) }}" + run__datahub_subnet_ids: "{{ run__datahub_private_subnet_ids | union(run__datahub_public_subnet_ids) }}" - name: Set fact for AWS Subnet IDs by assignment - when: infra__aws_subnet_ids + when: infra__aws_subnet_ids is defined block: - name: Set fact for All AWS Subnet IDs by assignment ansible.builtin.set_fact: diff --git a/roles/runtime/tasks/setup_aws.yml b/roles/runtime/tasks/setup_aws.yml index 2c2132d4..cebf967b 100644 --- a/roles/runtime/tasks/setup_aws.yml +++ b/roles/runtime/tasks/setup_aws.yml @@ -40,10 +40,10 @@ - name: Execute CDP DW cluster setup cloudera.cloud.dw_cluster: env: "{{ run__env_name }}" - overlay: no - # TODO - Allow direct assignment (will need to coordinate with infra role) + overlay: "{{ run__dw_overlay_network }}" + private_load_balancer: "{{ run__dw_private_load_balancer }}" aws_public_subnets: "{{ run__datahub_public_subnet_ids }}" - aws_private_subnets: "{{ run__datahub_private_subnet_ids }}" + aws_private_subnets: "{{ run__datahub_private_subnet_ids if run__dw_private_worker_nodes else [] }}" state: present wait: yes async: 3600 # 1 hour timeout @@ -51,13 +51,101 @@ register: __dw_builds - name: Wait for CDP DW cluster setup to complete + when: false ansible.builtin.async_status: jid: "{{ __dw_builds.ansible_job_id }}" - #loop_control: - # loop_var: __opdb_build - # label: "{{ __opdb_build.__opdb_config.name }}" - #loop: "{{ __opdb_builds.results }}" register: __dw_builds_async until: __dw_builds_async.finished retries: 120 - delay: 30 \ No newline at end of file + delay: 30 + + - name: Retrieve CDP DW experiences + cloudera.cloud.dw_cluster_info: + env: "{{ run__env_name }}" + register: run__dw_list + + - name: Fetch all the Database Catalogs under the cluster + cloudera.cloud.dw_database_catalog_info: + cluster_id: "{{ run__dw_list.clusters[0].id }}" + register: __dbc_list + + - name: Set default Database catalog id for the cluster + when: __dw_dbc.name | regex_search('.*'+run__dw_default_dbc_suffix+'$') + ansible.builtin.set_fact: + __default_dbc_id: "{{ __dw_dbc.id }}" + loop: "{{ __dbc_list.database_catalogs }}" + loop_control: + loop_var: __dw_dbc + + - name: Create CDP DW Database catalogs + when: not __dw_dbc_config.use_default_dbc + cloudera.cloud.dw_database_catalog: + cluster_id : "{{ run__dw_list.clusters[0].id }}" + name: "{{ __dw_dbc_config.name }}" + load_demo_data: "{{ __dw_dbc_config.load_demo_data }}" + state: present + wait: yes + async: 3600 # 1 hour timeout + poll: 0 + loop: "{{ run__dw_dbc_configs }}" + loop_control: + loop_var: __dw_dbc_config + label: "{{ __dw_dbc_config.name }}" + register: __dw_dbc_builds + + - name: Wait for CDP DW Database catalogs setup to complete + when: __dw_dbc_build.ansible_job_id is defined + ansible.builtin.async_status: + jid: "{{ __dw_dbc_build.ansible_job_id }}" + register: __dw_dbc_builds_async + until: __dw_dbc_builds_async.finished + retries: 120 + delay: 30 + loop: "{{ __dw_dbc_builds.results }}" + loop_control: + loop_var: __dw_dbc_build + label: "{{ __dw_dbc_build.__dw_dbc_config.name }}" + + - name: Set CDP DW Database catalog name to id map + when: __dw_dbc_build_async.database_catalog is defined + ansible.builtin.set_fact: + run__dw_dbc_ids: "{{ run__dw_dbc_ids | default({}) | combine({ __dw_dbc_build_async.database_catalog.name : __dw_dbc_build_async.database_catalog.id}) }}" + loop: "{{ __dw_dbc_builds_async.results }}" + loop_control: + loop_var: __dw_dbc_build_async + + - name: Create CDP DW Virtual warehouse + cloudera.cloud.dw_virtual_warehouse: + cluster_id: "{{ run__dw_list.clusters[0].id }}" + dbc_id: "{{ __dw_vw_config.use_default_dbc | ternary(__default_dbc_id, run__dw_dbc_ids[__dw_vw_config.dbc_name]) }}" + type: "{{ __dw_vw_config.type }}" + name: "{{ __dw_vw_config.name }}" + template: "{{ __dw_vw_config.template }}" + tags: "{{ __dw_vw_config.tags }}" + autoscaling_min_nodes: "{{ __dw_vw_config.autoscaling.min_nodes | default(omit) }}" + autoscaling_max_nodes: "{{ __dw_vw_config.autoscaling.max_nodes | default(omit) }}" + common_configs: "{{ __dw_vw_config.configs.common_configs | default(omit) }}" + application_configs: "{{ __dw_vw_config.configs.application_configs | default(omit) }}" + ldap_groups: "{{ __dw_vw_config.configs.ldap_groups | default(omit) }}" + enable_sso: "{{ __dw_vw_config.configs.enable_sso | default(omit) }}" + wait: yes + async: 3600 # 1 hour timeout + poll: 0 + register: __dw_vw_builds + loop: "{{ run__dw_vw_configs }}" + loop_control: + loop_var: __dw_vw_config + label: "{{ __dw_vw_config.name }}" + + - name: Wait for CDP DW Virtual warehouse setup to complete + when: __dw_vw_build.ansible_job_id is defined + ansible.builtin.async_status: + jid: "{{ __dw_vw_build.ansible_job_id }}" + register: __dw_vw_builds_async + until: __dw_vw_builds_async.finished + retries: 120 + delay: 30 + loop: "{{ __dw_vw_builds.results }}" + loop_control: + loop_var: __dw_vw_build + label: "{{ __dw_vw_build.__dw_vw_config.name }}" \ No newline at end of file