This is the basic blueprint of my system for juju charming. I found that this was the quickest and least problematic setup for myself.
Below is the guide to working with this setup. Most of this will apply for working with a local server as well.
While I was working on my first juju charm, I found that the documentation was quite helpful, but I also ran into some recurring issues. As a result, I curated a lot of content, and created notes, which are now in the form of a supplementary guide for those heading down a similar path.
WHAT THIS GUIDE WILL DO
- Install and setup juju on a single, local desktop system for creating and testing charms
- Give you basic terminal commands for working with juju
- Give some tips for troubleshooting the juju environment
Follow the guide on the LEFT, and refer to the RIGHT when necessary.
Terminal commands in this guide will look like this.
|GET THE PPA READY
SETUP THE LOCAL ENVIRONMENT
Install juju for local environment use:
The juju environment should be ready for working in now.
PREPARE LOCAL CHARM REPOSITORY
This guide will assume that you are working from the home directory, so please setup in home:
You can now put charms that you are working on into ~/charms/trusty and deploy them via the local repository method (see below). Each charm will have its own unique directory that should match the charm name.
Install charm-tools for creating new charms, or testing existing ones:
If you get any errors during bootstrap, then the environment is probably already boostrapped. You may need to restart the juju db and agent services. This might happen if you reboot the computer (you will notice that the juju commands just hang).
Wait a few minutes for the agent to reconnect.
If the whole environment becomes messy or faulty, you can start over.
In the worst case you might have to purge the juju installation and start again:
Some other errors might require a juju package upgrade.
|USEFUL INFO COMMANDS
This will give you the details of what your current juju environment is doing.
A running log of whatever juju is doing. It will show you where charms are at, if there is an error, and when hooks are “completed.”
It is important to be patient when checking on the status of charms. Some issues are resolved by waiting. You can check juju status periodically to see changes.
|DEPLOYING SERVICES (i.e. “installing” charms)
a) You can deploy any “recommended” charm with:
e.g. juju deploy juju-gui
You can deploy multiple charms without waiting for the previous one to finish.
b) If you want to deploy a charm that you are working on locally (one-line command):
Replace “trusty” with “precise” if necessary.
c) You can also deploy from personal trunks that haven’t yet been recommended:
e.g. juju deploy cs:~joe/trusty/ethercalc-6
d) Deploying from the GUI (see GUI section below)
|Destroy services (i.e. charm installations):
Maybe you installed the wrong one, or it “failed” to install or configure.
“Un-Dead” Services ( Can’t Destroy )
Sometimes things are “dying” forever, but don’t actually die because they are in an “error state.”
If a charm/relation is in an “error” state, it will hang indefinitely at each error. You can’t even destroy it.
You can “resolve” the errors until all the hooks have gone through the cycle at which point the thing may die.
e.g. juju resolved suitecrm/0
if you have more than one of the same service, the /# will indicate which one.
*Be sure to spell “resolved” correctly. I never get it right first type
ssh into a service (remember a service is running inside its own “machine” by default)
If you want to go into the virtual machine that your service is running on to fix/break things more:
e.g. juju ssh suitecrm/0
No username or password needed. You have root access with “sudo”. Keep track of where you are (purple circle vs orange circle). “exit” to return to the local terminal
You can link/relate charms to each other if compatible. Commonly a database and another service.
WAIT again. Check the status do see “x-relation-changed” hook running etc.
Can’t add relation:
Check the charm’s readme to see if a special syntax is required for the relation.
Generally I like to wait for both services/charms to be in a ready state before adding a relation between them.
relation-changed hook failed, or the charms don’t like each other anymore:
e.g. juju destroy-relation suitecrm mysql
SAMPLE WORKFLOW: Deploying Services
Let’s see if that suitecrm charm is working for you.
Just because it has a public-address does not mean that it’s ready to be used.
Check status…… WAIT!
While you’re waiting… why not check out the readme document.
Access the service:
This will give you graphical way of working with juju. It is quite magical, but requires manual installation if not using juju-quickstart.
WAIT. Do a “
Run this in your terminal again to get the admin password
Once started, copy the public-address. Usually 10.0.#.### and visit that in a browser. It will likely complain about an insecure connection. For our purposes you can add the exception.
Login with: admin and the password from the above command.
The GUI is the simplest way to deploy and manage services. It does not provide much debugging information at this time. Most of the usage is pretty self-explanatory.
When you deploy a service it will show the icon with colours to indicate its status (these have been varying lately):
Yellow = wait
You do have to “commit” the changes to the canvas.
Hopefully this guide has provided you with an acceptable environment for working on your charm(s). Further documentation exists for starting a charm, but I also recommend finding an existing charm that is similar to the one that you want to create so that you can model the structure. More on this process can be seen in an earlier post.
Remember that you are not alone in this project: juju add-relation me community 😉