What is Juju?
"With over 100 services ready to deploy, Juju enables you to build entire environments in the cloud with only a few commands on public clouds like Amazon Web Services and HP Cloud, to private clouds built on OpenStack, or raw bare metal via MAAS."
So you are able to install services, so called charms, in the cloud. You can use different clouds for that. I tested it locally than it is running with lxc to simulate the machines in the cloud locally.
The ~/.juju/environments.yaml for local looks like this:
data-dir: /home/vagrant/jujuOn Ubuntu you can add this ppa in order to get a more uptodate version:
After that you can install it:
apt-get install juju juju-jitsu juju-gui
juju-jitsu and juju-gui are not needed but provide some additional tools and a web frontend for deploying charms.
Afterwards make sure you have a ssh-key generated or generate it via:
ssh-keygen -t rsa -b 2048
Now you can bootstrap juju. This sets up a utility instance that is used to manage all the charms. Just type:
and you should be finished.
Hint: If you ever restart your system and juju is not working anymore. You can use these commands to start from scratch:
Now after you setup juju you may want to deploy some stuff. An example taken from the video on the juju site is setting up a mediawiki with mysql and haproxy. So we will test something like that.
These command will create to machines in the cloud. All commands are asynchronous so they will directly return to the prompt but have not finished. The first time it is downloading some additional stuff so it may take a few minutes befpre everything is up. You can take a look at the status with "juju status"
juju deploy mediawiki
juju deploy mysql
Now you want to connect the mediawiki to a sql database, just type this and the rest is done by the charms:
juju add-relation mediawiki:db mysql
To add an aditional unit for mediawiki you just have to type:
juju add-unit mediawiki
juju add-unit -n 5 mediawiki
if you want to add 5 more units.
That is nearly all to have it setup, but you can not reach it now. For that you have to expose the service. Cause we already added multiple units we do not want to expose them with lots of different urls. So we want to setup a load balancer. It is also quite easy:
juju add-unit mediawiki
juju add-relation haproxy mediawiki
juju expose haproxy
So the last command now exposes this service to the wild. Under "juju status" you can find the public-address of the services. So after everything is setup you can just go to the page and have a mediawiki.
Each charm has some different settings and relations you can add to them. For the mediawiki you can also setup a memcache with a few commands:
juju deploy memcached
juju add-relation mediawiki memcached
If you want later to add another memcache instance you can use a few extra parameters to specify a new name and some other options like:
juju deploy memcached new-cache --constraints mem=4G cpus=2
If you have any problems these commands might be helpfull:juju status
juju status memcached
If you have to investigate a specific charm you can connect to it via ssh with this command:
juju ssh memcached/0
This connects you to the first memcached unit.
A charming is running some hooks to do the installtion, add relations and so on. You can check if currently something is running with:
ps -aef | grep hooks
An additional charm log is also under:
tail -n 200 charm.log
If you have resolved the problem you can let it retry with:
juju resolved --retry memcached/0
Some charms can be upgraded with:
What it exactly does depends a bit on the charm and can sometimes be setup in different ways.
You can get all options for a charm with:
juju get mediawiki
And set a value like:
juju set mediawiki debug=true
You can find a lot of different charms on jujucharms.com and some additional help under https://juju.ubuntu.com/