How to preconfigure LXD containers with cloud-init

The original post here is now obsolete and it has been replaced by the following:

Permanent link to this article: https://blog.simos.info/how-to-preconfigure-lxd-containers-with-cloud-init/

6 comments

1 ping

Skip to comment form

  1. Cloud-init works only image ubuntu: How to use images: or other OS (Cetnos, Debian, etc)&

    1. Here is the relevant bug report and discussion on adding cloud-init on Debian,
      https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=850790

      The Debian image from images:debian/stretch does not have cloud-init pre-installed.
      The Centos image is 73MB and I doubt it has cloud-init. I suppose you have checked already.

      I think it is important for different distributions to add cloud-init support to their images.

      If you are interested in smaller Ubuntu images (but still have cloud-init), see the Ubuntu Minimal,
      https://blog.simos.info/a-closer-look-at-minimal-ubuntu-for-lxd/

      1. I tried install cloud-init in centos container and create image from container. Not work.

        lxc exec c2 bash
        yum install python2.7-minimal cloud-init
        exit
        lxc stop c2
        lxc publish c2 –alias centos-7

      2. Ideally, you would use distrobuilder (https://github.com/lxc/distrobuilder) to create a new container for your distribution. There is a template already for Centos.

        I do not know why in your published image, cloud-init is not working. It should be easy to debug this by following the boot-up sequence of the runtime.

  2. Can’t seem to get this to work on Ubuntu Bionic LTS.

    I have this in my LXD profile definition:

    config:
    environment.TZ: America/New_York
    user.user-data: |
    #cloud-init config
    package_upgrade: true
    package_reboot_if_required: true
    locale: es_US.UTF-8
    timezone: America/New_York

    And in the container in /var/lib/cloud/seed/nocloud-net/user-data, I have:

    #cloud-init config
    package_upgrade: true
    package_reboot_if_required: true
    locale: es_US.UTF-8
    timezone: America/New_York

    But none of the packages are updated and there is no mention in the cloud-init logs of an attempt.

    Any ideas?

  3. Does not work for ‘ubuntu:focal’
    Where is it stated which images have cloud-init enabled.
    This changed and I had all sorts of trouble, and looked in all the wrong places to try and fix it. 🙂

  1. […] How to preconfigure LXD containers with cloud-init […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.