The cloud-init data is private to each virtual machine and will not be replicated by cloning. Therefore, when cloning a virtual machine with cloud-init, the cloned virtual machine will not have the same initial configurations. Consequently, it is recommended to uninstall cloud-init from Guest OS before cloning the virtual machine.
In use
The cloud-init instance needs to be cleaned in the following scenarios:
When cloud-init virtual machines created using cloud-init templates do not meet expectations due to certain dependency service issues. In this case, the template needs to be reconverted into a virtual machine to modify the relevant configurations. After clearing the cloud-init instance to restore the cloud-init initializer to its initial state, shut down the virtual machine, and convert it back to a cloud-init template.
If you need to recreate a virtual machine that has been initialized by cloud-init as a cloud-init template, you need to clean the current cloud-init instance to restore the cloud-init initializer to its initial state, and then shut down the virtual machine, and convert it to a cloud-init template.
Procedure
Refer to the following two methods to clean the executed cloud-init instance.
Use the command cloud-init clean --logs --seed --disabled
to clean the cloud-init instances directly.
Refer to the Installing cloud-init in the operating system section, execute the command bash /mnt/<dir_to_mount_iso>/cloud-init/tools/clean_cloud_init.sh
to clean the instance. If the cleaning is successful, you will see the prompt cloud-init configuration cleanup completed
.
After cleaning the cloud-init instance, you can shut down the virtual machine, and then convert it to a VM template to create new cloud-init virtual machines.
Note:
If the virtual machine already has a NIC static IP configuration file, you need to manually delete it.
cloud-init will be automatically disabled after completing the virtual machine initialization, so it is not necessary to uninstall cloud-init before using the virtual machine.
If you want to uninstall cloud-init, you can execute the corresponding command according to the different software management tools used during installation.
If you are using the yum
software management tool, please execute:
yum remove cloud-init
to uninstall.
If you are using the apt-get
software management tool, please execute:
apt-get purge cloud-init
to uninstall.