'How can I use cloud-init to set up a VM with multipass that includes zsh?
I'm learning to use multipass. My version of multipass is multipass 1.9.0+mac
. I'm trying to create a very simple cloud-init configuration:
package:
- build-essential
- zsh
I start this with
multipass launch -n test --cloud-init config.yaml
I open a shell into that environment, but there is no zsh in /bin/.
Why was zsh not installed?
Solution 1:[1]
package
is not a valid top-level key, but packages
is. See the docs here.
It really should warn for this error but does not currently.
Try this:
#cloud-config
packages:
- build-essential
- zsh
Upstream cloud-init is working on better warnings/errors for this using jsonschema validation for configs (many changes on this front in upcoming releases). Currently, however, top level keys are not validated currently.
Also, it looks like multipass automatically inserts the #cloud-config
header for you so I don't think you need it on multipass specifically, but for portability to other datasources I would consider adding it anyways. Based on the userdata values in a multipass instance I tested I see the header both ways, so for portability I recommend adding it even though it's a no-op on multipass.
Solution 2:[2]
Also per Brett's comment https://stackoverflow.com/a/72233577/8479562, sudo cloud-init devel schema --annotate --system
should report whether the #cloud-config provided is was valid schema or not.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Chad Smith |