2.3. Boot stages of cloud-init


The cloud-init utility completes VM configuration in the following 5 boot stages. Phase is the logical grouping of the boot stages that controls the sequence of execution of modules. The default modules execute in the specific phase.

During system boot, the cloud-init utility operates in five stages that determine whether cloud-init runs and where it finds its datasources, among other tasks. Each stage also belongs to a module execution phase, which controls what modules are run. The stages are as follows:

  1. Detect stage: By using the systemd service, this stage determines whether to run cloud-init utility at the time of boot. The ds-identify tool detects whether or not to run cloud-init in the absence of a valid platform.

    This stage belongs to the Initialization phase and does not execute any modules. Instead, it identifies the datasource for cloud-init configuration.

  2. Local stage: cloud-init searches local datasources and applies network configuration, including the DHCP-based fallback mechanism.

    This stage belongs to the Initialization phase and does not execute any modules.

  3. Network stage: cloud-init processes user data by running modules listed under cloud_init_modules in the /etc/cloud/cloud.cfg file. You can add, remove, enable, or disable modules in the cloud_init_modules section.

    This stage belongs to the Networking module execution stage.

  4. Config stage: cloud-init runs modules listed under cloud_config_modules section in the /etc/cloud/cloud.cfg file. You can add, remove, enable, or disable modules in the cloud_config_modules section.

    This stage belongs to the Configuration module execution phase.

  5. Final stage: cloud-init runs modules and configurations included in the cloud_final_modules section of the /etc/cloud/cloud.cfg file. It can include the installation of specific packages, as well as triggering configuration management plug-ins and user-defined scripts. You can add, remove, enable, or disable modules in the cloud_final_modules section.

    This stage is equivalent to the Finalization module execution phase.

During the first boot of VM, when the cloud-init service initiates, all the configured modules execute in their respective phases. On subsequent booting, whether a module executes within a phase depends on the module frequency of that module. Module frequency is set in the cloud-init configuration, and determines whether a module executes every time cloud-init runs on the instance, or only the first time cloud-init runs, even if the instance ID changes.

注意

An instance ID uniquely identifies an instance. When an instance ID changes, cloud-init treats the instance as a new instance. For details, see Scename definition for module creation.

The possible module frequency values are as follows:

  • PER_INSTANCE means that the module runs on first boot of an instance. For example, if you clone an instance or create a new instance from a saved image, the modules designated as per instance run again.
  • ONCE means that the module runs only once. For example, if you clone an instance or create a new instance from a saved image, the modules designated per once do not run again on those instances.
  • PER_ALWAYS means the module runs on every boot.
注意

You can override a module’s frequency when you configure the module or by using the command line.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部