Glam Prestige Journal

Bright entertainment trends with youth appeal.

The issue I have is the exact same as documented by someone on 18.04 years ago on StackOverflow but the solution there doesn't work. My steps to reproduce the problem are as follows:

I start with an image created like this:

# cloud-localds -vv --network-config=gluster1net.yaml vvv.img vvv.yaml
# qemu-img create -f qcow2 -b focal-server-cloudimg-amd64-disk-kvm.img vvv.qcow2 100G
# virsh create vvv.xml --console

The image vvv.img is mounted as /dev/sr0 inside the VM. The image contains what you would expect, as follows:

# ls -l test
total 2
-rw-r--r-- 1 root root 33 Apr 27 21:39 meta-data
-rw-r--r-- 1 root root 321 Apr 27 21:39 network-config
-rw-r--r-- 1 root root 707 Apr 27 21:39 user-data
# cat test/network-config
#cloud-config
network: version: 2 ethernets: ens3: dhcp4: false dhcp6: false addresses: [ "2001:000:1:841:1:0:30:100/64" ] gateway6: 2001:470:1:841::1 nameservers: search: [ zzz.com ] addresses: [ "2001:4860:4860::8888", "2001:4860:4860::8844" ]
# cat test/meta-data
{
"instance-id": "iid-local01"
}

When the VM boots up, the user-data is used properly. The host name gets set and the user gets set and I can log in. The network-config is ignored, and I end up with a default netplan configuration file. If I manually copy the above yaml file over the one in /etc/netplan and do netplan apply then I get the network configuration that is needed. But that is a manual process that cloud-init is supposed to do instead.

I can't find any solution in the cloud-init documentation. Does anyone here know what the problem is?

1 Answer

The network top-level key is optional and gets removed internally by cloud-init. Unfortunately, a bug exists where it isn't removed correctly:

Remove the #cloud-config header and the network key in your test/network-config file:

version: 2
ethernets: ens3: dhcp4: false dhcp6: false addresses: [ "2001:000:1:841:1:0:30:100/64" ] gateway6: 2001:470:1:841::1 nameservers: search: [ zzz.com ] addresses: [ "2001:4860:4860::8888", "2001:4860:4860::8844" ]
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy