To ensure that you can use the user data injection function to inject initial custom information into ECSs created from a private image (such as setting the ECS login password), install Cloud-Init on the ECS used to create the image.
For details, see Check Whether Cloud-Init Has Been Installed.
You can install Cloud-Init using either of the following methods: (Recommended) Install Cloud-Init Using the Official Installation Package and Install Cloud-Init Using the Official Source Code Package and pip.
Perform the operations provided here to check whether Cloud-Init has been installed.
The methods of checking whether Cloud-Init is installed vary depending on the OSs. Take CentOS 6 as an example. Run the following command to check whether Cloud-Init is installed:
rpm -qa |grep cloud-init
If information similar to the following is displayed, Cloud-Init has been installed:
cloud-init-0.7.5-10.el6.centos.2.x86_64
cd /root/.ssh
rm authorized_keys
cd /home/centos/.ssh
rm authorized_keys
sudo rm -rf /var/lib/cloud/*
Do not restart the ECS after performing the configuration. Otherwise, you need to configure it again.
The method of installing Cloud-Init on an ECS varies depending on the OS. Perform the installation operations as user root.
The following describes how to install Cloud-Init on an ECS running SUSE Linux, CentOS, Fedora, Debian, and Ubuntu. For other OS types, install the required type of Cloud-Init. For example, you need to install coreos-cloudinit on ECSs running CoreOS.
Paths for obtaining the Cloud-Init installation package for SUSE Linux
http://ftp5.gwdg.de/pub/opensuse/repositories/Cloud:/Tools/
http://download.opensuse.org/repositories/Cloud:/Tools/
Select the required repo installation package in the provided paths.
Take SUSE Enterprise Linux Server 12 as an example. Perform the following steps to install Cloud-Init:
zypper ar http://ftp5.gwdg.de/pub/opensuse/repositories/Cloud:/Tools/SLE_12_SP3/Cloud:Tools.repo
chkconfig cloud-init-local on; chkconfig cloud-init on; chkconfig cloud-config on; chkconfig cloud-final on
service cloud-init-local status; service cloud-init status; service cloud-config status; service cloud-final status
systemctl enable cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service
systemctl status cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service
For SUSE and openSUSE, perform the following steps to disable dynamic change of the ECS name:
vi etc/sysconfig/network/dhcp
Table 1 lists the Cloud-Init installation paths for CentOS. Select the required installation package from the following addresses.
OS Type |
Version |
How to Obtain |
|---|---|---|
CentOS |
6 32-bit |
|
6 64-bit |
https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/ |
|
7 64-bit |
Run the following commands to install Cloud-Init on an ECS running CentOS 6.5 64-bit (example):
yum install https://archives.fedoraproject.org/pub/archive/epel/6/x86_64/epel-release-xx-xx.noarch.rpm
yum install cloud-init
xx-xx indicates the version of Extra Packages for Enterprise Linux (EPEL) required by the current OS.
Before installing Cloud-Init, ensure that the network installation source address has been configured for the OS by checking whether the /etc/yum.repo.d/fedora.repo file contains the installation source address of the software package. If the file does not contain the address, configure the address by following the instructions on the Fedora official website.
Run the following command to install Cloud-Init:
yum install cloud-init
Before installing Cloud-Init, ensure that the network installation source address has been configured for the OS by checking whether the /etc/apt/sources.list file contains the installation source address of the software package. If the file does not contain the address, configure the address by following the instructions on the Debian or Ubuntu official website.
Run the following commands to install Cloud-Init:
apt-get update
apt-get install cloud-init
The following operations use Cloud-Init 0.7.9 as an example to describe how to install Cloud-Init.
Download cloud-init-0.7.9.tar.gz from the following path:
https://launchpad.net/cloud-init/trunk/0.7.9/+download/cloud-init-0.7.9.tar.gz
If the ~/.pip/ directory does not exist, run the mkdir ~/.pip command to create it.
[global] index-url = https://<$mirror>/simple/ trusted-host = <$mirror>
Replace <$mirror> with a public network PyPI source.
Public network PyPI source: https://pypi.python.org/
pip install [--upgrade] /home/cloud-init-0.7.9.tar.gz
cloud-init 0.7.9
chkconfig --add cloud-init-local; chkconfig --add cloud-init; chkconfig --add cloud-config; chkconfig --add cloud-final
chkconfig cloud-init-local on; chkconfig cloud-init on; chkconfig cloud-config on; chkconfig cloud-final on
service cloud-init-local status; service cloud-init status; service cloud-config status; service cloud-final status
systemctl enable cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service
systemctl status cloud-init-local.service cloud-init.service cloud-config.service cloud-final.service
If you install Cloud-Init using the official source code package and pip, pay attention to the following:
useradd syslog
groupadd adm
usermod -g adm syslog