Cloud-init pre-configure not working on LXD 3.0/Bionic Beaver

(Stephen Nesbitt) #1

Has something changed in 3.0 with respect to embedding cloud-init provisioning of containers at launch?

Following Simos’s blog post i have created the following profile in the attempt to pre-configure the container on launch/initializtion

$ lxc profile show AWTUbuntu1804
  environment.TZ: ""
  user.user-data: |
    package_upgrade: true
      - build-essential
    locale: es_ES.UTF-8
    timezone: Europe/Madrid
      - [touch, /tmp/simos_was_here]
description: Default LXD profile
    nictype: bridged
    parent: lxdbr0
    type: nic
    path: /
    pool: default
    type: disk
name: AWTUbuntu1804
- /1.0/containers/test3
- /1.0/containers/test6

But it isn’t being executed - python2.7-minimal is not installed and no /tmp/simos_was_here file exists on either test3 or test6. I created test3 with the launch command. test6 was created through init and start.

Thx in advance,


(David Negreira) #2

Ubuntu 18.04 has no python2.7 by default

(Stephen Nesbitt) #3

Not sure I understand your meaning.

Python2.7-minimal is a package available on Bionic. As I understand it, the profile I have setup up should cause cloud-init to install the package when the container is inited.



I tried again the tutorial on LXD 3.0.0 and it worked. I got the /tmp/simos_was_here file.
Note that it takes some time to run that command because it first has to do a package upgrade.
To figure out what is going on, you can get a shell into the container as soon as you launch it, and then run ps ax to see the processes. You will be able to see the package upgrade (apt commands and so on) which takes a minute or two to complete.

You mention that python2.7-minimal is not installed on the Ubuntu 18.04 container image.
That is correct; on Ubuntu 18.04, there is no Python 2 whatsoever in the official images and ISOs.
Ubuntu 18.04 is fully transitioned to Python 3.
Here is the output from a freshly launched 18.04 container. The package is there, but not installed.

root@cloudinit:/tmp# apt policy python2.7-minimal
  Installed: (none)
  Candidate: 2.7.15~rc1-1
  Version table:
     2.7.15~rc1-1 500
        500 bionic/main amd64 Packages

To verify that the cloud-init commands have made it to the container, check (in the container) the following:

root@cloudinit:~# cat /var/lib/cloud/seed/nocloud-net/user-data 
package_upgrade: true
  - build-essential
locale: es_ES.UTF-8
timezone: Europe/Madrid
  - [touch, /tmp/simos_was_here]

By doing this, you verify that the container was created with the correct profile that has the cloud-init instructions.

(Stephen Nesbitt) #5

What Bionic image are you using?

My bionic image (images:ubuntu/18.04/amd64) doesn’t appear to have cloud-init installed…

apt policy cloud-init
Installed: (none)
Candidate: 18.2-14-g6d48d265-0ubuntu1
Version table:
18.2-14-g6d48d265-0ubuntu1 500
500 bionic/main amd64 Packages

(Stephen Nesbitt) #6

Ok - it’s definitely the image. I switched to ubuntu:18.04 and the python2.7-minimal is being installed.

Is there are any current documentation which lists the image servers available and what their differences are? How does images: differ from ubuntu: and how do I discover available image servers.

Thx for the help - got me asking the right questions.



Indeed, in general the images from images: are not likely to have cloud-init preinstalled.

Use instead the container image ubuntu:18.04 which has cloud-init.

(David Negreira) #8

You can see all the images on each remote with lxc image list ubuntu: and lxc image list images:. Not sure where can you find information about the images besides of what is in the description field.