canonical / canonical/multipass
Using #include section from cloud-init specs
- Dominant language
- C++
- Stars
- 9.2k
- Forks
- 828
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 44
Description
**What are you trying to do?**
I have several cloud-init files that describe virtual machine configurations. Some of their content is identical. I tried to separate the common part into a separate file and use it via the #include directive (). However, I didn't succeed.
To repeat my attempts, here is a brief example from the cloud-init documentation
```sh
multipass launch --cloud-init - <> /etc/hosts
- [ cloud-init-per, once, mymkfs, mkfs, /dev/vdb ]
```
After creating the VM, check the contents of the `/etc/hosts` file.
```console
ubuntu@infallible-ant:~$ sudo cat /etc/hosts
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 infallible-ant infallible-ant
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
```
The expected line "192.168.1.130 us.archive.ubuntu.com" is missing.
Checking whether the device was created `/dev/vdb`
```console
ubuntu@infallible-ant:~$ sudo ls /dev/vdb
ls: cannot access '/dev/vdb': No such file or directory
```
**What's your proposed solution?**
It would be great if we could use the `#include` directive to collect instructions for deploying a VM from several different files.
**Additional context**
The cloud-init documentation only provides an example for retrieving some settings from a remote source (https://...), but I hope that this should also work for local files. I also hope that file chains will work correctlyas well.
```yaml
# file-users.yaml
---
#cloud-config
users:
- name: username
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- $( cat ~/.ssh/id_rsa.pub )
```
⬇️
```yaml
# file-vm.yaml
---
#cloud-config
#include
file-users.yaml
package_update: true
package_upgrade: true
packages:
- git
- python3-pip
```
⬇️
```yaml
# file-extra.yaml
---
#cloud-config
#include
file-vm.yaml
runcmd:
- [ ls, -l, / ]
- [ sh, -xc, "echo $(date) ': hello world!'" ]
- [ sh, -c, echo "=========hello world=========" ]
- ls -l /root
```
Contributor guide
Research direction
Start by reproducing the `multipass launch --cloud-init` example and compare the observed VM state with the cloud-init include-file documentation linked in the issue. Check whether remote includes, local files, and chained includes are supported; done means the supported behavior is verified and the reported missing configuration is resolved or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100