Image Customization
Prebuilt images play an important role in OpenStack to allow seamless provisioning of instances.
You can use below steps to customize or build new images.
Table of Contents
Customize on Boot (Cloudinit)
OpenStack Instances can be injected with a custom cloud-init template which will provision resources on top of the base images on first boot.
During instance creation the cloud-init template needs to be passed via the user_data
property. In Horizon OpenStack Dashboard there is a textbox to pass a custom cloud-init template in the Instance Creation Wizard.
Create images manually
In cases where more customization is needed or the OS is not available as a prebuilt template a custom image can be built. However unless required we recommend to use pre-built cloud images and pass a cloud-init template for customization.
After successfully building the image you can upload it to OpenStack with the following command:
openstack image create \
--property hw_disk_bus=scsi \
--property hw_qemu_guest_agent=True \
--property hw_scsi_model=virtio-scsi \
--property os_require_quiesce=True \
--private \
--disk-format qcow2 \
--container-format bare \
--file ~/my-image.qcow2 \
my-image
The command to upload images requires these fields at a minimum:
--disk-format
: qcow2, in this case. This depends on the image format.--file
: The source file on your machine- Name of the Image:
my-image
for example.
Additionally, to enable the creation of Snapshots on running Instances, we recommend that you set --property hw_qemu_guest_agent=True
on the images you create, and to install the qemu-guest-agent
upon creation of the new image.
You can also use the dashboard to upload images. Make sure to use the same properties there.
Automated Image Build
For more advanced use cases image can be built automatically. There are a variety of tools such as Packer, image-bootstrap or windows-openstack-imaging-tools.
Please see Tools to automate image creation for more information.