Skip to content

Local BOA with Vagrant

Theodoros Ploumis edited this page Jun 6, 2017 · 30 revisions

Example of using Vagrant

Basic steps

  1. Read all the instructions here before starting.
  2. Do follow instructions from Docs: Installing BOA locally. Do not try other options. I did it and I regret it! If you want to use the same octopus name with the live server be careful here as you have to us this name on the installation commands.
  3. Run installer only with up-stable option. Hope you have the same option on the live server (if you need synchronized servers). Eg boa in-stable local my@email.
  4. Use Debian 8 Jessie 64x vagrant box (see the latest BOA Recommended). This must be as more as it can be a vanilla box. No ruby, no puppet, completely vanilla. Do not run updates on vagrant up.
  5. Use at least 2GB RAM for the vm.
  6. Important. SSH user must be root after installing BOA! If you use default user vagrant you may have errors because BOA does not allow other users to access folders such as /tmp. These folders are used when you run vagrant up. So initially run vagrant up as user vagrant (default). Login into the vm and change the root password.
# On host
vagrant up
...
# On host
vagrant ssh
...
# On guest
$vagrant@XXXXXX:
# Become root
$vagrant@XXXXXX: sudo -i
# Change root password to 'vagrant'
$root@XXXXXX: passwd
...
# Download BOA script
$vagrant@XXXXXX: cd;wget -q -U iCab http://files.aegir.cc/BOA.sh.txt;bash BOA.sh.txt
...
# Run boa installer
$vagrant@XXXXXX: boa in-stable local my@email
...

Then stop the vm (vagrant halt), edit the Vagrantfile and uncomment these lines to enable root login.

  #config.ssh.username = "root"
  #config.ssh.password = 'vagrant'
  1. Do NOT use Vagrant Synced folders. You could use nfs with vagrant-bindfs so you can change owner/permissions but I recommend you to not sync files at all with Vagrant. You may have a too many problems with permissions and owner of folders. Use sftp instead. If you insist to use nfs you should only sync the folders of /modules, /themes, /libraries of each project and not the folders of group www-data.
  2. Add the BOA entries to your hosts file (eg for Debian, /etc/hosts). You may also use a vagrant plugin like https://github.com/cogitatio/vagrant-hostsupdater to do this automatically.
# Local BOA running on host ip 192.168.44.42
192.168.44.42 aegir.local
192.168.44.42 sub.aegir.local
192.168.44.42 o1.sub.aegir.local
192.168.44.42 chive.aegir.local

Optional steps

  1. Disable changing passwords after every update. See how to at https://github.com/omega8cc/boa/blob/master/docs/ctrl/system.ctrl.
  2. Disable CSF (firewall) from .barracuda.cnf _XTRAS_LIST if exists there. It will not be enabled by default.
  3. Disable backups on all of your local Aegir Octopus user-accounts and websites. Default vm size is 40GB and you may run out of space.
  4. Change local BOA timezone (eg using command tzselect or dpkg-reconfigure tzdata as root) so local server reports match your local time.

Vagrantfile

Here is an example Vagrantfile with the above instructions applied. Notice that no provisioner is included.

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  # BOA needs a vanilla box, eg the latest debian: https://atlas.hashicorp.com/debian/boxes/jessie64
  config.vm.box = "debian/jessie64"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  config.vm.box_check_update = false
  config.vbguest.auto_update = false
  
  # Set guest OS
  config.vm.guest = :debian
  
  # IMPORTANT! Enable login as root after running the BOA installer.
  # Because BOA will remove vagrant user fro the system!
  #config.ssh.username = "root"
  #config.ssh.password = 'vagrant'

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 3306, host: 3306

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # Example of local ip: 192.168.44.42
  config.vm.network "private_network", ip: "192.168.44.42"
  # plugin https://github.com/cogitatio/vagrant-hostsupdater
  config.hostsupdater.aliases = [
    # aegir installer will create these entries on host machine
    'aegir.local',
    'sub.aegir.local',
    'o1.sub.aegir.local',
    'chive.aegir.local',
    # Any sites that may be installed via aegir. Eg.
    #'dev.example.com',
  ]

  # Provider-specific configuration so you can fine-tune various backing providers for Vagrant.
  config.vm.provider "virtualbox" do |vb|
  	vb.memory = "2048"
  end
  
end

Common Issues

  1. DNS after System Updates/Upgrades.

After system updates/upgrades local BOA may loose the DNS settings for Aegir master as also as for the additional software. If you have errors like:

BOA [09:10:40] ==> UPGRADE A: FATAL ERROR: DNS looks broken for aegir.local
BOA [09:10:40] ==> UPGRADE A: FATAL ERROR: Aborting AegirSetupA installer NOW!

or

BOA [09:11:44] ==> ERROR: o1.sub.aegir.local doesn't point to your IP: 127.0.1.1
BOA [09:11:44] ==> Please make sure you have a valid A record in your DNS
BOA [09:11:44] ==> It is also possible that DNS change didn't propagate yet

add a DNS entry at the BOA /etc/hosts file (assuming you use a Debian vagrant box):

127.0.1.1 aegir.local o1.sub.aegir.local chive.aegir.local
  1. 403 error on Chive domain (https://chive.aegir.local)

If you get an access denied error (403) while trying to access Chive domain on local BOA you may need to alter the chive vhost configuration file at /var/aegir/config/server_master/nginx/vhost.d/chive.aegir.local and add an allow all; entry. Notice that in order to access Chive you must be logged into the local BOA with ssh otherwise you will get a 403 error anyway (See more at https://omega8.cc/how-to-use-chive-manager-323).