Elastic High Performance Computing:Configure an installation script

更新时间:
复制 MD 格式

An installation script runs automatically on all cluster nodes after the cluster is fully initialized — once all nodes are started and any selected software is installed. Use it to install additional software or deploy a software environment without manual intervention.

Use cases

  • After creating a cluster from a public image, install software or set up a software environment.

  • After creating a cluster from a custom image, run a custom script to deploy a software environment.

Prerequisites

Before you begin, ensure that you have:

  • An E-HPC cluster (or a cluster in the process of being created)

  • A script written in a Linux shell-compatible language (such as Bash or Python)

Configure the installation script

On the Create Cluster page, navigate to the Software Configurations step and find the Advanced Configurations section to add your installation script.

The script must be written in a language supported by the Linux shell. The first line must declare the interpreter with a shebang. For example, a Bash script starts with:

#!/bin/bash

Sample script

The following script logs cluster environment variables, metadata, and node roles to files in the /root directory. It uses conditional blocks to run different logic on each node type.

#!/bin/bash

echo "call $0 with param: $@" | tee /root/command.log


## show all available 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

To download this script, see the sample installation script.

Environment variables

E-HPC injects environment variables into each node before running the script. Use these variables to identify the cluster, the current node, and its role — so you can run different logic on different node types.

Cluster and node identity

VariableExampleDescription
ClusterIdehpc-hz-AQoy7J****The ID of the cluster.
HOSTNAMEi-bp133vs16yb3kqdj****The hostname of the current node.
AccountTypeNISThe type of the domain account. Valid values: NIS, LDAP.
SchedulerTypePBSThe type of the scheduler. Valid values: PBS, SLURM, GRIDENGINE.

Node role

The Role variable identifies what role the current node plays. A node can have multiple roles; if so, the value contains multiple role names separated by commas (,).

VariableExampleValid values
RoleAccountManagerAccountManager — management node of a primary domain account<br>AccountManagerBackup — management node of a secondary domain account<br>ResourceManager — primary scheduling node<br>ResourceManagerBackup — secondary scheduling node<br>Compute — compute node<br>LoginNode — logon node

For quick conditional checks, use the boolean variables below instead of parsing Role.

Boolean node-type flags

VariableExampleDescription
isLoginNodetrueWhether the node is a logon node. Valid values: true, false.
isAccountManagertrueWhether the node is the primary domain server. Valid values: true, false.
isAccountManagerBackuptrueWhether the node is the secondary domain server. Valid values: true, false.
isResourceManagertrueWhether the node is the primary scheduler. Valid values: true, false.
isResourceManagerBackuptrueWhether the node is the secondary scheduler. Valid values: true, false.
isComputeNodetrueWhether the node is a compute node. Valid values: true, false.

Network addresses

VariableExampleDescription
ResourceManagerIp192.168..The private IP address of the primary scheduling node.
ResourceManagerHostscheduler000The hostname of the primary scheduling node.
AccountManagerIp192.168..The private IP address of the management node of the primary domain account.
AccountManagerHostaccount000The hostname of the management node of the primary domain account.

The following variables are populated when high availability is enabled.

VariableExampleDescription
ResourceManagerBackupIp192.168..The private IP address of the secondary scheduling node (High availability enabled).
ResourceManagerBackupHostscheduler001The hostname of the secondary scheduling node (High availability enabled).
AccountManagerBackupIp192.168..The private IP address of the management node of the secondary domain account (High availability enabled).
AccountManagerBackupHostaccount001The hostname of the management node of the secondary domain account (High availability enabled).

Failure scenarios

The script does not run in the following situations:

  • Cluster creation fails: If the cluster fails to be created, the script is not executed on any node.

  • Single node not running: If a specific compute node in an otherwise-healthy cluster is not running as expected, the script is not executed on that node.

  • Non-zero exit code: If the script exits with a code other than 0, the execution is considered failed.

To investigate a non-zero exit code failure, check the Operation Log page in the E-HPC console for alert information. For more detail, log in to the cluster and inspect the log files in /root on the affected nodes.