Local LXD image server

I’ve also seen this solved as a juju model-config cloudinit-userdata setting for new machines to download and install their lxd images via curl and lxc image commands at a machine’s initial creation (you can change these URLs to point to images you’re hosting). This was used specifically due to a proxy blocking older juju go libraries from making this call with old TLS versions through a secure proxy. We’ve since swapped most of these sites over to use the container-image-metadata-url method described above.

$ juju model-config cloudinit-userdata
postruncmd:
  - if hostname |grep -qv lxd; then wget --tries=15 --retry-connrefused --timeout=15 --random-wait=on -O /home/ubuntu/ubuntu-16.04-server-cloudimg-amd64-lxd.tar.xz https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-lxd.tar.xz; fi
  - if hostname |grep -qv lxd; then wget --tries=15 --retry-connrefused --timeout=15 --random-wait=on -O /home/ubuntu/ubuntu-18.04-server-cloudimg-amd64-lxd.tar.xz https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-18.04-server-cloudimg-amd64-lxd.tar.xz; fi
  - if hostname |grep -qv lxd; then wget --tries=15 --retry-connrefused --timeout=15 --random-wait=on -O /home/ubuntu/ubuntu-16.04-server-cloudimg-amd64.squashfs https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64.squashfs; fi
  - if hostname |grep -qv lxd; then wget --tries=15 --retry-connrefused --timeout=15 --random-wait=on -O /home/ubuntu/ubuntu-18.04-server-cloudimg-amd64.squashfs https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-18.04-server-cloudimg-amd64.squashfs; fi
  - sleep 30 # it seems there is race condition in system lxd startup and cloud init.
  - if hostname |grep -qv lxd; then lxc image import /home/ubuntu/ubuntu-16.04-server-cloudimg-amd64-lxd.tar.xz /home/ubuntu/ubuntu-16.04-server-cloudimg-amd64.squashfs --alias juju/xenial/amd64; fi
  - if hostname |grep -qv lxd; then lxc image import /home/ubuntu/ubuntu-18.04-server-cloudimg-amd64-lxd.tar.xz /home/ubuntu/ubuntu-18.04-server-cloudimg-amd64.squashfs --alias juju/bionic/amd64; fi
  - lxc image list