From d0d0b1cbfb2ae7eb89a677bcfc03902d72f73ace Mon Sep 17 00:00:00 2001 From: Anis FATHALLAH Date: Thu, 2 Nov 2023 09:20:44 +0400 Subject: [PATCH] add support for custom config groups in cluster update Signed-off-by: Anis FATHALLAH --- .../services/roleConfigGroupConfig_custom.j2 | 2 ++ .../cluster/templates/services/service.j2 | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 roles/deployment/cluster/templates/services/roleConfigGroupConfig_custom.j2 diff --git a/roles/deployment/cluster/templates/services/roleConfigGroupConfig_custom.j2 b/roles/deployment/cluster/templates/services/roleConfigGroupConfig_custom.j2 new file mode 100644 index 00000000..bab52157 --- /dev/null +++ b/roles/deployment/cluster/templates/services/roleConfigGroupConfig_custom.j2 @@ -0,0 +1,2 @@ +{% import 'cm_api.j2' as cm_api with context %} +{{ cm_api.ApiConfigList(merged_configs[service][custom_role]) }} \ No newline at end of file diff --git a/roles/deployment/cluster/templates/services/service.j2 b/roles/deployment/cluster/templates/services/service.j2 index 700b1222..98fd14b9 100644 --- a/roles/deployment/cluster/templates/services/service.j2 +++ b/roles/deployment/cluster/templates/services/service.j2 @@ -32,6 +32,21 @@ {%- endfor -%} {%- endfor -%} + {%- for custom_role in cluster.host_templates | cloudera.cluster.extract_custom_roles(service) -%} + {%- set (role_type, config_group) = custom_role | cloudera.cluster.extract_role_and_group -%} + {%- for host in (groups[service_ref + '_' + role_type | lower + '/' + config_group | lower] | default([])) -%} + {{ role_joiner() }} + { + "type" : "{{ role_type }}", + "hostRef" : { + "hostId" : "{{ cloudera_manager_api_hosts[host]['id'] }}" + }, + "roleConfigGroupRef" : { + "roleConfigGroupName" : "{{ service_ref }}-{{ role_type }}-{{ config_group }}" + } + } + {%- endfor -%} + {%- endfor -%} {%- endif -%} ], "roleConfigGroups": [ @@ -47,6 +62,17 @@ "base": true } {%- endfor -%} + {%- for custom_role in cluster.host_templates | cloudera.cluster.extract_custom_roles(service) -%} + {%- set (role_type, config_group) = custom_role | cloudera.cluster.extract_role_and_group -%} + {{ role_group_sep() }} + { + "name": "{{ service_ref }}-{{ role_type }}-{{ config_group }}", + "roleType": "{{ role_type }}", + {% set config_sep = joiner(",") -%} + "config": {%- include 'services/roleConfigGroupConfig_custom.j2' -%}, + "base": false + } + {%- endfor -%} {%- endif -%} ] }