I think of this more like the most direct and reproducable approach I could think of. You could build off of this and automate a lot of the installation tasks with a vagrant provisioner like puppet, chef, saltstack, or ansible. In my case I like to use Ansible which is written by Michael DeHaan who wrote func back in the day. I loved func and ansible feels more at home to me.
Installing and configuring MAAS
- Ubuntu Precise 12.04 (latest updates)
- vagrant 1.3.x
- vagrant lxc
% sudo apt-get install lxc
Download and install vagrant via vagrant install link
% wget http://files.vagrantup.com/packages/0ac2a87388419b989c3c0d0318cc97df3b0ed27d/vagrant_1.3.4_x86_64.deb % sudo dpkg -i vagrant_1.3.4_x86_64.deb
% vagrant plugin install vagrant-lxc
Install a lxc supported vagrant box
% vagrant box add precise64 http://bit.ly/vagrant-lxc-precise64-2013-09-28
Create a Vagrantfile
Add the following into your Vagrantfile
Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.provider :lxc do |lxc| lxc.customize 'cgroup.memory.limit_in_bytes', '1024M' lxc.customize 'cgroup.devices.allow', 'b 7:* rwm' lxc.customize 'cgroup.devices.allow', 'c 10:237 rwm' end end
Cache sudo password
# Load up visudo and append the following % sudo visudo Defaults !tty_tickets
Run the vagrant box
% vagrant up --provider=lxc
SSH into the vagrant box
% vagrant ssh
Add additional repository
A ubuntu-cloud archive exists for providing the latest juju, maas, etc bits on precise. Enable this to get the latest MAAS versions.
vagrant@precise-base:~$ sudo apt-get install -qy ubuntu-cloud-keyring </dev/null vagrant@precise-base:~$ sudo tee /etc/apt/sources.list.d/cloud-tools-precise.list <<EOF deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/cloud-tools main deb-src http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/cloud-tools main EOF
Update the repository and install MAAS
vagrant@precise-base:~$ sudo apt-get update vagrant@precise-base:~$ sudo apt-get install maas maas-dhcp maas-dns
Create your MAAS superuser
vagrant@precise-base:~$ sudo maas createsuperuser
It's a pain doing this many times over, pulled this tip from Bojan Mihelac
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'pass')" | sudo maas shell
Login to your MAAS UI
In your web browser visit the IP (something like http://10.0.3.32/MAAS) of the vagrant box to log into your MAAS instance.
Import your boot images
Once logged in click on the cog icon in the top right hand corner.
On the settings page just under Cluster controllers click the import boot images button.
This will take awhile to run so maybe go get some coffee.
If you want to speed things up a bit edit
/etc/maas/import_pxe_files with the following
vagrant@precise-base:~$ cat /etc/maas/import_pxe_files # This file replaces an older one called import_isos. Include that here for # compatibility. if [ -f /etc/maas/import_isos ] then cat >&2 <<EOF Including obsolete /etc/maas/import_isos in configuration. This file has been superseded by import_pxe_files. Please see if it can be removed. EOF . /etc/maas/import_isos fi RELEASES="precise" ARCHES="amd64/generic" LOCALE="en_US" #IMPORT_EPHEMERALS=1
Cluster interface configuration
Once the boot images are done you are ready to configure one of the network interfaces to be managed by MAAS. Click on the edit icon under Cluster controllers. In the Edit Cluster Controller page click on the edit icon next to the interface you'd like to configure. In this case I am using eth0.
On the next page titled Edit Cluster Interface we are going to set eth0 to manage dhcp and dns along with entering the ip information for our network. Since vagrant is using 10.0.3.32 as its IP we'll set the rest according to that.
DBusException error with avahi
DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.freedesktop.Avahi': no such name
Comment out rlimit-nproc in
/etc/avahi/avahi-daemon.conf, then start the service. See here for more information on this issue and user namespaces in lxc.
vagrant@precise-base:~$ sudo service avahi-daemon restart
Failing to mount ephemeral image
precise-ephemeral-maas-amd64.img mount: Could not find any loop device. Maybe this kernel does not know about the loop device? (If so, recompile or `modprobe loop'.) Tue, 01 Oct 2013 19:33:58 +0000: failed to mount /tmp/uec2roottar.MmKLTg/precise-ephemeral-maas-amd64.img failed to create root image failed to prepare image for precise/amd64
Per this post
- Rename lxc-container-default to lxc-container-default-with-loops
- Add an entry:
"mount -> /tmp/*/*,"or matching the source node, fstype,
% sudo /etc/init.d/apparmor reload
- Edit your container's configuration and set lxc.aa_profile to lxc-container-default-with-loops
- Note: this would be
lxc.customize "aa_profile", "lxc-container-default-with-loops"in your Vagrantfile
- Note: this would be
- Restart your container
That's pretty much it! Whether this is actually useful remains to be seen. Nevertheless, this was a good learning experience for me. :) Oh and if you read this far down I did automate most of this which you can find over at my github vagrant-maas repo.
% git clone git://github.com:battlemidget/vagrant-maas.git % cd vagrant-maas % vagrant plugin install vagrant-lxc % vagrant box add precise64 http://bit.ly/vagrant-lxc-precise64-2013-09-28 % vagrant up --provider=lxc --provision-with ansible % vagrant provision