Skip to content

Commit

Permalink
docs: Add instructions to run libvirt with (#4578)
Browse files Browse the repository at this point in the history
Also organize other "how to run cloud-init locally" content better.

Fixes GH-4608
  • Loading branch information
holmanb committed Nov 16, 2023
1 parent 09dbdd8 commit d8bce58
Showing 1 changed file with 72 additions and 12 deletions.
84 changes: 72 additions & 12 deletions doc/rtd/howto/run_cloud_init_locally.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ The ``NoCloud`` datasouce allows users to provide their own user data,
metadata, or network configuration directly to an instance without running a
network service. This is helpful for launching local cloud images with QEMU.

The following is an example of creating the local disk using the
:command:`genisoimage` command:
Create your configuration
-------------------------
We will leave the network-config and meta-data files empty, but populate
user-data with a cloud-init configuration. You may edit the network and
meta-data files if you have a config to provide.

.. code-block:: shell-session
Expand All @@ -32,10 +35,12 @@ The following is an example of creating the local disk using the
chpasswd:
expire: False
ssh_pwauth: True
ssh_authorized_keys:
- ssh-rsa AAAA...UlIsqdaO+w==
EOF
Create an iso disk
------------------
This disk is used to pass configuration to cloud-init. Create it with the
:command:`genisoimage` command:

.. code-block:: shell-session
Expand All @@ -44,24 +49,35 @@ The following is an example of creating the local disk using the
-volid cidata -rational-rock -joliet \
user-data meta-data network-config
See the :ref:`network_config_v2` page for details on the format and config of
network configuration. To learn more about the possible values for metadata,
check out the :ref:`datasource_nocloud` page.
The resulting :file:`seed.img` can then be passed along to a cloud image
containing ``cloud-init``. Below is an example of passing the :file:`seed.img`
with QEMU:
Download a cloud image
----------------------
Download a Ubuntu image to run:

.. code-block:: shell-session
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
Boot the image with the iso attached
------------------------------------
Pass the :file:`seed.img` with QEMU:

.. code-block:: shell-session
$ qemu-system-x86_64 -m 1024 -net nic -net user \
-hda ubuntu-20.04-server-cloudimg-amd64.img \
-hda jammy-server-cloudimg-amd64.img \
-hdb seed.img
The now-booted image will allow for login using the password provided above.

For additional configuration, users can provide much more detailed
configuration, including network configuration and metadata:
configuration in the empty files network-config and meta-data.

.. note::

See the :ref:`network_config_v2` page for details on the format and config
of network configuration. To learn more about the possible values for
metadata, check out the :ref:`datasource_nocloud` page.

LXD
===
Expand Down Expand Up @@ -109,6 +125,50 @@ See the LXD `Instance Configuration`_ docs for more info about configuration
values or the LXD `Custom Network Configuration`_ document for more about
custom network config.

Libvirt
=======

Libvirt is tool for managing virtual machines and containers.

Create your configuration
-------------------------

We will leave the network-config and meta-data files empty, but populate
user-data with a cloud-init configuration. You may edit the network and
meta-data files if you have a config to provide.

.. code-block:: shell-session
$ 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 a Ubuntu image to run:

.. code-block:: shell-session
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
Create an instance
------------------

.. code-block:: shell-session
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"
Multipass
=========
`Multipass`_ is a cross-platform tool for launching Ubuntu VMs across Linux,
Expand Down

0 comments on commit d8bce58

Please sign in to comment.