Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit e00260d

Browse files
committed
Added cluster name selection to Terraform schema rather than defined in script
1 parent 4aee396 commit e00260d

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

compute.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module "utility" {
4141
block_volume_count = "${var.block_volumes_per_worker}"
4242
AD = "${var.availability_domain}"
4343
deployment_type = "${var.deployment_type}"
44+
cluster_name = "${var.cluster_name}"
4445
}
4546

4647
module "master" {

modules/utility/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ resource "oci_core_instance" "Utility" {
2222
block_volume_count = "${var.block_volume_count}"
2323
availability_domain = "${var.AD}"
2424
deployment_type = "${var.deployment_type}"
25+
cluster_name = "${var.cluster_name}"
2526
}
2627

2728
extended_metadata {

modules/utility/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ variable "cloudera_manager" {}
2121
variable "cm_install" {}
2222
variable "deploy_on_oci" {}
2323
variable "deployment_type" {}
24+
variable "cluster_name" {}
2425

2526
# ---------------------------------------------------------------------------------------------------------------------
2627
# Optional variables

scripts/cms_mysql.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ availability_domain=`curl -L http://169.254.169.254/opc/v1/instance/metadata/ava
1414
worker_shape=`curl -L http://169.254.169.254/opc/v1/instance/metadata/worker_shape`
1515
worker_disk_count=`curl -L http://169.254.169.254/opc/v1/instance/metadata/block_volume_count`
1616
deployment_type=`curl -L http://169.254.169.254/opc/v1/instance/metadata/deployment_type`
17+
cluster_name=`curl -L http://169.254.169.254/opc/v1/instance/metadata/cluster_name`
1718
EXECNAME="TUNING"
1819
log "-> START"
1920
sed -i.bak 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
@@ -387,11 +388,6 @@ for w in `seq 1 $num_workers`; do
387388
done;
388389
log "-->Host List: ${fqdn_list}"
389390
log "-->Cluster Build"
390-
if [ ${deployment_type} = "simple" ]; then
391-
log "---> python /var/lib/cloud/instance/scripts/deploy_on_oci.py -S -m ${cm_ip} -i ${fqdn_list} -d ${worker_disk_count} -w ${worker_shape} -n ${num_workers} -cdh ${cdh_version} -ad ${availability_domain}"
392-
python /var/lib/cloud/instance/scripts/deploy_on_oci.py -S -m ${cm_ip} -i ${fqdn_list} -d ${worker_disk_count} -w ${worker_shape} -n ${num_workers} -cdh ${cdh_version} -ad ${availability_domain} 2>&1 1>> $LOG_FILE
393-
else
394-
log "---> python /var/lib/cloud/instance/scripts/deploy_on_oci.py -m ${cm_ip} -i ${fqdn_list} -d ${worker_disk_count} -w ${worker_shape} -n ${num_workers} -cdh ${cdh_version} -ad ${availability_domain}"
395-
python /var/lib/cloud/instance/scripts/deploy_on_oci.py -m ${cm_ip} -i ${fqdn_list} -d ${worker_disk_count} -w ${worker_shape} -n ${num_workers} -cdh ${cdh_version} -ad ${availability_domain} 2>&1 1>> $LOG_FILE
396-
fi
391+
log "---> python /var/lib/cloud/instance/scripts/deploy_on_oci.py -D ${deployment_type} -m ${cm_ip} -i ${fqdn_list} -d ${worker_disk_count} -w ${worker_shape} -n ${num_workers} -cdh ${cdh_version} -ad ${availability_domain} -N ${cluster_name}"
392+
python /var/lib/cloud/instance/scripts/deploy_on_oci.py -D ${deployment_type} -m ${cm_ip} -i ${fqdn_list} -d ${worker_disk_count} -w ${worker_shape} -n ${num_workers} -cdh ${cdh_version} -ad ${availability_domain} -N ${cluster_name} 2>&1 1>> $LOG_FILE
397393
log "->DONE"

scripts/deploy_on_oci.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
data_tiering = 'False'
3535
nvme_disks = 0
3636
cluster_version = '6.2.0' # type: str
37-
simple_deployment = 'False' # type: bool
37+
deployment_type = 'simple' # type: str
3838

3939
#
4040
# Custom Global Parameters - Customize below here
@@ -52,11 +52,11 @@
5252
cluster_name = 'TestCluster' # type: str
5353

5454
# Set this to 'True' (default) to enable secure cluster (Kerberos) functionality
55-
# Set this to 'False" to deploy an insecure cluster - This is automatically off for simple_deployment
55+
# Set this to 'False" to deploy an insecure cluster - This is automatically off for simple deployment
5656
secure_cluster = 'True' # type: bool
5757

5858
# Set this to 'False' if you do not want HDFS HA - useful for Development or if you want to save some setup time
59-
# This is automatically off for simple_deployment
59+
# This is automatically off for simple deployment
6060
hdfs_ha = 'True' # type: bool
6161

6262
# They should match what is in the Cloudera Manager CloudInit bootstrap file and instance boot files
@@ -2085,7 +2085,7 @@ def options_parser(args=None):
20852085
'OCI using cm_client with Cloudera '
20862086
'Manager API %s' % (cluster_version,
20872087
api_version))
2088-
parser.add_argument('-S', '--simple_deployment', action='store_true', help='Simple, no HA or Kerberos at deployment')
2088+
parser.add_argument('-D', '--deployment_type', metavar='deployment_type', help='simple, no HA or Kerberos at deployment, or secure to enable both')
20892089
parser.add_argument('-m', '--cm_server', metavar='cm_server', required='True',
20902090
help='Cloudera Manager IP to connect API using cm_client')
20912091
parser.add_argument('-i', '--input_host_list', metavar='input_host_list',
@@ -2099,6 +2099,7 @@ def options_parser(args=None):
20992099
parser.add_argument('-n', '--num_workers', metavar='num_workers', help='Number of Workers in Cluster')
21002100
parser.add_argument('-cdh', '--cdh_version', metavar='cdh_version', help='CDH version to deploy')
21012101
parser.add_argument('-ad', '--availability_domain', metavar='availability_domain', help='OCI Availability Domain')
2102+
parser.add_argument('-N', '--cluster_name', metavar='cluster_name', help='CDH Cluster Name')
21022103
options = parser.parse_args(args)
21032104
if not options.cm_server:
21042105
print('Cloudera Manager Server IP required.')
@@ -2117,6 +2118,10 @@ def options_parser(args=None):
21172118
print('OCI Availability Domain is required.')
21182119
parser.print_help()
21192120
exit(-1)
2121+
if options.cm_server and not options.cluster_name:
2122+
print('Cluster Name is required.')
2123+
parser.print_help()
2124+
exit(-1)
21202125

21212126
if options.license_file:
21222127
try:
@@ -2129,7 +2134,7 @@ def options_parser(args=None):
21292134
sys.exit()
21302135

21312136
return (options.cm_server, options.input_host_list, options.disk_count, options.license_file, options.worker_shape,
2132-
options.num_workers, options.simple_deployment, options.cdh_version, options.availability_domain)
2137+
options.num_workers, options.deployment_type, options.cdh_version, options.availability_domain, options.cluster_name)
21332138

21342139
#
21352140
# MAIN FUNCTION FOR CLUSTER DEPLOYMENT
@@ -2315,14 +2320,21 @@ def enable_kerberos():
23152320
#
23162321

23172322
if __name__ == '__main__':
2318-
cm_server, input_host_list, disk_count, license_file, worker_shape, num_workers, simple_deployment, cdh_version, cms_version =\
2323+
cm_server, input_host_list, disk_count, license_file, worker_shape, num_workers, deployment_type, cdh_version, cms_version, cluster_name =\
23192324
options_parser(sys.argv[1:])
23202325
if debug == 'True':
23212326
print('cm_server = %s' % cm_server)
23222327
print('input_host_list = %s' % input_host_list)
23232328
print('disk_count = %s' % disk_count)
23242329
print('license_file = %s' % license_file)
23252330
print('worker_shape = %s' % worker_shape)
2331+
print('cluster_name = %s' % cluster_name)
2332+
print('deployment_type = %s' % deployment_type)
2333+
if deployment_type == 'simple':
2334+
hdfs_ha = 'False'
2335+
secure_cluster = 'False'
2336+
else:
2337+
pass
23262338
user_name = 'admin'
23272339
password = 'admin'
23282340
print('->Building API Endpoints')
@@ -2348,14 +2360,14 @@ def enable_kerberos():
23482360
time.sleep(30)
23492361
wait_status = wait_status + '*'
23502362

2351-
if simple_deployment == 'True':
2363+
if deployment_type == 'simple':
23522364
print('Simple Deployment Selected')
23532365
print('Cluster Security and High Availabilty are DISABLED')
23542366
else:
23552367
print('Cluster Deployment options - HA: %s - Kerberos: %s' % (hdfs_ha, secure_cluster))
23562368

23572369
build_cloudera_cluster()
2358-
if simple_deployment == 'True':
2370+
if deployment_type == 'simple':
23592371
exit(0)
23602372
else:
23612373
if hdfs_ha == 'True':

variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ variable "availability_domain" {
7979
default = "1"
8080
}
8181

82+
variable "cluster_name" {
83+
default = "TestCluster"
84+
}
85+
8286
# ---------------------------------------------------------------------------------------------------------------------
8387
# Environmental variables
8488
# You probably want to define these as environmental variables.

0 commit comments

Comments
 (0)