Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 6. Rerunning cloud-init on a virtual machine


You can rerun the cloud-init process when you need additional configurations for a virtual machine (VM) configured with the cloud-init service.

Warning

If you rerun the cloud-init process, you might lose data and overwrite credentials such as SSH keys and passwords. Avoid rerunning cloud-init in a production environment.

To change virtual machine (VM) settings after the initial boot, you need to modify the cloud-init configuration and rerun cloud-init.

Note

Clean the VM data directories before rerunning cloud-init to apply the new configuration.

Prerequisites

  • You have created a Red Hat account.
  • You have opted for one of the following options:

    • You have downloaded a Red Hat ISO image from the Red Hat Customer Portal and created a KVM guest image, which has cloud-init preinstalled and cloud-init set to run automatically on the VM.
    • You have created a custom image by downloading a Red Hat ISO image from the Red Hat Customer Portal and installed cloud-init on it.
    • You have created a custom image Red Hat Enterprise Linux (RHEL) ready for the public cloud platforms by using RHEL image builder. These image formats have cloud-init preinstalled: Amazon Machine Image (AMI), Virtual Hard Drive (VHD), and QEMU copy-on-write (QCOW2).

Procedure

  1. Log in to your VM.
  2. Add or change directives, for example, modify the cloud.cfg file in the /etc/cloud directory or add directives to the /etc/cloud/cloud.cfg.d directory.
  3. Run the cloud-init clean command to clean directories so that cloud-init can rerun.
  4. Run the following commands as root to clean the VM data:

    rm -Rf /var/lib/cloud/instances/
    rm -Rf /var/lib/cloud/instance
    rm -Rf /var/lib/cloud/data/
    Note

    You can save the cleaned image as a template image and use that image for multiple VMs. The new VMs will use the updated configuration to run cloud-init.

  5. Rerun cloud-init or reboot the VM to implement the configuration changes you made. For details on re-running cloud-init, see Re-run cloud-init.

6.2. Modifying a VM for a specific datasource after cloud-init has run

You can modify the cloud-init configuration before rerunning cloud-init. The exact steps vary based on your datasource, such as Red Hat OpenStack Platform or other cloud platforms.

Procedure

  1. Create and launch an instance for the Red Hat OpenStack Platform. For information about creating instances for Red Hat OpenStack Platform, see Creating an instance. In this example, the virtual machine (VM) includes cloud-init, which runs upon boot of the VM.
  2. Add or change directives. For example, modify the user-data.file file that is stored on the OpenStack HTTP server.
  3. Clean the virtual machine:

    # rm -rf /etc/resolv.conf /run/cloud-init
    # userdel -rf cloud-user
    # hostnamectl set-hostname localhost.localdomain
    # rm /etc/NetworkManager/conf.d/99-cloud-init.conf
    Note

    You can save the cleaned image as a template image and use that image for multiple virtual machines. The new virtual machines run cloud-init, using your updated cloud-init configuration.

  4. Rerun cloud-init or reboot the VM to implement the configuration changes you made. For details on re-running cloud-init, see Re-run cloud-init.
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2026 Red Hat
Nach oben