Shell Based Bootstrap Helper Functions

Shell script based bootstrap helper functions exist to update Ambari configurations.

Note

The custom bootstrap script is run as an opc user. To run a command that needs root access, add sudo.

The following event types are supported for the bootstrap script. For usage example, see Shell Script Examples.

  • CreateBdsInstance
  • on-demand
  • AddWorkerNodes
  • ChangeShape
  • StartBdsInstance

To run a bootstrap script, see Running the Bootstrap Script.

For more information on shell script bootstrap helper functions, see:

Bootstrap Shell Script Helper Functions

For more information on shell bootstrap script, see Shell Based Bootstrap Helper Functions.

For shell script helper function examples, see Shell Script Examples.

To run a bootstrap script, see Running the Bootstrap Script.

Helper Function Functionality
$getClusterName Displays the cluster name.
$getAllNodesIps Displays a space-separated list of IPs of all the nodes.
$getUtilityNodesIps Displays a space-separated list of IPs of the utility nodes.
$getWorkerNodesIps Displays a space-separated list of IPs of the worker nodes.
$getMasterNodesIps Displays a space-separated list of IPs of the master nodes.
$getQueryServerNodesIps Displays a space-separated list of IPs of the query server nodes.
$eventType Displays the event type that initiated the bootstrap script.

Shell Script Examples

For more information on the shell script helper functions, see Bootstrap Shell Script Helper Functions.

Example: Custom bootstrap script with helper functions to find the node types
#!/bin/bash
                    
                    #Helper Method Sample
                    
                    #Use Following Helper function to get list of IPs of all nodes and you can use this to run a command for all nodes
                    for node in $getAllNodesIps
                    do
                    # setup common things for all nodes
                    echo "Node name: $node"
                    done
                    
                    #Cluster Name
                    
                    echo "Cluster Name"+$getClusterName
                    
                    #Master Nodes 
                    for node in $getMasterNodesIps
                    do
                    # setup common things for master nodes
                    echo "Master Node name: $node"
                    done
                    
                    
                    #Worker Nodes 
                    for node in $getWorkerNodesIps
                    do
                    # setup common things for worker nodes
                    echo "Worker Node name: $node"
                    done
                    
                    #Utility Nodes
                    
                    for node in $getUtilityNodesIps
                    do
                    # setup common things for Utility nodes
                    echo "Utility Node name: $node"
                    done
                    
                    #QueryServer Nodes
                    for node in $getQueryServerNodesIps
                    do
                    # setup common things for Query Server nodes
                    echo "QueryServer Node name : $node"
                    done
                    
                    
                    
                    echo "bootstrap script execution complete!!!"
Example: Custom bootstrap script for a cluster life cycle
To run a custom bootstrap script for a cluster life cycle operation such as create cluster, add node, or change shape, use the $eventType helper variable as shown in the following example:
#!/bin/bash
                #Take action on certain Event Types
                
                echo "Customer Bootstrap Script Execution for EventType :$eventType"
                
                if [ $eventType == "CreateBdsInstance" ]
                then
                echo "setup things post Cluster Creation"
                fi
                
                if [ $eventType == "AddWorkerNodes" ]
                then
                echo "setup things post ADD Node "
                fi
                
                if [ $eventType == "ChangeShape" ]
                then
                echo "setup things post Change Shape"
                fi
                
                if [ $eventType == "on-demand" ]
                then
                echo "on demand script execution"
                fi
                
                if [ $eventType == "StartBdsInstance" ]
                then
                echo "set up things post Start operation"
                fi