第 2 章 Introduction to cloud-init


The cloud-init utility automates the initialization and configuration of virtual machines (VM), also known as instances, during the first boot. You can configure cloud-init to perform tasks such as:

  • Configuring a hostname, network interfaces, and user accounts
  • Installing packages on an instance
  • Running scripts
  • Modifying default virtual machine (VM) actions

Before you begin, make sure to complete the following step:

cloud-init is available for various types of RHEL images as follows:

  • A KVM qcow2 guest image comes preinstalled with cloud-init. After you launch the instance, the cloud-init utility is automatically enabled. You can use KVM guest images from the Red Hat Customer Portal with Red Hat Virtualization, Red Hat OpenStack Platform (RHOSP), and Red Hat OpenShift Virtualization.
  • If you download a Red Hat ISO image from the Red Hat Customer Portal to create a custom guest image, you need to install the cloud-init package on that customized guest image.
  • If you use an image from a certified cloud service provider (CCSP), such as Amazon Web Services (AWS), Google Cloud, or Microsoft Azure, you can use RHEL image builder to create the image. RHEL image builder customizes images for specific cloud providers. The following image formats come with cloud-init preinstalled:

    • Amazon Machine Image (AMI)
    • Virtual Hard Drive (VHD)
    • QEMU copy-on-write (QCOW2)

For details about the RHEL image builder, see Installing RHEL image builder.

Most cloud platforms support cloud-init, but configuration procedures and supported options vary.

Otherwise, you can configure cloud-init for the NoCloud environment. By using NoCloud, you can manage cloud instances for both a local configuration (without network access) and configurations fetched from a remote server. Additionally, you can create a VM template by configuring cloud-init on one VM. By using this template, you can create additional VMs or clusters of VMs.

2.1. Overview of the cloud-init configuration

The cloud-init utility uses YAML-formatted configuration files to apply user-defined tasks to instances. When an instance boots, the cloud-init service initiates and executes the instructions from the YAML file. These tasks may complete during the first boot or on subsequent boots of the VM, depending on the configuration.

To define the specific tasks, configure the /etc/cloud/cloud.cfg file and add directives under the /etc/cloud/cloud.cfg.d/ directory.

  • The cloud.cfg file includes directives for various system configurations, such as user access, authentication, and system information. This file also includes default and optional modules for cloud-init. The default module groups are as follows:

    • cloud_init_modules
    • cloud_config_modules
    • cloud_final_modules
  • You can include additional directives for cloud-init in the cloud.cfg.d directory.
  • While adding directives to the cloud.cfg.d directory, add them to a custom file named *.cfg, and always include #cloud-config at the top of the file.

For details, refer to an example file of cloud.cfg. See an example of cloud.cfg file.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部