OpenTechStrategies / lisc-ttm

LISC TTM code. See https://ttm.lisc-chicago.org/.
GNU Affero General Public License v3.0
1 stars 4 forks source link

Switch from virtualbox to qemu in deployment system #105

Open cwebber opened 9 years ago

cwebber commented 9 years ago

Virtualbox apparently has a non-free bios compiler dependency (wtf) and we're going for free as in freedom / open as in totally open, so! Let's see if we can replace virtualbox with qemu in our ansible deployment setup.

cwebber commented 9 years ago

There are a couple of routes:

Some resources:

cwebber commented 9 years ago

Obviously we want to have reproducible builds of qemu images, or have the user build their own. I'll settle for a prebuilt image for testing first though.

kfogel commented 9 years ago

Yay! (Just watching and cheering; I trust your judgement about the right route to go here...)

cwebber commented 9 years ago

I got qemu working. That was easy, pleasant, and interesting.

However, getting Vagrant to work with qemu has turned out to be a real challenge. Here's what I ran into:

Vagrant doesn't do quite that much anyway. One thing that's nice about qemu images: they're just files you can copy around very easily. I think at this point we should ditch Vagrant... I have a much simpler suggestion, but I am going to write it up as a separate comment.

kfogel commented 9 years ago

I'm sold -- ditching Vagrant is fine. Looking forward to your upcoming suggestion comment!

cwebber commented 9 years ago

Here's my much simpler suggestion. We can start with something small and grow it a bit if needed.

For the whole "local virtual machine for development that you can setup and tear down", why not KISS? How about a simple makefile. At its very simplest:

# Install "base" vm if needed, copy over one for hacking, turn it on, and provision it
make
# turn it off
make halt
# Destroy it
make destroy

The default "make" target automatically will run some other targets, that can of course be run individually if desired::

# first-time setup of *base* virtual machine
$ make base
# make a "copy" of the vm for local hacking... copies the base file
$ make vm
# turn on the vm
$ make up
# provision the vm (doesn't provision the live server, we can use normal ansible commands for that)
$ make provision

(We could use a filename like "vm.make" and do "make -f vm.make" if we want to be clear about it.)

Karl, what do you think of this? We can eventually iterate to something more "sophisticated" if needed, but I think this will be fine. Again, Vagrant does not do that much.

If we figure this out nicely, it could be the basis for future OTS stuff too.

cwebber commented 9 years ago

Sketching things out:

.PHONY: up server-is-up vm base provision halt destroy

###################
# Default locations
###################

PIDFILE=.vm/running.pid
BASE_IMAGE=.vm/base-image.qcow2
DEV_IMAGE=.vm/dev.qcow2

######################################################################
# Targets
######################################################################

# Provision
# =========

# Turn on (if needed) and provision the server

provision: up
    ./deploy/scripts/provision.sh

# Spin up
# =======

up: vm $PIDFILE

# This is where we really turn it on
$PIDFILE:
    ./deploy/scripts/run_vm.sh

# Create the base image
# =====================

base: $BASE_IMAGE

# This is where we really make the base image
$BASE_IMAGE:
    ./ansible/scripts/make_base_image.sh

# Create the user's dev VM
# ========================

vm: base $DEV_IMAGE

$DEV_IMAGE:
    cp $BASE_IMAGE $DEV_IMAGE

# Turning stuff off and destroying
# ================================

halt:
    ./deploy/scripts/halt_if_running.sh

destroy: halt
    -rm -f $DEV_IMAGE

destroy-base: halt
    -rm -f $BASE_IMAGE
cwebber commented 9 years ago

I've started a branch with these changes: https://github.com/OpenTechStrategies/lisc-ttm/tree/qemu

There are some errors in the "sketched out" makefile above, but I'm fixing things up as I go.

kfogel commented 9 years ago

+1 on this solution. Is there a way to specify a custom name for the environment being made? Or is that just "the directory in which one is doing all this"?

kfogel commented 9 years ago

By the way, if this is not TTM-specific, let's break it out into its own open-source repository under OpenTechStrategies. @cwebber, I can make sure you have perms to create new repositories in there if you don't have them already.

cwebber commented 9 years ago

@kfogel It's just "the directory in which one is doing all this" but we can look at changing that up later if need be.

I'm glad you're interested in breaking it out into its own FOSS repo once we're done with it! I think it makes sense to nail down how it works in TTM first, then once we have a sense of that, break it out.

kfogel commented 9 years ago

Why would we wait until we're done with it to break it out into its own FOSS repo?

http://opentechstrategies.com/resources#be-open-from-day-one

cwebber commented 9 years ago

@kfogel It's mostly because I'm not sure how to "break out" a makefile and what route to take for that when generalizing i. I agree with "be open from day one" generally.

kfogel commented 9 years ago

Hmm. Okay, yeah, I see. If it's easier to map out the problem space by doing it within TTM first, that's fine. Probably the abstraction boundaries will become clearer as you go.