Monday, January 11, 2016

Debian cloud template for XenServer [feedly]



----
Debian cloud template for XenServer
// Xen Orchestra

TL;DR: a working and validated Debian 8 (Jessie) template is available here if you want.

The story continue, after implementing the XenServer Cloud Init support in Xen Orchestra, and giving you a guide for CentOS: let's see now how to create a Debian compatible template "from scratch".

Debian installation

Let's create a new VM. The trivial way is to use the "Other install media". Put a Debian 8 ISO, netinstall is a good option.

CPU, RAM and even disk size could be changed later, so no worries with that now. Just click on Create VM.

Disk size could be only extended in the future, so it's better to create a small template (4 GiB is enough).

Let's go!

First, when you need to fill the username, use "debian"

Partitioning

To allow future disk growing, you need to create only one partition on the disk:

The recap:

Installing:

Xen tools

Before setting CloudInit, you can install XenServer Xen Tools: this way, they will be shipped with your template.

Like any normal tool installation:

  • Mount the XS Tool ISO
  • mount /dev/cdrom /mnt
  • dpkg -i /mnt/Linux/xe-guest-utilities_6.5.0-1427_amd64.deb
  • umount /mnt
  • eject the ISO

CloudInit

Let's install everything to have a CloudInit ready VM.

But first, we'll install sudo:

$ apt-get install sudo  

CloudInit installation:

$ apt-get install cloud-init cloud-initramfs-growroot  

Growpart package will allow to extend your template if necessary.

Configuration

The main configuration file for CloudInit is inside /etc/cloud/cloud.cfg. Almost all default parameters are OK, just modify some of them, like this one:

preserve_hostname: false    ssh_deletekeys: true    

It's indicating that existing ssh keys should be deleted on a per-instance basis. On a public image, this should absolutely be set to 'True'.

We'll also add a sudo without password, by editing this section at the end of the file:

   default_user:       name: debian       lock_passwd: True       gecos: Debian       groups: [adm, audio, cdrom, dialout, floppy, video, plugdev, dip]       sudo: ALL=(ALL) NOPASSWD:ALL  

This configuration will have:

  • a default user "debian", with sudo without password. Makes sense for a cloud image (it replaces the root user).
  • growpart working (extend the FS if the disk is larger than the current partition)
  • disabled SSH password authentication (only SSH keys)
  • root disabled
  • and a lot of other things, you can find documentation here

Let's use only the CloudInit source needed in our case:

$ dpkg-reconfigure cloud-init  

Uncheck everything but "OpenStack Config Drive":

And now, let's remove any possible root access:

$ passwd -l root  

You're good! You can halt the VM. You won't be able to login anymore with this one, except by using CloudInit from now.

Template creation

The easiest part, on the halted VM view:

Done!

Usage

Now, if you go inside the VM creation page:

Then, activate the config drive and give your SSH key:

Want the new VM bigger than the existing template? No problem, edit the root disk size (template disk was 4 GiB originally):

Now start the VM and SSH on its IP, it just works!

Extra stuff

This template is very generic. For your own needs, remember that you can install anything inside it, like a better bashrc file to have a fancy prompt, Git, Docker, etc.

Download the template

This template (with Xen Tools) is available here:

And import it:

It will appears in the template list!

If you want templates for other distros, just tell us in the comment section :)


----

Shared via my feedly reader


Sent from my iPhone

No comments:

Post a Comment