Skip to content

Commit

Permalink
Allow selection of cluster deployed from cluster.yml (#151)
Browse files Browse the repository at this point in the history
Allows finer-grain control on exactly which type cluster to deploy from a cluster.yml file. The default/legacy behavior remains; all clusters are created as found in a cluster.yml file.

To invoke, provide the extra variable "deploy_only", e.g. "-e deploy_only=<value>", at the in command line or in a configuration.

Current accepted values:
- base
- encryption  (a KTS cluster)
- compute
- ecs

Thanks npopa@cloudera.com

Signed-off-by: Chuck Levesque <clevesque@cloudera.com>
  • Loading branch information
clevesque authored Nov 13, 2023
1 parent d25a610 commit 905661c
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions roles/deployment/cluster/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
# Copyright 2023 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,16 @@
name: cloudera.cluster.config.cluster.common
public: yes

## Nico
- name: Apply "all hosts" configs
include_role:
name: cloudera.cluster.cloudera_manager.config
vars:
api_config_keys_uppercase: False
api_config_endpoint: cm/allHosts/config
api_configs: "{{ definition.hosts.configs }}"
when: definition.hosts.configs is defined

- name: Detect Cloudera Manager version
cloudera.cluster.cm_api:
endpoint: /cm/version
Expand All @@ -35,6 +45,7 @@
existing_clusters: "{{ clusters_response.json | json_query('items[*].name') }}"

# If you get failures here check in CM to ensure you don't have empty clusters or other oddities
# Add deploy_only="base" to select base from several clusters in clusters.yml
- name: Create base clusters
include_tasks: create_base.yml
loop: "{{ definition.clusters }}"
Expand All @@ -45,7 +56,9 @@
when:
- cluster.type | default(default_cluster_type) == 'base'
- cluster.name not in existing_clusters

- (deploy_only is defined and 'base' in deploy_only) or deploy_only is not defined

# Add deploy_only="base" to select base from several clusters in clusters.yml
- name: Update base clusters
include_tasks: update_base.yml
loop: "{{ definition.clusters }}"
Expand All @@ -57,7 +70,9 @@
- cluster.type | default(default_cluster_type) == 'base'
- cluster.name in existing_clusters
- (cdh_cdp_upgrade|default(false)|bool) or (update_services|default(false)|bool) or (upgrade_runtime|default(false)|bool)
- (deploy_only is defined and 'base' in deploy_only) or deploy_only is not defined

# Add deploy_only="base" to select base from several clusters in clusters.yml
- name: Create base cluster data contexts (SDX)
include_tasks: create_data_context.yml
loop: "{{ definition.clusters }}"
Expand All @@ -68,7 +83,9 @@
when:
- cluster.type | default(default_cluster_type) == 'base'
- cloudera_manager_version is version('6.2.0','>=')
- (deploy_only is defined and 'base' in deploy_only) or deploy_only is not defined

# Add deploy_only="encryption" to select kts from several clusters in clusters.yml
- name: Create Key Trustee server cluster
include_tasks: create_kts.yml
loop: "{{ definition.clusters }}"
Expand All @@ -80,7 +97,10 @@
- cluster.type | default(default_cluster_type) == 'kts'
- cluster.name not in existing_clusters
- '"kts_active" in groups'
- (deploy_only is defined and 'encryption' in deploy_only) or deploy_only is not defined


# Add deploy_only="encryption" to select kts from several clusters in clusters.yml
- name: Upgrade Key Trustee server cluster
include_tasks: upgrade_kts.yml
loop: "{{ definition.clusters }}"
Expand All @@ -93,7 +113,9 @@
- cluster.name in existing_clusters
- '"kts_active" in groups'
- upgrade_kts_cluster | default(false)

- (deploy_only is defined and 'encryption' in deploy_only) or deploy_only is not defined

# Add deploy_only="compute" to select compute clust from several clusters in clusters.yml
- name: Create compute clusters
include_tasks: create_base.yml
loop: "{{ definition.clusters }}"
Expand All @@ -104,8 +126,10 @@
when:
- cluster.type | default(default_cluster_type) == 'compute'
- cluster.name not in existing_clusters
- (deploy_only is defined and 'compute' in deploy_only) or deploy_only is not defined

# This process is not idempotent, as the whole ECS setup process must succeed or it will skip on subsequent runs
# Add deploy_only="ecs" to select ecs from several clusters in clusters.yml
- name: Create ECS clusters
include_tasks: create_ecs.yml
loop: "{{ definition.clusters }}"
Expand All @@ -116,8 +140,9 @@
when:
- cluster.type | default(default_cluster_type) == 'ecs'
- cluster.name not in existing_clusters
- (deploy_only is defined and 'ecs' in deploy_only) or deploy_only is not defined

- name: Restart Cloudera Management Service
cloudera.cluster.cm_api:
endpoint: /cm/service/commands/restart
method: POST
method: POST

0 comments on commit 905661c

Please sign in to comment.