Vagrant and Ansible setup with VLAD

I've been toying around with VLAD, a VM setup for Drupal.https://bitbucket.org/philipnorton42/vlad . Here are my notes for doing this on a Macbook pro running Mavericks.

  • Install XCODE developer tools, no need to install the full XCODE
    • This may not be necessary, but the tools are good to have anyway.
  • Install Vagrant. Do this by visiting the main vagrant website and using the installer.
  • Install Vagrant extras:
    • vagrant plugin install vagrant-cachier
    • vagrant plugin install vagrant-triggers
  • Install Ansible. Even though there are other ways, use PIP like it says in the README for VLAD.
  • Clone the VLAD repo into a new folder, ie git clone https://bitbucket.org/philipnorton42/vlad.git ~/vagrant/vlad
  • Copy the new directory that was just cloned into a new folder, ie ~/vagrant/examplevm
  • Copy ~/vagrant/examplevm/vlad/example.settings.yml and rename it to ~/vagrant/examplevm/vlad/settings.yml
    • Change webserver_hostname, boxipaddress, boxname
    • The following components are not really needed and/or I couldn't get them to work :)
      • adminer
      • imagemagick
      • munin
      • pimpmylog
      • redis
      • sendmail
      • xhprof
  • Change ~/vagrant/examplevm/Vagrantfile :
    • up the memory limit to 2048
    • make sure each synced folder's id is different. For example, use "id: "vagrant-docroot" and "id: vagrant-aux".
      • by default, both synced folders have the same id, vagrant-root, and it seems like only the second folder gets synced, in this case 'aux'.
  • cd into ~/vagrant/examplevm and run vagrant up

Add more vhosts

By default, you'll only get one virtual host. To add more, here's how I do it.

First, in Vagrantfile, add these lines:

  # Creates nfs shared folders for vhosts.
  # Each is mapped like this: /var/www/[vhost]/docroot => /[VAGRANT DIRECTORY]/[hvost]/docroot
  vhosts = [ "examplesite", "examplesitetwo"]
  vhosts.each do|n|
    config.vm.synced_folder vagrant_dir + "/#{n}/docroot",
      "/var/www/#{n}/docroot", 
      id: "#{n}-docroot",
      :nfs => nfs_setting,
      create: true
  end

Then, vagrant ssh into the server and add a vhosts file:

sudo touch /etc/apache2/httpd-vhosts.conf

Add this to /etc/apache2/httpd-vhosts.conf:

<VirtualHost *:8080>
  ServerName devlocal.examplesite.com
  DocumentRoot /var/www/examplesite/docroot
</VirtualHost>
<VirtualHost *:8080>
  ServerName examplesitetwo.d8.com
  DocumentRoot /var/www/examplesitetwo/docroot
</VirtualHost>

Finally, add this to /etc/apache2/httpd.conf

Include /etc/apache2/httpd-vhosts.conf

Article Type

General