|GET THE PPA READY
sudo add-apt-repository ppa:juju/stable
sudo apt-get update
SETUP THE LOCAL ENVIRONMENT
Install juju for local environment use:
sudo apt-get install juju-core juju-local
juju switch local
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:
mkdir -p charms/trusty
(swap “trusty” for “precise” if necessary)
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:
sudo apt-get install charm-tools
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).
sudo service juju-db-$USER-local start
sudo service juju-agent-$USER-local start
Wait a few minutes for the agent to reconnect.
If the whole environment becomes messy or faulty, you can start over.
juju destroy-environment local
You will probably have to enter the super user password. And re-bootstrap.
In the worst case you might have to purge the juju installation and start again:
sudo apt-get purge juju*
sudo rm -rf ~/.juju
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.
Pay attention to public-address (IP), and current state of your charm. Don’t interact with it until it is “started”.
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.”
(You must CTRL C to get out of it.)
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:
juju deploy charmName
e.g. juju deploy juju-gui
You can deploy multiple charms without waiting for the previous one to finish.
Just don’t add relations until they are BOTH “started.”
b) If you want to deploy a charm that you are working on locally (one-line command):
juju deploy --repository=/home/$USER/charms/ local:trusty/charmname
e.g. juju deploy –repository=/home/$USER/charms/ local:trusty/diaspora
Replace “trusty” with “precise” if necessary.
c) You can also deploy from personal trunks that haven’t yet been recommended:
juju deploy cs:~launchpadUserId/trusty/charmname
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.
(You should probably destroy relations first.)
juju destroy-service serviceName
e.g. juju destroy-service suitecrm
“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.
juju resolved serviceName/0
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:
juju ssh serviceName/0
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.
juju add-relation charmName1 charmName2
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:
juju destroy-relation charm1 charm2
e.g. juju destroy-relation suitecrm mysql