cloud-init doesn't start when no data source is present
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Expired
|
Wishlist
|
Unassigned |
Bug Description
I am using KVM (via libvirt)
1. I take bionic-
2. I create a simple user-data file
----
#cloud-config
users:
- default
- name: ubuntu
- ssh-rsa <contents of id_rsa.pub>
----
3. I create the seed ISO.
----
cloud-localds --hostname TEMPLATE --verbose seed.iso user-data
----
4. I boot the VM. Within the VM I run some provisioning ...
----
cloud-init status --wait
# Some provisioning here
apt-get install some devel libraries
truncate -s 0 /etc/machine-id
rm -rf /etc/netplan/*
rm -rf /etc/ssh/ssh_host_*
cloud-init clean --seed --logs
----
5. I shut down the VM. This, in theory, should become my template from which I should be able to clone new VMs, correct? However, when I clone and boot it, cloud-init does not run on the clones at all.
In /run/cloud-
----
di_report:
datasource_list: [ ]
# reporting not found result. notfound=disabled
----
In /run/cloud-
----
ds-identify rc=1
ds-identify_
cloud-init is enabled but no datasource found. disabling
----
Finally, in /run/cloud-
----
DSNAME=
DSLIST=NoCloud ConfigDrive OpenNebula DigitalOcean Azure AltCloud OVF MAAS GCE OpenStack CloudSigma SmartOS Bigstep Scaleway AliYun Ec2 CloudStack Hetzner IBMCloud Oracle Exoscale None
Mode=search
is_container=false
is_ds_enabled(
ec2 platform is 'Unknown'
No ds found [mode=search,
----
DSLIST in the above matches what is in /etc/cloud/
However, as mentioned in https:/
----
echo 'datasource_list: [ NoCloud, None ]' > /etc/cloud/
---
Then everything works just as I want it. The clones boot up properly, there's no need to attach any seed ISO file, we are able to login.
Why is it that when 90_dpkg.cfg contains [ NoCloud, None]
the cloning process works and cloud-init starts, but when 90_dpkg.cfg has a long list of entries (all of which are irrelevant) , it chooses to not even start?
(NOTE: This is on Ubuntu 18, /usr/bin/cloud-init 20.2-45-
Hi Hari,
Thanks for filing a bug.
> . I boot the VM. Within the VM I run some provisioning ...
Can you provide more details on how you're booting the VM? I ask because cloud-init is designed to *not* run unless it detects a datasource. The NoCloud datasource is detected in a few ways;
1) filesystem label found with 'cidata' or 'CIDATA' cloud/seed/ nocloud- * directory exists
2) DMI Product Serial includes ds=nocloud*
3) /var/lib/
> cloud-init clean --seed --logs
This operation will *remove* any seeds from /var/lib/ cloud/seed/ * in your image. If this was how you were telling cloud-init to run; you've now removed it and future boots of this image will not run cloud-init as you've not provided a datasource that will activate cloud-init.
> Why is it that when 90_dpkg.cfg contains [ NoCloud, None]
the cloning process works and cloud-init starts, but when 90_dpkg.cfg has a long list of entries (all of which are irrelevant) , it chooses to not even start?
cloud-init's reads /etc/cloud/ cloud.cfg and /etc/cloud/ cloud.cfg. d/*.cfg; if in those config files something sets the datasource_list to a single datasource (like you did); then cloud-init assumes that someone has configured a specific datasource and will always activate.
The goal for cloud-init is to allow an image to be re-used on any number of platforms; so if you've customized an image using NoCloud; if you take this image and booted it on Ec2 or Azure; it should work there (but will use the correct platform datasource rather than NoCloud).
I'm going to mark this bug invalid as it appears that cloud-init is working as designed but please change it back to New if you believe that cloud-init is not working as designed.