6.2. Modifying a VM for a specific datasource after cloud-init has run
You can modify your cloud-init configuration before rerunning cloud-init. Note that the exact steps you need to perform vary based on your datasource. The following procedure uses OpenStack as an example datasource.
Procedure
-
Create and launch an instance for the OpenStack Platform. For information about creating instances for OpenStack, 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.conf注意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 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.