Juju, MAAS, and VirtualBox

I’ve been meaning to use MAAS for quite some time. In fact, I’ve been excited about its release since I stumbled upon it a few weeks before its announcement in the package repo. I originally started by trying to install Xen on my Desktop as it’s what I’ll be using in production. That didn’t quite work out, so I took my chances with VirtualBox instead. I skimmed the Testing MAAS section of the documentation and felt confident enough that VirtualBox could handle something like MAAS. To start, I created a few MAAS machines in VirtualBox and attached the 12.04 ISO as the install medium. I started the first one to install a MAAS “master” server.

On the installation screen I selected the “Multiple server install with MAAS” option, selected “Create a new MAAS on this server”, and followed the defaults from there. Toward the end of the install I was given an address through which I could view the MAAS control panel, 10.0.2.5. Needless to say I was pretty excited. Of course, the address didn’t work and I quickly realized that I couldn’t actually access that network. Reviewing the Networking settings for the VM I made the following changes:

Attached to: Bridged Adapter
Name: eth0
Promiscuous Mode: Allow All

I updated each unit to reflect these settings. After the update, I had to re-start the VM and reconfigure MAAS to use the new address. This was done simply with:

sudo dpkg-reconfigure maas

Then I updated the IP to reflect the new IP address within my network. After doing so 192.168.5.27 became my MAAS Master, and http://192.168.5.27/MAAS loaded the control panel!

Taking notice of what the Dashboard says, I ran the following two commands:

sudo maas createsuperuser
sudo maas-import-isos

The first command prompted me for a user, password, and email. The second ran for several minutes downloading and creating different precise images. Once that was finished, my dashboard still showed warnings of impor-isos, but more importantly I was able to log in and see that I had 0 nodes!

This gave me the confidence to push forward. I started the “maas1″ VM to begin the install process. Like before, I selected “Multiple server install with MAAS”. The next screen provided the option to Enlist with the maas-master MAAS Server, so I happily selected that option when the machine suddenly SIGKILLs all processes then powers off. The victory was in the dashboard though, as it now reflected 1 node!

I continued doing this for each of the “maas” VMs until all were registered in the maas-master dashboard. Unfortunately, during installation, of one of the nodes lost my naming scheme (I was trying to do maas-node0, maas-node1, … for each MAAS node) and ended up naming one of the maas2, which threw off the naming for the rest of the nodes. That aside, all of the initial nodes I wanted to enlist did so without any issues.

Now it was time to get some Juju goodness pushing against these machines. The first thing I did was hunt down my MAAS Key. I stumbled through a few sections of the dashboard before landing in the account preferences. I also noticed a section for SSH Keys which I added my public key to (for good measure). I copied my MAAS Key and created the following stanza in my juju environments file (I couldn’t find documentation on the Juju site for MAAS setup but I found this URL from a screenshot of MAAS testing tools, which lead me to the answer).

environments:
  vb-maas:
    type: maas
    maas-server: http://192.168.5.27:80/MAAS
    maas-oauth: "MY:MAAS:KEY"
    admin-secret: super-secret-made-up-admin-key
    default-series: precise
When I first tried to bootstrap the MAAS setup, I received several errors. The port needs to be specified for Juju to connect to the provider. However, when I attempted to bootstrap again, I received a whole mouthful of errors about 409 CONFLICT. This is when I realized you need to Accept each machine in order for it to be provisioned. I stepped back and started reading the documentation as my nodes wouldn’t commission properly (or at all). It was pretty clear that I didn’t have the DNS set up properly. I recommend reading through the documentation to get a grasp on what you’ll need to do for your network. Once I installed maas-dhcp and configured that package, the ISOs needed to be regenerated to use the updated information. Running `sudo maas-import-isos` remedied this for me. After all that I needed to update each VirtualBox VM to include Network in the boot sequence. To do so, open each VM’s settings, go to System, and make sure the Network boot is checked and at the top of the list.

After doing that, boot each VM and the PXE DHCP should find your MAAS Master and set up the VM properly. Each machine will turn off after successful setup and MAAS Dashboard will update. The end result is quite glorious:

Now it’s really time to get Juju working with these lovely MAAS machines! After several non-starts I created a new account in MAAS Dashboard with the same username as my local user and updated Juju environments to use that MAAS Key. After completing that, I issued a bootstrap:

juju bootstrap

and checked the dashboard after the command completed.

The dashboard now shows one of the nodes allocated to Juju for bootstrapping. I had to manually start each VM, as for some reason they don’t respond to Wake On Lan. However, my goal of using Juju to deploy to MAAS was fulfilled. There is definitely room for improvement with the experience, but I have high hopes when we start throwing bare metal at MAAS.

  • Dave Walker (Daviey)

    GREAT write up Marco!

    Regarding the enlisting.. If you pxe-boot a fresh machine, it will automatically enlist.. There isn’t a need to use the iso manual process (unless you want to!)…

    But really, this is great stuff. If you wanted to migrate this to the wiki, i’d be overjoyed.

    Thanks again!

    • https://www.google.com/accounts/o8/id?id=AItOawl6URXjaXMSmzpvI0tBCAks24jjDbBTeAg Marco Ceppi

      Hi Dave! I realized that later on (Which is why the node list increased by two half way through) but I wasn’t sure which was the preferred method. Point me to a wiki I’d love to instill my experience to help others.

      • jorge
        • Mario

          Hey! Thanks for the tutorial. But for successful PXE booting and enlisting, don’t you need to do “sudo apt-get install maas-enlist tftpd-hpa” on the maas server? I could not find this hint in this tutorial, but it was needed for my setup.

  • Pingback: Ubuntu developers: Marco Ceppi: Juju, MAAS, and VirtualBox | Linux-Support.com

  • Tonny

    Hi Marco,

    How were you able to get the VMs to PXE boot? I installed maas-dhcp and ran sudo maas-import-isos afterwards. Then I changed my VMs to have network at the top of the systems list. My nodes are still not being PXE booted. Do I have to start any specific processes? Just trying to figure out if you left out anything.

    Thanks,
    –Tonny

    • Mike

      Hey Tonny. Run ‘sudo dpkg-reconfigure maas’ again, ensuring that you’re entering in the local, private IP address. See the WIKI page referenced above for details.

  • Pingback: Ubuntu Weekly Newsletter Issue 267 | Ubuntu Linux FAQs

  • Kevin

    Hi this has been a great tutorial but I have only got as far as seeing nodes in my dashboard. I wondered if somebbody could point me in the direction of a good tutorial on setting up PXE boot as this is something I have no experience with. Thanks in advance!

    Kevin

    • https://www.google.com/accounts/o8/id?id=AItOawl6URXjaXMSmzpvI0tBCAks24jjDbBTeAg Marco Ceppi

      The problem with VirtualBox is that while PXE boot works, Wake-on-LAN (WoL) does not. So in VirutalBox you just select Network as one of the boot options in the VMs preferences an d move it to the top. The downside is that MaaS can’t turn these machines on at will, you’ll have to manually start them up then PXE boot takes over.

  • haru

    I’m trying to use virtual box. I’m using your setup tutorial. Two questions about the IP address. Are you using the IP that a router would give you? Second question are you using multiple virtual servers? Right now, the setup i’m following is 1024mb and 16 gbs. Is that enough?

    • https://www.google.com/accounts/o8/id?id=AItOawl6URXjaXMSmzpvI0tBCAks24jjDbBTeAg Marco Ceppi

      I’ve been using the IP address the router assigns to each VM, and each node (plus the master) is it’s own VM – each with 8GB disk and 512MB RAM

  • HARU

    I’m doing the juju part of the tutorial. environments.yaml file. That needs to be when you are as superuser correct? I’m pretty it is…I’m just double checking. if that is case, I may get this running tonight.

  • Kevin

    I have got two nodes appearing on my dashboard. However after clicking ‘Accept and Commission’ I then started up the two nodes and got ‘IP-Config: no response….’ Can anyway enlighten me as to where I might have gone wrong? Many thanks

  • Dang Anh Tuan

    Hi Macro,
    Can you deployed MySQL anđ WordPress? Please send me your tutorial

  • Haru

    Hey Marco,
    I’m following the tutorials. I wrote my environments.yaml file exactly like the tutorial but I keep getting this error message: Bootstrap aborted because file storage is not writeable: The supplied storage credentials were not accepted by the server. What do you think the problem is? What are some solutions to the problem…Thanks

    • nocontrol

      I have the same problem. Did you find a solution?

      • nocontrol

        Never mind, just misinterpreted the line: “Replace ${maas-api-key} in the maas-oauth line with the API key you copied earlier. Don’t leave the ${ and } behind; replace everything within the quotes.”
        I thought you should only edit the text inside the curlybrackets, and let the $ stay, that was not the case…

  • raj

    Hi…. gr8 tutorial and followed the same. But i am getting error in the bootstrap and the error was unable to create file storage for environment and aws-access-key-id…. please let me the problem where i gone wrong…. many thanks

    • https://www.google.com/accounts/o8/id?id=AItOawl6URXjaXMSmzpvI0tBCAks24jjDbBTeAg Marco Ceppi

      Make sure you fill out the environments.yaml file like I’ve mentioned above. Since you’re getting aws-access-key-id errors it means it’s not setup to talk to MaaS

  • SoftDev

    Hey, I am having trouble configuring the DNS part. Can you provide some insights into that. My host machine(eth0) is connected to a network, but I don’t have control over the DHCP server. My MAAS-master and nodes are however able to get IPs, but the nodes never get comissioned. Status: comissioning. Typically, how long does it take to comission ?

  • raj

    Thanks for the reply…. I followed the same steps as mentioned above but after the command juju bootstrap i’m getting error like error: Environment configuration error :/home/.juju/environment.yaml: environments: expected dict, got none plz let me know the solution….. many thanks…

  • James

    Good tutorial! One question is on the networking issue. If you leave it bridged than any other PC on that network will ask the DHCP server for an IP right? How could this be set up so that the master only serves IPs to the VMs? Thx in advance!

    • chen shu

      In my company, we have a dhcp server. Because I used bridged network in VirtualBox following your document, all physical and virtual machines are in one IP range(from 10.112.18.0 to 10.112.18.x).
      I don’t know how to configure mass-dhcp!
      Using the above range? Could you tell me how did you configure it?

  • Tomas

    I have the same problem as RAJ. When i run juju bootstrap , this error occure: Environments configuration error: /home/crash/.juju/environments.yaml: environments: expected dict, got None

    I dont know what does it means. And i didnt find solution. Do someone know what to do?

    • https://www.google.com/accounts/o8/id?id=AItOawl6URXjaXMSmzpvI0tBCAks24jjDbBTeAg Marco Ceppi

      Formatting is vital, indents need to be two spaces and not tabs, as well as a few other things. If you’re having a problems with getting Juju to accept the setup consider asking on Ask Ubuntu (http://askubuntu.com/questions/ask?tags=juju) include the error and your current configuration file.

      • Tomas

        I made a new environments.yaml and the error is solved.
        Thanks very much for your reply.

      • priya

        ya you are right but you may get your solution from http://www.studyingon.com

  • Ahsan

    Hey macro , ive made environment file exactly the way it is written on your blog and ubuntu webpage. i am getting this error , please help

    clusteruser@cluster:~$ juju bootstrap
    2012-08-04 22:19:24,918 INFO Bootstrapping environment ‘maas’ (origin: distro type: maas)…
    2012-08-04 22:19:26,138 ERROR No matching node is available.

    • Stephan

      I am getting the same error. Any solutions?

      • Romain

        You have to make a new node and enlist it in MAAS with PXE, Accept and commission it but not start it.
        In the web interface the new node should be at the step “Queued”
        After that retry with juju

  • Swami

    Its started now. environment file changes works for me.
    environments:
    vb-maas:
    type: maas
    maas-server: http://192.168.10.50:80/MAAS
    maas-oauth: “KEY”
    admin-secret: nothing
    default-series: precise
    @cloud:~$ juju bootstrap
    2012-09-20 10:17:57,485 INFO Bootstrapping environment ‘maas’ (origin: distro type: maas)…
    2012-09-20 10:18:01,028 INFO ‘bootstrap’ command finished successfully

    Thanks for the post. Great work.

    -swami

    • genius group

      thnx

    • Alaa Badri

      what should the admin-secret to be i thing you type nothing for example i need to know where i can get the admin-secret

  • aki

    Nice post friend. This page below also gives more details on how to install ubuntu on virtual box

    http://cybrwrld.blogspot.com/2012/10/feel-ubuntu-ubuntu-on-virtual-box.html

  • Romain

    I’ve a solution for PXE boot

    First configure the dhcp

    After put network as first boot device for the maas VM and for the nodes VM and check if the nodes and the maas VM have Attached to Bridged Adapter in Network
    Change the Adapter type from Intel PRO/1000 MT Desktop to PCnet-FAST III
    Start the maas VM
    Start the nodes and it should work
    (I had the same problem that a lot of persons here and it resolves the problem)

  • Pingback: Cloud computing en la nube.13

  • George Masters

    Excellent tutorial! Has anyone succeeded in setting up a MAAS server and nodes using a NAT rather than a bridged NIC? I want to be able to do this on a portable machine that I use on multiple networks, two of which I don’t own.

    • SoftwareExplorer

      This should be possible. I would install the bridge-utils package, and then make the interfaces for the VM’s a host-only interface. I would create a bridge (sudo brctl addbr ). Then I would make sure the host side of the interface is up (sudo ifconfig up), and then add it to the bridge (brctl addif ) (you’ll have to do this for each VM). This will create a virtual switch with your VM’s plugged into them. You may have to run ‘sudo ifconfig up’. Add an IP for your computer on it’s connection to this switch: ‘ip addr add /24 dev ‘.

      Then if you enable routing on the host (edit /etc/sysctl.conf to have net.ipv4.ip_forward = 1 and then run sudo sysctl -p). This will make your computer route for other machines (including stuff on your ‘switch’).

      If you have UFW going, edit /etc/default/ufw (I think) to have the default forward policy of ‘ACCEPT’, and restart ufw (sudo ufw restart).

      Finally, add the nat rule: ‘iptables –table nat –append POSTROUTING –out-interface -j MASQUERADE’

      That was mostly from memory, so it’s not tested. But it should do it. (I’ve done similar stuff with KVM instead of Virtualbox and it’s worked).

      • SoftwareExplorer

        You will probably have to go into the MaaS UI settings and then the region controller and set the router to the IP address you set for your computer on the bridge interface.

  • cloudk

    From where did u access the MAAS Web interface?? From where did you get the browser when ubuntu server is console based? Did you try to access it from the OS in which the virtual box was installed or you setup another virtual machine(Ubuntu/windows) besides Ubuntu server in the virtual box? This is really confusing!