How to configure a Bash component on a compute

Step 1. Drop

  • Drop the Bash component on a compute.

Fig. Bash component properties

Step 2. Write a script and upload to the editor

  • Write a bash script (e.g., configure.sh)
#!/usr/bin/env bash
echo "Start configuring $NODE on compute $HOST"
echo "I have the ip address: $ip_address"

In this exmple, the script uses some environment variables, for instance NODE, HOST, and ip_address, which print the component name (e.g., Bash_1), the hosted compute (e.g., Compute_1), the IP address of the compute at runtime, respectively.

tip

For more environment variables, see this section)

  • Go to Archive content. This section displays the file directory of the application topology.
  • Upload configure.sh to the Archive content.

Fig. Open file directory of the application topology

Step 3. Choose an artifact

  1. Click on the Bash component, go to the Artifacts section. In this section, you can control the lifecycle of the Bash component by providing configuration scripts.
  2. Click configure / Select artifact and select the script configure.sh which you uploaded to the archieve content (in step 2).

Fig. Providing artifacts for a Bash component

Expected result

During the deployment, the deployment logs will print the following message when Bash_1 is executed on the compute:

Start configuring Bash_1 on compute Compute_1
I have the ip address: 10.0.0.3