mattyw

talkative, friendly, programmer

The Remote-deployer Charm: Playing With Juju During a Tea Break

| Comments

The power of juju, and its model driven approach to deployments is undoubtedly the relationships. Being able to specify what services you depend on and what you provide to other services is extremely powerful.

To get all of those benefits you need to write your app as a charm. With the new layering approach (http://blog.dasroot.net/2015-charming-2-point-oh.html) this has got even easier. There will be more posts about that coming soon.

But I’ve always pondered the following:

Is there a useful shortcut around writing a charm that would let you deploy your app in < 5 minutes

My idea was the remote-deployer charm (https://jujucharms.com/u/mattyw/remote-deployer/trusty/2)

It doesn’t replace writing your own charm, indeed the cases in which it’s useful are limited. (you must have a publicly available file path that you want to deploy from) The intention is to facilitate playing with juju in less time than the typical tea break.

The idea goes:

  1. Deploy the charm
  2. Give it something to do
1
2
juju deploy cs:~mattyw/trusty/remote-deployer-2
juju action do remote-deployer/0 deploy source=https://github.com/mattyw/compojure-app-bootstrap

The something to do is just pointing it at some remote file tree (like a github url). It downloads this file tree and looks for a file called remote-deployer. It runs this as the ubuntu user. The example above installs the clojure build tool lein and creates a hello world web app (https://github.com/mattyw/compojure-app-bootstrap)

1
2
3
4
5
6
7
8
# remote-deployer
#!/bin/sh
set -ev
sudo apt-get install -y --force-yes openjdk-7-jre-headless
sudo cp lein /usr/bin
cd $HOME && lein new compojure-app my-app
cd $HOME/my-app && nohup lein ring server &
open-port 3000

Juju fans will notice that the normal hook tools are available to you in this file.

If you’d like to suggest or help make improvements the project is here: https://github.com/mattyw/remote-deployer-charm

Take a look at in action:

Comments