Move your VMware and KVM applications to the cloud without making any changes

  • August 18, 2015

Preparing Linux Images for Ravello

One of the great things about building and running applications in Ravello is that you can, almost literally, drag and drop in machines from a range of virtualization platforms - VirtualBox, VMWare, Qemu-kvm, pretty much anything really. Then you can use these images to build your environment and run them without caring about the underlying cloud provider. In this blog, I will describe how to build a machine image for Ravello and some of the key modifications that need to be made both to a generic image and to a RHEL7 image in order for it to work properly.

To get started, you only need a disk image and machine information. However,it is incredibly important to remember that the machine image in question is, by necessity, going to be copied and cloned when you actually use it in a blueprint in Ravello.

As everyone who has done clones in a virtualization environment knows, if a machine is going to be cloned or copied you need to disable anything that was designed to lock a physical NIC to a machine. Almost universally this includes udev, with a popular technique being to drop a directory in udev (IE: mkdir -p /etc/udev/rules.d/60-net.rules). RHEL7, and thus CentOS 7, adds a couple additional wrinkles, because of course it does.

The changes introduced in the jump from EL6 to EL7 may very well be the most radical of any linux distribution update ever. In addition to normal things like software revisions we have:

  • SystemD replacing init.
  • A major version kernel update
  • grub and anaconda changes
  • NetworkManager replacing /etc/init.d/network
  • biosdevname now compliments udev
  • And at one point in the beta, net-tools was not installed as part of core.

Ubuntu, Debian, and Fedora have / had similar changes but they’ve been staggered across multiple releases, Red Hat got them all in in one. Anyway, in a world where init has gone away, the key changes here for virtual and cloud environments ironically come down to the network. Udev pinning interfaces to MAC addresses was a problem with cloning virtual hardware but fairly simple to resolve: drop a directory or device into udev(mkdir -p /etc/udev/rules.d/60-net.rules). The change to NetworkManager* however, requires some fiddly bits and biosdevname / net.if_names requires that you pass flags in to the kernel at boot.

* NetworkManager, strictly speaking, does not have to be disabled, but a number of automation tools or modules make a lot of assumptions around networking and so break on EL6 -> EL7 - often because of interface names and NetworkManager (IE: PackStack). It’s easier just to turn it off for now.

We have a fork here; if you’re kicking the machine you can add the options to the bootloader section (“bootloader --location=mbr --boot-drive=sda —append “net.ifnames=0 biosdevname=0”). If you’re working on an existing image, you’ll need to update the grub config:

 sed -i -e 's/quiet/net.ifnames=0 biosdevname=0 quiet/' /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg 


And to disable network manager:

 systemctl disable NetworkManager systemctl enable network 

After doing both of these changes you’ll need to manually configure the interface eth0 ala an EL6 machine:

 rm -f /etc/sysconfig/network-scripts/ifcfg-e* cat </etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO="dhcp" ONBOOT="yes" TYPE="Ethernet" EOT 


All of this can be loaded into your kickstart in the post-install section if you desire. I’d use the append technique as opposed to sed for turning off net.ifnames and biosdevname if you decide to do it that way though.

Next up is cloud-init. You need a minimum of one package for this, located in the extras repo, cloud-init. You also probably want dynamic resizing of storage volumes though, so you will want to tack on cloud-utils-growpart . After that you’ll want to make sure the cloud user exists and is configured the way you want it to be as well as cloud-init is on at boot:

 useradd -g adm,wheel,systemd-journal -G users cloud-user sed -i -e 's/centos/cloud-user/' /etc/cloud/cloud.cfg 


I like to drop it into sudoers with a ALL=(ALL) NOPASSWD:ALL

 echo “cloud-user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/cloud-user 


And that’s it, everything you absolutely need to know to build your own image. If you booted an CentOS 7.1.1503 disk and followed along you’ll have a rough approximation of this (Virtual Machine) - so go ahead and use that to get you started. A kickstart encompassing all of these changes is available here.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha