Installation and configuration of cloud-init on the Linux server
The IBM® Cloud Infrastructure Center uses cloud-init as its activation engine. It works well with:
cloud-init 18.5 for RHEL 7.9 and RHEL 8.4
cloud-init 18.4 for SLES 15 SP1
cloud-init 19.4 for SLES 15 SP2
cloud-init 20.1 for UBUNTU 20.04
cloud-init 20.2 for SLES 15 SP3
cloud-init 21.1 for RHEL8.6, RHEL8.8 and RHEL9.0
cloud-init 22.2 for UBUNTU 22.04
If you are using a different version of cloud-init, specify the following commands as required for your version of cloud-init.
During cloud-init installation, some dependency packages might be required. You can use yum, zypper or apt-get to easily resolve these dependencies.
Follow these steps to install and configure the cloud-init service:
Installing and configuring cloud-init on RHEL
ssh to the Linux server, then run the following to install cloud-init:
yum install cloud-initIBM Cloud Infrastructure Center uses
ConfigDriveas the data source for cloud-init. Remember to disable network configure module of cloud-init because the virtual machine network is configured by zvmguestconfigure service in IBM Cloud Infrastructure Center.Add the following lines to the default configuration file
/etc/cloud/cloud.cfg:datasource_list: [ ConfigDrive, None ] datasource: ConfigDrive: dsmode: local network: {config: disabled}If the image is for booting a virtual machine from volume, you must disable the mounts module from the cloud-init by removing the - mounts line. When using images to boot a virtual machine from a volume, disable the mounts module in cloud-init:
For OS versions lower than RHEL 8.10 (RHEL7 and RHEL8.1 ~ RHEL8.9), remove the - mounts line from the
cloud_config_modulessection.
cloud_config_modules: - locale - mounts <-- remove the line - set-passwordsFor OS versions RHEL 8.10 and RHEL 9, remove the
- mountsline from thecloud_init_modulessection.
cloud_init_modules: ... - disk_setup - mounts <-- remove the line - set_hostname ...
Note: Pay attention to the indentation, otherwise cloud-init might not work as expected.
Optionally, the default
/etc/cloud/cloud.cfgfile supports login by ssh key. If you want to log in by username and password via ssh, configure the/etc/cloud/cloud.cfgfile:ssh_pwauth: 1Optionally, to enable root login, you can configure the
/etc/cloud/cloud.cfgfile:disable_root: falseEnable and start the cloud-init related services by running the following commands:
systemctl enable cloud-init-local.service systemctl start cloud-init-local.service systemctl enable cloud-init.service systemctl start cloud-init.service systemctl enable cloud-config.service systemctl start cloud-config.service systemctl enable cloud-final.service systemctl start cloud-final.serviceIf you experience problems the first time you start
cloud-config.serviceandcloud-final.service, try to restart them.Ensure all cloud-init services have an active status by running the following commands:
systemctl status cloud-init-local.service systemctl status cloud-init.service systemctl status cloud-config.service systemctl status cloud-final.serviceTo verify the cloud-init configuration, issue the following command. If no errors occur, cloud-init is installed correctly:
cloud-init init --localRemove the
/var/lib/clouddirectory (if it exists) so that cloud-init does not run after a restart:rm -rf /var/lib/cloud
Installing and configuring cloud-init on SLES 15
ssh to the Linux server, then run the following to install cloud-init:
zypper install cloud-initNote: For SLES 15 SP1 server, the cloud-init package and required dependencies are included in the Basesystem-Module 15.1-0, Public-Cloud-Module 15.1-0 and Server-Applications-Module 15.1-0, make sure you can access these modules to install cloud-init.
IBM Cloud Infrastructure Center uses
ConfigDriveas the data source for cloud-init. Remember to disable network configure module of cloud-init because the virtual machine network is configured by zvmguestconfigure service in IBM Cloud Infrastructure Center.Add the following lines to the default configuration file
/etc/cloud/cloud.cfg:datasource_list: [ ConfigDrive, None ] datasource: ConfigDrive: dsmode: local network: {config: disabled}
Note: Pay attention to the indentation, otherwise cloud-init might not work as expected.
Enable and start the cloud-init related services by running the following commands:
systemctl enable cloud-init-local.service systemctl start cloud-init-local.service systemctl enable cloud-init.service systemctl start cloud-init.service systemctl enable cloud-config.service systemctl start cloud-config.service systemctl enable cloud-final.service systemctl start cloud-final.serviceIf you experience problems the first time you start
cloud-config.serviceandcloud-final.service, try to restart them.Ensure all cloud-init services have an active status by running the following commands:
systemctl status cloud-init-local.service systemctl status cloud-init.service systemctl status cloud-config.service systemctl status cloud-final.serviceTo verify the cloud-init configuration, issue the following command. If no errors occur, cloud-init is installed correctly:
cloud-init init --localRemove the
/var/lib/clouddirectory (if it exists) so that cloud-init does not run after a restart:rm -rf /var/lib/cloud
Installing and configuring cloud-init on Ubuntu 20.04 and Ubuntu 22.04
If you do not install cloud-init during the installation, after the installation complete, ssh to the Linux server, then run the following to install cloud-init:
apt-get install cloud-initIBM Cloud Infrastructure Center uses
ConfigDriveas the data source for cloud-init. Remember to disable network configure module of cloud-init because the virtual machine network is configured by zvmguestconfigure service in IBM Cloud Infrastructure CenterAdd the following lines to the default configuration file
/etc/cloud/cloud.cfg:datasource_list: [ ConfigDrive, None ] datasource: ConfigDrive: dsmode: local network: {config: disabled}
Note: Pay attention to the indentation, otherwise cloud-init might not work as expected.
Optionally, when install Ubuntu, if username created same within the
default_userin file/etc/cloud/cloud.cfg, setlock_passwditem value isFalseto enable login with password.Check whether the file
/etc/cloud/ds-identity.cfgwith following content exists, if not, create this file with upcoming content.policy: enabledDelete file
99-installer.cfgif the file existed in path/etc/cloud/cloud.cfg.d/.Enable and start the cloud-init related services by running the following commands:
systemctl enable cloud-init-local.service systemctl start cloud-init-local.service systemctl enable cloud-init.service systemctl start cloud-init.service systemctl enable cloud-config.service systemctl start cloud-config.service systemctl enable cloud-final.service systemctl start cloud-final.serviceIf you experience problems the first time you start
cloud-config.serviceandcloud-final.service, try to restart them.Ensure all cloud-init services have an active status by running the following commands:
systemctl status cloud-init-local.service systemctl status cloud-init.service systemctl status cloud-config.service systemctl status cloud-final.serviceTo verify the cloud-init configuration, issue the following command. If no errors occur, cloud-init is installed correctly:
cloud-init init --localRemove the
/var/lib/clouddirectory (if it exists) so that cloud-init does not run after a restart:rm -rf /var/lib/cloud