User Tools

Site Tools


Working with Juju and MaaS

:!: WARNING: reboot support is not yet merged. If you need to reboot please use old binaries :!:

:!: For the sake of this example, we will assume that your MaaS IP is :!:

  • Install Go
sudo apt-get -y install golang-go git mercurial bzr mongodb
  • Set up your Go environment
echo 'export GOPATH=$HOME/golang' >> ~/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc
. ~/.bashrc
mkdir -p $GOPATH

This will add the necessary variables to facilitate building juju and to have juju (client) in your path once that's done.

  • Get a copy of juju-core from launchpad. This will pull in all other dependencies:
go get -v
  • Get correct dependencies
go get -v
cd $GOPATH/src/
godeps -f -u dependencies.tsv
  • build juju
go install -v

Binaries will be in $GOPATH/bin

:!: Instructions for the Windows version can be found HERE :!:

Setting up your Juju environment

  • Initialize your environment. This will create ~/.juju/environments.yaml
juju init
  • Set up juju to work with MaaS

Generating local tools

  • Uploading juju tools to MaaS

If you want to upload your version of juju to MaaS to be used for deployment (and you do):

mkdir -p ~/.juju/tools/releases
cd ~/.juju/tools/releases
cp ~/golang/bin/jujud* .
tar -czf juju-1.21.1-trusty-amd64.tgz jujud
rm jujud

Do this for every version of ubuntu that you want to have tools for. Trusty should be enough for development.

For windows machines:

cd ~/.juju/tools/releases
cp /location/to/jujud.exe . # this will have to be copied over from your Windows machine (see above)
tar -czf juju-1.21.1-win2012hvr2-amd64.tgz jujud.exe
rm *.exe

do this for every version you want to support

  • Generate the metadata necessary for uploading to MaaS:
juju-metadata generate-tools

This will generate all metadata from the tools found in ~/.juju/tools/releases. The metadata files can be found in:

ls -l /home/ubuntu/.juju/tools/streams/v1

Setting up your configuration

Go to your MaaS web interface under:

Where you will find:

MAAS keys
  • Generate a new key for Juju and copy it to your clipboard. On the node where you have juju installed, edit the file that was generated by juju init:
sed -i 's/^default:.*/default: maas/g' ~/.juju/environments.yaml
sed -i 's|maas-server: .*|maas-server: ""|' ~/.juju/environments.yaml
sed -i 's|maas-oauth: .*|maas-oauth: "<KEY FROM MAAS WEB UI>"|' ~/.juju/environments.yaml
  • Upload tools to MaaS:
juju sync-tools --source=/home/ubuntu/.juju/ --debug
  • Bootstrap the state machine
juju bootstrap --debug
  • If added in MaaS, you may optionally use constraints to tag particular node:
juju bootstrap --debug --constraints tags=StateMachine

This will take a while. If your network is slow, the first time you try to bootstrap will fail. Juju has a timeout of 10 minutes. Don't panic, just run it again. MaaS caches your debs and the next time you try it will get from local cache.

  • Set your nameserver to the MaaS IP address in resolv.conf (or equivalent)
echo 'nameserver' > /etc/resolv.conf # this will replace you nameservers
  • Check that the state machine has been bootstrapped:
juju status

this should output something similar to:

ubuntu@maas-controller:~$ juju status
environment: maas
    agent-state: started
    agent-version: 1.19.1
    dns-name: MaaS-StateMachine.maas
    instance-id: /api/1.0/nodes/node-4aecf276-c94c-11e3-95d7-525400a3b5b3/
    series: trusty
    state-server-member-status: has-vote

If it does not, I have failed miserably to explain this procedure properly, and I am ashamed.

You should now be able to deploy new charms. To test it out, lets install MySQL:

juju deploy mysql

This will install mysql on a “Ready” node (in MaaS).

juju.txt · Last modified: 2015/08/17 11:37 (external edit)