Post-Creation Scripts

Post-creation scripts are run after a Cloudera Manager cluster has been created. The scripts are run sequentially on a randomly selected cluster host. The scripts can be written in any scripting language that can be interpreted on the system where it runs.

Configuring the Scripts

Post-creation scripts are available only through the client configuration file or the Cloudera Director API.

You can supply post-creation scripts in the client configuration file in two ways:
  • Use the postCreateScripts directive inside of the cluster {} configuration block. This block can take an array of scripts, similar to the bootstrapScript that can be placed inside the instance {} configuration block.
  • Use the postCreateScriptsPaths directive inside of the cluster {} configuration block. It can take an array of paths to arbitrary files on the local filesystem. This is similar to the bootstrapScriptPath directive. Cloudera Director reads the files from the filesystem and uses their contents as post-creation scripts.

Unlike bootstrapScript and bootstrapScriptPath, both post-creation scripting methods can be used simultaneously. For example, postCreateScripts can be used for setup (package installation, light system configuration), and postCreateScriptsPaths can be used to refer to more complex scripts that may depend on the configuration that was performed in postCreateScripts. Everything in the postCreateScripts block is run first, sequentially, and then everything in postCreateScriptsPaths is run sequentially.

cluster {
   .... 
   postCreateScripts: [#!/usr/bin/python]
   print 'Hello World Again!'

   #!/bin/bash
   echo 'Hello World!',

   postCreateScriptsPaths: ["/tmp/script1.py", "/tmp/script2.sh"]

Predefined Environment Variables

Post-creation scripts have access to several environment variables defined by Cloudera Director. Use these variables in your scripts to communicate with Cloudera Manager and configure it after Cloudera Director has completed its tasks.

Variable Name Example Description
DEPLOYMENT_HOST_PORT 192.168.1.100:7180 The host and port used to connect to the Cloudera Manager deployment that this cluster belongs to.
ENVIRONMENT_NAME Cloudera Director Environment The name of the environment that this cluster belongs to.
DEPLOYMENT_NAME Cloudera Director Deployment The name of the Cloudera Manager deployment that this cluster belongs to.
CLUSTER_NAME Cloudera Director Cluster The name of the cluster. The Cloudera Manager API needs this to specify which cluster on a Cloudera Manager server to operate on.
CM_USERNAME admin The username needed to connect to the Cloudera Manager deployment.
CM_PASSWORD admin The password needed to connect to the Cloudera Manager deployment.