I have been experimenting with cloud-init and qemu. This is how I start my VM:
qemu-system-x86_64 \
--enable-kvm \
-nographic \
-m 2G -smp 4 \
-drive file=/disks/mustafa.img,if=virtio \
-cdrom /disks/my-seed.img \
-device virtio-net,netdev=network0,mac=52:55:00:d1:55:01 \
-netdev tap,id=network0,ifname=tap0,script=no,downscript=no
And the respecting meta-data and user-data files are:
instance-id: 49380625-37c5-48b0-8a2b-60bd1392519a
network:
version: 2
ethernets:
interface0:
match:
macaddress: 52:55:00:D1:55:01
set-name: eth0
addresses:
- 172.17.0.2/255.255.0.0
gateway4: 172.17.0.1
This is the user data, not really related but whatever.
#cloud-config
password: passw0rd
chpasswd: { expire: False }
ssh_pwauth: True
But it hangs with the following output:
[ OK ] Started Network Time Synchronization.
[ OK ] Reached target System Time Synchronized.
[ 6.148261] blk_update_request: I/O error, dev fd0, sector 0
[ 6.168261] blk_update_request: I/O error, dev fd0, sector 0
[ OK ] Started Update UTMP about System Boot/Shutdown.
[ 6.188260] blk_update_request: I/O error, dev fd0, sector 0
[ OK ] Started Set console font and keymap.
[ OK ] Created slice system-getty.slice.
[ 6.044744] cloud-init[417]: Cloud-init v. 0.7.9 running 'init-local' at Sat, 13 May 2017 14:49:10 +0000. Up 5.67 seconds.
[ OK ] Started Initial cloud-init job (pre-networking).
[ OK ] Reached target Network (Pre).
[ OK ] Started LSB: AppArmor initialization.
Starting Raise network interfaces...
[ *** ] A start job is running for Raise ne... interfaces (2min 25s / 5min 1s)
What am I doing wrong? I have read https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html
By the way, the following works perfectly:
instance-id: 49380625-37c5-48b0-8a2b-60bd1392519a
network-interfaces: |
auto ens3
iface ens3 inet static
address 172.17.0.2
netmask 255.255.0.0
gateway 172.17.0.1
But I do not want to use static interface names, and make them match hosts.