Run cloud-init locally with libvirt (original) (raw)
Toggle table of contents sidebar
Libvirt is a tool for managing virtual machines and containers.
Create your configuration¶
In this example we will create empty network-config
and meta-data
files, and create a user-data
file with a basic cloud-init configuration.
If you have network configuration or metadata to provide, edit thenetwork-config
and meta-data
files accordingly.
To create the files, run the following commands:
$ touch network-config $ touch meta-data $ cat >user-data <<EOF #cloud-config password: password chpasswd: expire: False ssh_pwauth: True EOF
Download a cloud image¶
Download an Ubuntu image to run:
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
Create an instance¶
virt-install --name cloud-init-001 --memory 4000 --noreboot
--os-variant detect=on,name=ubuntujammy
--disk=size=10,backing_store="$(pwd)/jammy-server-cloudimg-amd64.img"
--cloud-init user-data="$(pwd)/user-data,meta-data=$(pwd)/meta-data,network-config=$(pwd)/network-config"