Cloud-init Ubuntu 18.04 - netplan v2

encore

Well-Known Member
May 4, 2018
108
1
58
36
Hi,

I am playing arround with Cloud-Init to setup Ubuntu 18.04 VMs:
- Hostname
- User password change
- disk resize
works fine so far, but I do not get a static IP configured.

I figured out, Ubuntu is using Netplan v2 and Proxmox does not Support netplan v2, right?
Any ideas on how to achieve proxmox cloud-init to configure Ubuntu 18.04 networking?
 
It should out of the box. Please post your ipconfig (the one added in the GUI) as well as the output of 'cat /etc/netplan/50-cloud-init.yaml' in your VM.
You can also take a look at the logs, there's probably some information why it didn't work. (VM journal)
Cloud-init translates the v1 network config to the netplan one (which is a superset of the network config v2)
 
It should out of the box. Please post your ipconfig (the one added in the GUI) as well as the output of 'cat /etc/netplan/50-cloud-init.yaml' in your VM.
You can also take a look at the logs, there's probably some information why it didn't work. (VM journal)
Cloud-init translates the v1 network config to the netplan one (which is a superset of the network config v2)

Thanks for your answer, I hope you can help me out here.
Debian 8/9 with Cloud-Init works fine btw, even the network config. I still assume that this has something to do with netplan network config v2 and cloud-init is not able to read your format, but I am not sure.

Here you have everything you need:
/etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens18:
addresses:
- 134.255.23X.XX/XX
gateway4: 134.255.23X.X
nameservers:
addresses:
- 8.8.8.8
version: 2
These settings were NOT set by proxmox! These settings were set during the installation with an Ubuntu 18.04 ISO.

Cloud-Init settings from Proxmox GUI:
http://prntscr.com/n7thfu
SSH key, user settings, and Hostname were set successfully from the data given by proxmox.
Networking not. 50-cloud-init.yaml does not change.
Also tried to empty instance cache of cloud-init. So cloud-init really tried to execute everything.

Cloud.cfg:
# The top level settings are used as module
# and system configuration.

# A set of users which may be applied and/or used by various modules
# when a 'default' entry is found it will reference the 'default_user'
# from the distro configuration specified below
users:
- default

# If this is set, 'root' will not be able to ssh in and they
# will get a message to login instead as the default $user
disable_root: false

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false

# Example datasource config
# datasource:
# Ec2:
# metadata_urls: [ 'blah.com' ]
# timeout: 5 # (defaults to 50 seconds)
# max_wait: 10 # (defaults to 120 seconds)

# The modules that run in the 'init' stage
cloud_init_modules:
- migrator
- seed_random
- bootcmd
- write-files
- growpart
- resizefs
- disk_setup
- mounts
- set_hostname
- update_hostname
- update_etc_hosts
- ca-certs
- rsyslog
- users-groups
- ssh

# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
- emit_upstart
- snap
- snap_config # DEPRECATED- Drop in version 18.2
- ssh-import-id
- locale
- set-passwords
- grub-dpkg
- apt-pipelining
- apt-configure
- ubuntu-advantage
- ntp
- timezone
- disable-ec2-metadata
- runcmd
- byobu

# The modules that run in the 'final' stage
cloud_final_modules:
- snappy # DEPRECATED- Drop in version 18.2
- package-update-upgrade-install
- fan
- landscape
- lxd
- puppet
- chef
- mcollective
- salt-minion
- rightscale_userdata
- scripts-vendor
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- scripts-user
- ssh-authkey-fingerprints
- keys-to-console
- phone-home
- final-message
- power-state-change

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
# This will affect which distro class gets used
distro: ubuntu
# Default user name + that default users groups (if added/used)
default_user:
name: root
lock_passwd: True
gecos: Ubuntu
groups: [adm, audio, cdrom, dialout, dip, floppy, lxd, netdev, plugdev, sudo, video]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
# Automatically discover the best ntp_client
ntp_client: auto
# Other config here will be given to the distro class and/or path classes
paths:
cloud_dir: /var/lib/cloud/
templates_dir: /etc/cloud/templates/
upstart_dir: /etc/init/
package_mirrors:
- arches: [i386, amd64]
failsafe:
primary: http://archive.ubuntu.com/ubuntu
security: http://security.ubuntu.com/ubuntu
search:
primary:
- http://%(ec2_region)s.ec2.archive.ubuntu.com/ubuntu/
- http://%(availability_zone)s.clouds.archive.ubuntu.com/ubuntu/
- http://%(region)s.clouds.archive.ubuntu.com/ubuntu/
security: []
- arches: [armhf, armel, default]
failsafe:
primary: http://ports.ubuntu.com/ubuntu-ports
security: http://ports.ubuntu.com/ubuntu-ports
ssh_svcname: ssh

2019-04-05 09:04:41,054 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>
2019-04-05 09:04:41,055 - stages.py[DEBUG]: applying net config names for {'ethernets': {'ens18': {'addresses': ['134.255.23XX/XX'], 'gateway4': '134.255.23X.X', 'nameservers': {'addresses': ['8.8.8.8']}}}, 'version': 2}
2019-04-05 09:04:41,055 - __init__.py[DEBUG]: no interfaces to rename
2019-04-05 09:04:41,055 - __init__.py[DEBUG]: Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net,/dev/sr0][dsmode=net] not updated for events: System boot
2019-04-05 09:04:41,055 - stages.py[DEBUG]: No network config applied. Neither a new instance nor datasource network update on 'System boot' event
2019-04-05 09:04:41,055 - main.py[DEBUG]: [local] Exiting. datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net,/dev/sr0][dsmode=net] not in local mode.
2019-04-05 09:04:41,056 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2019-04-05 09:04:41,056 - util.py[DEBUG]: Read 12 bytes from /proc/uptime
2019-04-05 09:04:41,056 - util.py[DEBUG]: cloud-init mode 'init' took 0.293 seconds (0.30)
2019-04-05 09:04:41,056 - handlers.py[DEBUG]: finish: init-local: SUCCESS: searching for local datasources
2019-04-05 09:04:42,574 - util.py[DEBUG]: Cloud-init v. 18.5-45-g3554ffe8-0ubuntu1~18.04.1 running 'init' at Fri, 05 Apr 2019 09:04:42 +0000. Up 17.48 seconds.
2019-04-05 09:04:42,574 - main.py[DEBUG]: No kernel command line url found.
The IP and gateway within the log was not provided trough proxmox! Still the IP set to the VM during ISO installation. IP in the Proxmox GUI is different, check screenshot above.
 
Please post the complete VM config: 'qm config <vmid>' And if possible post the complete 'cloud-init.log' and 'cloud-init-output.log'.
 
Logs attached. Just to make sure again:
134.255.231.41/24
is not the IP set in Proxmox Cloud-Init GUI. This is the IP set during installation of the VM with the ubuntu ISO.
IP set in Proxmox Cloud-Init GUI is 185.223.28.197/24 (see QM config)
agent: 1
balloon: 2048
boot: dcn
bootdisk: scsi0
cipassword: **********
ciuser: test
cores: 4
ide2: imageserver-clones:117/vm-117-cloudinit.qcow2,media=cdrom
ipconfig0: ip=185.223.28.197/24,gw=185.223.28.1
keyboard: de
memory: 8192
name: ubuntu1804-en-image-scsi
nameserver: 8.8.4.4
net0: virtio=62:A7:8B:89:D6:64,bridge=vmbr0
numa: 0
ostype: l26
scsi0: imageserver-clones:117/vm-117-disk-0.qcow2,discard=on,size=5G,ssd=1
scsihw: virtio-scsi-pci
serial0: socket
smbios1: uuid=6ceb9c0f-29e2-4880-b69e-a82405527e9d
sockets: 1
sshkeys: ssh-rsa%20AAAAB3NzaC1yc2EAAAADAQABAAACAQDUQR%2BaaR%2B2EQz1nosufrVuVkKTN9GagKg9XuO5I2TQBU1r0U3urvd9AP1FEtEaKb8yH2b2LrjDQyJplSj2pZnAtPhaDxkTaP97CnV1Od0u54aVgv96NrB%2BkWMt76n%2B36ZyFmUm1VUoAUKCepguvdsuwiJ2%2BBBI3E2ktB%2FBvkAUhKTascufHo0vK3RyHV%2BpI6DrKYKyQ73KQ1UqNaQruxAbVWq8bGPfy7LEMg61Mi4TJvXJwpNzPxkZmQ40Xw4C47QdaLhJdDiQG2bLXI%2Ft4wWr8SgY2b6rz3GrjaLaL84qgE3UaYtyqGqiylYPR6qTRcw%2F1reondDHbfmy4VsvhHOpSJTRKPO%2FeQvCD62IcwVLdJymx%2BhrXDbBBg8ed4vhiRo3t6Js%2F7GjW%2FSmKGivOieN8aT322%2B5o%2BHmsJLYD2PYOiDuvEW8Y9FlLj2lFPWXuQ5tJS4f6Ad9AmszCevo9p5yOtKbDQLyyy2nLemBVord5sqyjuhLWhRWe5tZ0QjzeleXCRX0j4NqVx23AO2vkGuPPRBUCAx9t2kCxc%2BjNUhUhSISXaqxfyQvMF10NaqKYUgrLLIouMR9xEX1qj6j5icNQGpxO55RIm8MPobV5KqtEiXffWHKiIyKmS0gjvfvznOrrIjZOhBQAOHiyBzbhFRBuwkKOgHnVvJJr2i2wOT04Q%3D%3D%20
vmgenid: 4d67af92-00b4-404c-946d-27f9ea0a6a23

Maybe the datasource (mounted ISO inside the VM) is relevant:
root@ubuntu1804-en-image-scsi:/mnt# ls
meta-data network-config user-data
root@ubuntu1804-en-image-scsi:/mnt# cat *
instance-id: 026c022506165286d703949ba2f51e3ae29010fa
version: 1
config:
- type: physical
name: eth0
mac_address: '62:a7:8b:89:d6:64'
subnets:
- type: static
address: '185.223.28.197'
netmask: '255.255.255.0'
gateway: '185.223.28.1'
- type: nameserver
address:
- '8.8.4.4'
search:
- 'zap-hosting.com'
#cloud-config
hostname: ubuntu1804-en-image-scsi
manage_etc_hosts: true
user: test
password: $5$kEaexh0c$v/84nXBjOQAO9xesbleKxT0ZTN4IUbSSlBVxfTtQJ8/
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDUQR+aaR+2EQz1nosufrVuVkKTN9GagKg9XuO5I2TQBU1r0U3urvd9AP1FEtEaKb8yH2b2LrjDQyJplSj2pZnAtPhaDxkTaP97CnV1Od0u54aVgv96NrB+kWMt76n+36ZyFmUm1VUoAUKCepguvdsuwiJ2+BBI3E2ktB/BvkAUhKTascufHo0vK3RyHV+pI6DrKYKyQ73KQ1UqNaQruxAbVWq8bGPfy7LEMg61Mi4TJvXJwpNzPxkZmQ40Xw4C47QdaLhJdDiQG2bLXI/t4wWr8SgY2b6rz3GrjaLaL84qgE3UaYtyqGqiylYPR6qTRcw/1reondDHbfmy4VsvhHOpSJTRKPO/eQvCD62IcwVLdJymx+hrXDbBBg8ed4vhiRo3t6Js/7GjW/SmKGivOieN8aT322+5o+HmsJLYD2PYOiDuvEW8Y9FlLj2lFPWXuQ5tJS4f6Ad9AmszCevo9p5yOtKbDQLyyy2nLemBVord5sqyjuhLWhRWe5tZ0QjzeleXCRX0j4NqVx23AO2vkGuPPRBUCAx9t2kCxc+jNUhUhSISXaqxfyQvMF10NaqKYUgrLLIouMR9xEX1qj6j5icNQGpxO55RIm8MPobV5KqtEiXffWHKiIyKmS0gjvfvznOrrIjZOhBQAOHiyBzbhFRBuwkKOgHnVvJJr2i2wOT04Q== m.kluck
chpasswd:
expire: False
users:
- default
package_upgrade: true

root@ubuntu1804-en-image-scsi:/mnt# dpkg -l | grep cloud
ii cloud-guest-utils 0.30-0ubuntu5 all cloud guest utilities
ii cloud-init 18.5-45-g3554ffe8-0ubuntu1~18.04.1 all Init scripts for cloud instances
ii cloud-initramfs-copymods 0.40ubuntu1.1 all copy initramfs modules into root filesystem for later use
ii cloud-initramfs-dyn-netconf 0.40ubuntu1.1 all write a network interface file in /run for BOOTIF
I assume netplan v2 is not able to read your network config file from the datasource (proxmox' cloud init iso).
 

Attachments

  • cloud-init.log
    93 KB · Views: 13
  • cloud-init-output.log
    5.3 KB · Views: 4
Thank you for the output. I could reproduce the problem on 18.04. It worked in the past, but somehow doesn't now.
18.10 still works and I compared the logs to see if there's any difference. The new network config never gets written even though it should on a change.
I don't have any solution right now. Not even snippets worked with a network config v2. (Snippet support is a feature of qemu-server 5.0-48 and higher that allows one to override generated config files with custom ones (network, user, meta))
 
thanks so far @mira
did you compare cloud-init version of you 18.04 and 18.10 machine? Any difference here?
 
18.10: 18.5-45-g3554ffe8-0ubuntu1~18.10.1
18.04: 18.5-45-g3554ffe8-0ubuntu1~18.04.1
Also tried cloud-init 18.2 available in Ubuntu 18.04 and it did not work.
 
mhm I am facing the exact same issue on 18.10 as well.
There is the exact same version installed as you mentioned (18.10: 18.5-45-g3554ffe8-0ubuntu1~18.10.1)
Is your test VM a new VM installed with a ISO or is it older?
If new, what exact ISO did you use?

Could you send me the cloud-init.log and cloud.cfg, where it is working?
Also please share your kernel version.

Maybe we find some differences between your 18.10 VM and mine.

Thanks!
 
Both of my VMs are older. I just updated the 18.04 one and installed cloud-init at the same time.
18.10 kernel version: 4.18.0-17-generic
Just updated 18.10 from an older version, still works.
18.04 was installed from 18.04.1-live-server ISO, no idea which ISO I used for 18.10.
 
the key will be the comparison between a working and non working VM. Maybe you install a fresh new 18.10 VM https://www.ubuntu.com/download/server to confirm, that network config will NOT work as in my case. Then you compare packages, configs and logs between your working 18.10 VM and this.

Otherwise any chance to get SSH access to your working 18.10 VM? So I could compare with mine.
 
btw: same issue with Ubuntu 17.10 and netplan version 2. Seems like it is currently impossible to configure Proxmox KVM Ubuntu servers network with cloud-init.
 
nvm, I can confirm using this image:
https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
with the tutorial from proxmox:
https://pve.proxmox.com/wiki/Cloud-Init_Support "Preparing Cloud-Init Templates"
doing this step "# finally attach the new disk to the VM as scsi drive" trough the GUI (becaue I were not able to "attach" the disk when using the commands mentioned in this tutorial) and using this fix https://bugs.launchpad.net/cloud-images/+bug/1573095/comments/15 because it stucked at "Btrfs loaded" finally worked. Including network config.
 
I downgrade the cloud-init version to 18.2-14-g6d48d265-0ubuntu1, and the network config works well.
 
@chao On which side did you downgrade cloud-init? My host node is running Debian, so I cannot downgrade to that specific package version.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!