How to deploy ubuntu using CloudInit and Proxmox (BETA)?

ChappIO

New Member
Apr 1, 2018
8
0
1
30
I just installed the beta channel of Proxmox VE and I noticed the CloudInit device in the hardware section. I would like to play around with it since it might allow me to stop using and maintaining my scripts for VM creation.

I was able to add the CloudInit device but I cannot seem to find out how to launch cloud images. My main problem is that Proxmox still only allows .iso files as boot images, whereas most distros release .img files for their cloud images.

Am I too early to the party or am I missing something?
 

Absolutely! Thank you. I did not know I could just use templates to do this.
Just tried it and it works like a charm.

EDIT:

I think I did something wrong and I don't know if I should fix it in proxmox or in the guest.
I set the DNS Servers option in CloudInit (proxmox gui) to 172.20.0.1 (which is my gateway and dns server) but when I restarted the machine I did not have dns. After inspecting the interfaces I found that cloudinit added the nameserver to the lo interface and not to eth0. Does this sound familiar or did I do something wierd?

I did not use a cloud image, but instead just installed ubuntu using the iso installer and ran 'apt install cloud-init' after installation.
 
which ubuntu version did you use? and how does your config look like? (qm config <ID>)
 
which ubuntu version did you use? and how does your config look like? (qm config <ID>)

I used the latest ubuntu server lts: 16.04.04.

Steps:

1. Upload the iso through the web interface to the local storage
2. Install ubuntu using dhcp
3. Run `apt update && apt upgrade && apt install cloud-init`
4. Poweroff
5. Add CloudInit drive through web interface
6. Configure CloudInit drive:
Code:
User: Default
Password: non
DNS domain: use host settings
DNS servers: 172.20.0.1
SSH public key: my key
IP Config: ip=172.20.0.103/24,gw=172.20.0.1
7. Start Machine

Commands used for debugging:
Code:
 ssh ubuntu@172.20.0.103
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64)

0 packages can be updated.
0 updates are security updates.


Last login: Tue Apr  3 09:51:47 2018 from 192.168.1.205
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ubuntu-cloud-test:~$ host google.com
;; connection timed out; no servers could be reached
ubuntu@ubuntu-cloud-test:~$ host google.com 172.20.0.1
Using domain server:
Name: 172.20.0.1
Address: 172.20.0.1#53
Aliases:

google.com has address 216.58.212.206
google.com has IPv6 address 2a00:1450:400e:800::200e
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
ubuntu@ubuntu-cloud-test:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens18
iface ens18 inet dhcp
ubuntu@ubuntu-cloud-test:~$ cat /etc/network/interfaces.d/50-cloud-init.cfg
# 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}
auto lo
iface lo inet loopback
    dns-nameservers 172.20.0.1
    dns-search localdomain

auto eth0
iface eth0 inet static
    address 172.20.0.103/24
    gateway 172.20.0.1

Config:
Code:
qm config 103
bootdisk: scsi0
cores: 2
ide0: SSD:vm-103-cloudinit,media=cdrom
ide2: local:iso/ubuntu-16.04.4-server-amd64.iso,media=cdrom
ipconfig0: ip=172.20.0.103/24,gw=172.20.0.1
memory: 4000
name: ubuntu-cloud-test
net0: virtio=FE:74:C4:F5:CF:CE,bridge=vmbr0
numa: 0
ostype: l26
scsi0: HDD:vm-103-disk-1,size=32G
scsihw: virtio-scsi-pci
smbios1: uuid=6e86171d-2a4c-4fcf-8621-784a9159574b
sockets: 1
sshkeys: *snip*
 

Attachments

  • cloudinit_logs.txt
    91.2 KB · Views: 21
I hope it's cool if I piggy back on this thread. I just happen to be exploring cloud-init with intentions of automating my template builds.

I'm stuck. I don't understand how I'm supposed to generate the cloud-init data to mount to the cd-rom.
Code:
qm set 9001 --ide2 vmpool:cloudinit

Here is my script I have so far that I'll be feeding to Gitlab CI runner.
Code:
#!/bin/bash
wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
qm create 9001 --name ubuntu-cloud-image --memory 2048 --net0 virtio,bridge=vmbr0 --cores 2 --sockets 1 --cpu cputype=kvm64 --description "Ubuntu 18.04 cloud image" --kvm 1 --numa 1
qm importdisk 9001 bionic-server-cloudimg-amd64.img vmpool
qm set 9001 --scsihw virtio-scsi-pci --virtio0 vmpool:vm-9001-disk-1
qm set 9001 --ide2 vmpool:cloudinit
 
  • Like
Reactions: DerDanilo
So an update for everyone following this thread.

Following the instructions from @dietmar will work for ubuntu if you use the cloud image. An additional note, you can use the proxmox interface as well after you created the disk image. (cloning etc...).

What I cannot seem to do from the proxmox web interface is:
1. Create the disk image from the .img file
2. Resize the disk (which is supported by cloudinit)*
3. Create my own disk using the regular ubuntu server installer (I still cannot get the dns server to be set correctly)

EDIT:

*It seems I am incapable of using my eyes. Just seconds after I posted this I saw a 'resize' button in the 'hardware' view when I selected the hard drive.
 
I was already referring to that link.

This step though "qm set 9000 --ide2 local-lvm:cloudinit". How do I go about creating the "cloudinit" iso*? Where does that come from?
You don't have to create the cloudinit as an ISO: it is part of the QCOW2 diskimage if that image was created with cloud-init enabled..
 
Will there be more features like an IP management?
So I can enter my IPs/ Subnet and Proxmox will automatically choose a free IP?
 
which ubuntu version did you use? and how does your config look like? (qm config <ID>)

Just to add, similar to the other report. We have the exact same problem. dns-nameservers and dns-search are added to lo instead of eth0

Code:
# 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}
auto lo
iface lo inet loopback
    dns-nameservers x x x
    dns-search xxx.net

auto eth0
iface eth0 inet static
    address xxxxx/24
    gateway xxxxx
 
I am using Debian Stretch on VM in proxmox with cloud-init. I can't get an IP address on eth0.

In the logs it says that:

stages.py [WARNING]: failed to rename devices: [nic not present] Cannot rename mac=<VM MAC ADDRESS> to eth0, not available.


Where as in /etc/network/interfaces.d/50-cloud-init.cfg eth0 is defined to get an IP address via DHCP. But it still doesn't get one. ifconfig shows eth0 present.

Any help on that?
 
It may be worth posting what version of cloud-init should be used (as a minimum).

The one in CentOS 7 seems to suffer the same issue.
 

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!