All Products
Search
Document Center

Configure an installation script

Last Updated: Sep 13, 2021

If you need to install software or deploy a software environment after you create a cluster, you can configure an installation script. After all nodes in a cluster are started and all selected software is automatically installed, an installation script is automatically downloaded and executed. This topic describes how to set the parameters in an installation script.

Scenarios

  • After you create a cluster based on a public image, you need to install software or deploy a software environment.

  • After you create a cluster based on a custom image, you need to execute a custom script to deploy a software environment.

Background information

To configure an installation script, navigate to the Advanced Configurations section of the Software Configurations step on the Create Cluster page. The installation script must be written in a language supported by the Linux shell, such as Bash and Python. The first line of the script must be annotated to indicate the commands to be called at runtime. For example, the first line of the bash script is #!/bin/bash

    Example

    The following sample script outputs cluster environment variables, cluster metadata, and node roles to the log files in the /root directory. To download an installation script, click the sample installation script.

    #!/bin/bash
    
    echo "call $0 with param: $@" | tee /root/command.log
    
    
    ## show all availble environment variables
    printenv | tee /root/env.log
    
    ## Cluster meta data
    echo "ClusterId: ${ClusterId}, HOSTNAME: ${HOSTNAME}" | tee /root/cluster.log
    echo "AccountType: ${AccountType}, SchedulerType: ${SchedulerType}" | tee -a /root/cluster.log
    
    ## Role of current machine
    echo "${Role}" | tee /root/role.log
    
    if [ "${isLoginNode}" == "true" ]; then
      ## Do your work on login node
      echo "This is login node" | tee -a /root/role.log
      exit $?
    fi
    
    if [ "${isAccountManager}" == "true" ]; then
      ## Do your work on NIS/LDAP master
      echo "This is account manager" | tee -a /root/role.log
      exit $?
    fi
    
    if [ "${isResourceManager}" == "true" ]; then
      ## Do your work on Slurm/PBS master
      echo "This is scheduler" | tee -a /root/role.log
      exit $?
    fi
    
    if [ "${isComputeNode}" == "true" ]; then
      ## Do your work with on compute node
      echo "This is compute node" | tee -a /root/role.log
      exit $?
    fi

    Environment variables

    By default, an installation script is executed on all nodes of a cluster. You can specify the operations to be performed on different types of nodes by setting environment variables. The following table describes the available environment variables.

    Variable

    Example

    Description

    ClusterId

    ehpc-hz-AQoy7J****

    The ID of the cluster.

    HOSTNAME

    i-bp133vs16yb3kqdj****

    The name of the host.

    AccountType

    NIS

    The type of the domain account. Valid values:

    • NIS

    • LDAP

    SchedulerType

    PBS

    The type of the scheduler. Valid values:

    • PBS

    • SLURM

    • GRIDENGINE

    Role

    AccountManager

    The Role variable can contain a single role name. The Role variable can also contain multiple role names separated by commas (,) to indicate that a single node has multiple roles. Valid values:

    • AccountManager: the management node of a primary domain account

    • AccountManagerBackup: the management node of a secondary domain account

    • ResourceManager: the primary scheduling node

    • ResourceManagerBackup: the secondary scheduling node

    • Compute: the compute node

    • LoginNode: the logon node

    ResourceManagerIp

    192.168.**.**

    The private IP address of the primary scheduling node.

    ResourceManagerHost

    scheduler000

    The hostname of the primary scheduling node.

    AccountManagerIp

    192.168.**.**

    The private IP address of the management node of the primary domain account.

    AccountManagerHost

    account000

    The hostname of the management node of the primary domain account.

    ResourceManagerBackupIp

    192.168.**.**

    The private IP address of the secondary scheduling node (High availability enabled).

    ResourceManagerBackupHost

    scheduler001

    The hostname of the secondary scheduling node (High availability enabled).

    AccountManagerBackupIp

    192.168.**.**

    The private IP address of the management node of the secondary domain account (High availability enabled).

    AccountManagerBackupHost

    account001

    The hostname of the management node of the secondary domain account (High availability enabled).

    isLoginNode

    true

    Specifies whether the node is a logon node. Valid values:

    • true

    • false

    isAccountManager

    true

    Specifies whether the server is a primary domain server. Valid values:

    • true

    • false

    isResourceManager

    true

    Specifies whether the scheduler is a primary scheduler. Valid values:

    • true

    • false

    isAccountManagerBackup

    true

    Specifies whether the server is a secondary domain server. Valid values:

    • true

    • false

    isResourceManagerBackup

    true

    Specifies whether the scheduler is a secondary scheduler. Valid values:

    • true

    • false

    isComputeNode

    true

    Specifies whether the node is a compute node. Valid values:

    • true

    • false

    Exceptions

    Exceptions may occur when you create a cluster. The following exceptions are common:

    • If an exception occurs during cluster creation and the cluster fails to be created, the installation script is not executed.

    • If a single compute node of a created cluster is not running as expected, the installation script is not executed on the node.

    • If an exit code other than 0 is returned at the end of an installation script after a cluster is created, the script fails to be executed. You can check alert information on the Operation Log page of the E-HPC console. For more information, log on to the cluster, check log files in the /root directories of the failed nodes.