You can use Cloud Assistant to compile scripts for modifying configurations or installing applications and run the scripts on multiple ECS instances simultaneously. This eliminates the need to log on to instances one by one, saving your time. This topic uses shell scripts for Linux as an example to describe how to modify instance configurations.

Make sure that you fully understand how to use Cloud Assistant. For more information, see Use the cloud assistant .

Overview

Whether the scripts in this topic can be run on an ECS instance depends on the operating system and configurations of the instance. We recommend that you modify the scripts as needed. You can include the custom parameter {{key}} in the script to increase its applicability.

Modify instance configurations

  • Scenario: Modify configurations of an ECS instance by using Cloud Assistant.
  • Example: Run the following scripts to add, delete, and modify user information in an instance.
    # Add a user and set a password. {{password}} is the key of a custom parameter and you need to set the corresponding value before you run the script. useradd -m -p {{password}} {{newUser}}
    # Change the password. passwd {{password}}
    # Delete the user. userdel {{newUser}}
    # Modify the username. usermod -l {{newUser}} -d /home/{{newUser}} -m {{previousUser}}
  • Result: If you run the useradd -m -p test** student script, the following output is generated:
    [root@EcsHost ~]# su - student -c pwd
    /home/student

Install applications

  • Scenario: You can simultaneously install applications on multiple instances by using Cloud Assistant. This reduces repeated installation and deployment operations.
  • Example: Run the following scripts to install Python 3, which is suitable for systems that use yum, such as CentOS.
    yum install zlib zlib-devel readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel libdbi-devel ncurses-libs kernel-devel libxslt-devel libffi-devel python-devel zlib-devel openldap-devel sshpass gcc git -y
    wget -c https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
    tar -xzvf Python-3.6.6.tgz
    cd Python-3.6.6
    ./configure --prefix=/usr/local/python3
    make all
    make install
    make clean
    make distclean
    ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
  • Result: If you run the python3 script after Python 3 is installed, the following output is generated. If Python 3 is not installed, the error message command not found is returned.
    [root@EcsHost ~]# python3
    Python 3.6.6 (default, Jan 10 20**, 14:09:05)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

Upgrade applications

  • Scenario: You can upgrade applications within multiple ECS instances by using Cloud Assistant.
  • Example: You can run the following scripts to upgrade Python from 3.6.0 to 3.7.0.
    wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz && rm -rf /usr/bin/python3
    tar -xzvf Python-3.7.0.tgz
    cd Python-3.7.0
    ./configure && make && make install
    ln -s /usr/local/bin/python3.7 /usr/bin/python3
    ln -s /usr/local/bin/python3.7-config /usr/bin/python-config
    python3 -V
  • Result: The application is upgraded.
    [root@EcsHost ~]# python3 -V
    Python 3.7.0