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.
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.
6.1. Modifying a VM created from a KVM Guest Image after cloud-init has run Link kopierenLink in die Zwischenablage kopiert!
To change virtual machine (VM) settings after the initial boot, you need to modify the cloud-init configuration and rerun cloud-init.
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-initpreinstalled andcloud-initset 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-initon 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-initpreinstalled: Amazon Machine Image (AMI), Virtual Hard Drive (VHD), and QEMU copy-on-write (QCOW2).
-
You have downloaded a Red Hat ISO image from the Red Hat Customer Portal and created a KVM guest image, which has
Procedure
- Log in to your VM.
-
Add or change directives, for example, modify the
cloud.cfgfile in the/etc/clouddirectory or add directives to the/etc/cloud/cloud.cfg.ddirectory. -
Run the
cloud-init cleancommand to clean directories so thatcloud-initcan rerun. Run the following commands as
rootto clean the VM data:rm -Rf /var/lib/cloud/instances/ rm -Rf /var/lib/cloud/instance rm -Rf /var/lib/cloud/data/NoteYou 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.-
Rerun
cloud-initor reboot the VM to implement the configuration changes you made. For details on re-runningcloud-init, see Re-run cloud-init.
6.2. Modifying a VM for a specific datasource after cloud-init has run Link kopierenLink in die Zwischenablage kopiert!
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
-
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. -
Add or change directives. For example, modify the
user-data.filefile that is stored on the OpenStack HTTP server. 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.confNoteYou 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 updatedcloud-initconfiguration.-
Rerun
cloud-initor reboot the VM to implement the configuration changes you made. For details on re-runningcloud-init, see Re-run cloud-init.