I am creating a custom core18-amd64 image using ubuntu-image tool and ubuntu-core-18-amd64.model-assertion.
ubuntu-image snap --snap docker --snap avahi --snap myprivatesnap_amd64.snap --cloud-init cloud-config.yaml ubuntu-core-18-amd64.model-assertion
cloud-config.yaml is very simple. It just runs a few snap commands to configure myprivatesnap:
#cloud-config
snap:
commands:
- snap connect myprivatesnap:avahi-control avahi
- snap connect myprivatesnap:docker-daemon docker
- snap connect myprivatesnap:docker-executables docker
- snap connect myprivatesnap:hardware-observe
- snap set myprivatesnap foo=bar
I have verified that the cloud-config.yaml is correctly written to /var/lib/cloud/seed/nocloud-net in the resulting image. However after cloud-init runs, /var/lib/cloud/instance/user-data.txt is empty. From /var/log/cloud-init.log, it seems that /var/lib/cloud/seed/nocloud-net/user-data is read but somehow get dropped.
I also see the following errors in /var/log/cloud-init.log:
OSError: [Errno 30] Read-only file system: ā/etc/pollinateā
OSError: [Errno 30] Read-only file system: ā/etc/localtimeā
/var/lib/cloud/data/status.json:
{
"v1": {
"datasource": "DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net,/dev/sr0][dsmode=net]",
"init": {
"errors": [
"('write-files', OSError(30, 'Read-only file system'))"
],
"finished": 1588981155.247145,
"start": 1588981154.733196
},
"init-local": {
"errors": [],
"finished": 1588981152.377084,
"start": 1588981151.9045477
},
"modules-config": {
"errors": [
"('timezone', OSError(30, 'Read-only file system'))"
],
"finished": 1588981156.988874,
"start": 1588981156.7807033
},
"modules-final": {
"errors": [],
"finished": 1588981157.4702873,
"start": 1588981157.3532157
},
"modules-init": {
"errors": [],
"finished": null,
"start": null
},
"stage": null
}
}
However when I pass the cloud-config file when launching the image via multipass, it does get picked up and all cloud-init commands are correctly executed:
multipass launch --cloud-init cloud-config.yaml file:///pc.img
I could use some help in troubleshooting why the pre-seeded cloud-init config is ignored while the same file gets correctly picked up by multipass. Thanks!