Post-creation Scripts

Post-creation scripts allow users to supply one or more scripts to be run after a Cloudera Manager cluster has been created. The supplied scripts are executed sequentially on a randomly selected cluster host. Scripts are not limited to Bash scripts, but 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 command-line interface (CLI). There are two ways to supply post-creation scripts in the client configuration file:
  • Use the postCreateScripts directive inside of the cluster {} configuration block. This block can take an array of scripts, and they can be entered directly into the configuration file, similar to the bootstrapScript that can be placed inside the instance {} configuration block.
  • Use the postCreateScriptsPaths directive, also inside of the cluster {} configuration block. It can take an array of paths to arbitrary files on the local file system. This is similar to the bootstrapScriptPath directive. Cloudera Director will read the files from the file system and use these files' contents in their entirety as post-creation scripts.

Unlike bootstrapScript and bootstrapScriptPath, both ways can be used simultaneously. For example, the postCreateScripts directive can be used for setup (package installation, light system configuration), and the postCreateScriptsPaths directive can be used to refer to more complex scripts that may depend on the configuration that was performed in the postCreateScripts directive. Everything in the postCreateScripts block is executed sequentially first, and then everything in postCreateScriptsPaths is executed 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 will need this in order 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.