Deploying Services
The fundamental point of Juju is that you can use it to deploy serivces through the use of charms (the magic bits of code that make things just work). These charms can be fetched from the charm store, stored in a local repository, or if you are feeling clever, written by you. Just as there are different series of Ubuntu ('precise', 'raring', etc), so there needs to be different series of charms to take into account any subtle changes in the underlying OS. For the most part you can forget about this, as Juju will always try to apply the most relevant charm, so deploying can be straightforward and easy.
Deploying from the Charm Store
In most cases, you will want to deploy charms by fetching them directly from the charm store. This ensures that you get the relevant, up to date version of the charm and "everything just works". To deploy a charm like this you can just specify:
juju deploy mysql
Running this will do exactly what you expect - fetch the latest juju charm for the series you are running and then use the bootstrap environment to initiate a new instance and deploy MySQL
Juju usefully supports a system of namespaces that means you can actually deploy charms from a variety of sources. The default source is the charm store. The above command is the same as running:
juju deploy cs:precise/mysql
which follows the format:
<repository>:<series><service>
Deploying from a local repository
There are many cases when you may wish to deploy charms from a local filesytem source rather than the charm store:
- When testing charms you have written.
- When you have modified store charms for some reason.
- When you don't have direct internet access.
... and probably a lot more times which you can imagine yourselves.
Juju can be pointed at a local directory to source charms from using the --repository=<path/to/files> switch like this:
juju deploy --repository=/usr/share/charms/ local:precise/vsftpd
You can also make use of standard filesystem shortcuts, so the following examples are also valid:
juju deploy --repository=. haproxy
juju deploy --repository=~/charms/ wordpress
Note: Specifying a local repository makes juju look there first, but if the relevant charm is not found in that repository, it will fall back to fetching it from the charm store. If you wish to check where a charm was installed from, it is listed in the juju status output.
Changing the defaults
As we have seen, we can specify repositories to install from on the commandline. In fact, this only introduces another potential source and changes the searching order. To permanently change the defaults (e.g. if you would prefer to always deploy from a local service first), you can enter a list of repositories in your environments.yaml file:
...
repositories:
- http://charms.ubuntu.com/collection/ubuntu
- http://charms.ubuntu.com/collection/openstack
- http://charms.ubuntu.com/people/miked
- /var/lib/charms
A note about caching...
After juju resolves a charm and its dependencies, it bundles them and deploys them to a machine provider charm cache/repository (e.g. ~/.juju/charmcache). This allows the same charm to be deployed to multiple machines repeatably and with minimal network transfers.