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

Discussion in 'Proxmox VE: Installation and configuration' started by ChappIO, Apr 1, 2018.

  1. ChappIO

    ChappIO New Member

    Joined:
    Apr 1, 2018
    Messages:
    8
    Likes Received:
    0
    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?
     
  2. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,446
    Likes Received:
    304
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    ChappIO likes this.
  3. ChappIO

    ChappIO New Member

    Joined:
    Apr 1, 2018
    Messages:
    8
    Likes Received:
    0
    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.
     
  4. dcsapak

    dcsapak Proxmox Staff Member
    Staff Member

    Joined:
    Feb 1, 2016
    Messages:
    3,519
    Likes Received:
    318
    which ubuntu version did you use? and how does your config look like? (qm config <ID>)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. ChappIO

    ChappIO New Member

    Joined:
    Apr 1, 2018
    Messages:
    8
    Likes Received:
    0
    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*
    
     

    Attached Files:

  6. pheonix991

    pheonix991 New Member

    Joined:
    Nov 22, 2016
    Messages:
    7
    Likes Received:
    1
    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
    
     
    DerDanilo likes this.
  7. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,446
    Likes Received:
    304
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    fireon likes this.
  8. ChappIO

    ChappIO New Member

    Joined:
    Apr 1, 2018
    Messages:
    8
    Likes Received:
    0
    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.
     
  9. pheonix991

    pheonix991 New Member

    Joined:
    Nov 22, 2016
    Messages:
    7
    Likes Received:
    1
    #9 pheonix991, Apr 7, 2018
    Last edited: Apr 8, 2018
  10. fireon

    fireon Well-Known Member
    Proxmox Subscriber

    Joined:
    Oct 25, 2010
    Messages:
    2,940
    Likes Received:
    173
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,446
    Likes Received:
    304
    This is auto-generated.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. hbokh

    hbokh New Member

    Joined:
    May 8, 2017
    Messages:
    6
    Likes Received:
    0
    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..
     
  13. Vengance

    Vengance Member

    Joined:
    May 21, 2016
    Messages:
    75
    Likes Received:
    3
    Will there be more features like an IP management?
    So I can enter my IPs/ Subnet and Proxmox will automatically choose a free IP?
     
  14. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,446
    Likes Received:
    304
    not for the next release.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. trystan

    trystan New Member

    Joined:
    Dec 15, 2017
    Messages:
    21
    Likes Received:
    1
    Are there further options like --sshkey and --ipconfig that exist for setting a username/password that can be passed via qm set for cloudinit?
     
  16. trystan

    trystan New Member

    Joined:
    Dec 15, 2017
    Messages:
    21
    Likes Received:
    1
    Just found --ciuser and --cipassword, nevermind.
     
  17. XN-Matt

    XN-Matt Member

    Joined:
    Aug 21, 2017
    Messages:
    36
    Likes Received:
    2
    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
     
  18. NIXKnight

    NIXKnight New Member

    Joined:
    May 27, 2018
    Messages:
    2
    Likes Received:
    0
    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?
     
  19. dietmar

    dietmar Proxmox Staff Member
    Staff Member

    Joined:
    Apr 28, 2005
    Messages:
    16,446
    Likes Received:
    304
    What cloud-init version do you use? The default version in stretch is far too old ...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. XN-Matt

    XN-Matt Member

    Joined:
    Aug 21, 2017
    Messages:
    36
    Likes Received:
    2
    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.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice