Create a custom OpenStack image with Packer
Create and customize an OpenStack image from an existing one with Packer
Objective
This guide will show you how to create a Packer configuration file to create your own OpenStack image.
Requirements
You'll need an OVHcloud Public Cloud project and a terminal.
OVHcloud Console Access
- Direct link:
- Navigation path:
Public Cloud> Select your project
Install Packer
Packer can be downloaded from the official website (currently here ) and you'll need to unzip it.
For Linux 64bits
Install the OpenStack plugin for Packer
Install jq
jq is a command line tool for parsing JSON document. It'll be used to automate the configuration file creation.
Fetch your openrc.sh configuration
From the , fetch your openrc.sh configuration file: in the left-hand menu of your Public Cloud project, click Project Management, then the Users tab, click the ... button on the row of your OpenStack user and select Download the OpenStack RC file. You might need to create an OpenStack user before.
Install openstack command line client
The easier way is to use a Python virtual environment
or install your distribution package apt-get install python-openstackclient
Verification
After sourcing the openrc.sh file, test your local setup with
Packer configuration
First, source your openrc.sh file with
Next, find the required IDs. You'll need the ID of the image, flavor and network. We'll build our image from Ubuntu 24.04 on a b2-7 hardware, with an interface connected on public network Ext-Net.
INFO: for FLAVOR_ID, you can directly use the name, i.e., b2-7
Finally, create a packer.json file
In the last section of the configuration file, we specify a setup_vm.sh shell script to be run.
Building the image
Using the configuration file above, validate and build the image:
If all went OK, you should have a new image available. You can check with
Tip: To enable debug information: export PACKER_LOG=1
Go further
Join our community of users.