Bedrock Vagrant/Ansible released

Thanks and double thanks for the box :smile:

@swalkinshaw I’m a bit confused. How is this suppose to work exactly? Does cloning the bedrock/ansible and running vagrant up give me a devbox with wordpress and everything needed. Instead wordpress should already be downloaded somewhere before? as here ?

You need to download/clone Bedrock first and make sure the paths in the example Vagrantfile are correct relative to all your folders.

@swalkinshaw Did you get a chance to create an example Vagrantfile showing how to provision to DO? Im about to take the plunge myself so any help would be very much appreciated.

Trying to get this to work with the new box… for some reason I’m getting the error when I’m running the ansible provisioner. I recently upgraded to Mavericks but I cannot find anything about needing to change anything with ansible or how to fix this error… any ideas? I’ve been googling this error and coming up with nothing about how to change the path for ansible. I’ve verified it’s installed with homebrew and up-to-date.

==> default: Running provisioner: ansible...
The executable 'ansible-playbook' Vagrant is trying to run was not
found in the PATH variable. This is an error. Please verify
this software is installed and on the path.

UPDATE: I needed to do a brew uninstall ansible and then re-install it. For some reason brew update was not upgrading ansible to it’s latest version. After re-installing I was able to access it via the command line also with ansible --version(1.6.1) so I know it’s working now.

Performing a vagrant up now runs through the process fine.

I’ve done it with this Vagrantfile:

You need this plugin installed: and the proper DO env vars set up as seen in the Vagrantfile for api keys etc.

But it requires more configuration that I don’t have right now. The prod box references a new prod.yml playbook instead of the normal site.yml. It’s basically the same but doesn’t run the wordpress-sites role.

So the steps would be something like this:

  1. Run vagrant prod up --no-provision
  2. Create a prod specific prod.yml playbook with the roles you want
  3. Create a new hosts file with a [wordpress-server-prod] group and the DO ip/host
  4. You could move the group_vars/all to be env specific at group_vars/wordpress-server-prod and group_vars/wordpress-server if you only want those vars to apply to each server
  5. Run vagrant prod provision
  6. Update Capistrano configs with the correct prod ip/host
  7. Run cap production deploy

The steps are something like that…

Honestly I don’t think production servers should be managed with Vagrant. Maybe if you want a remote dev server. I’d probably just set up the servers manually (if you only have 1 per site or 1 total) and then run ansible-playbook -i prod.yml hosts manually.

Thanks for that Scott. That makes sense will give it a go for a remote staging/dev server. For production are you saying essentially set up the server manually but provision it with ansible?

Correct. Then you can look into just doing everything with Ansible. It has a built-in Digital Ocean module to manage servers.

If I wanted to have more than one site on the Box, how would I change the hosts file on bedrock-ansible, /etc/hosts and the group_vars/all file? I tried adding a new IP address for each in the hosts file and the /etc/hosts file but I’m not sure if that’s the correct way… do you have an example of this?

All you need to change is adding another site “item” in group_vars/all. See this Gist:

wordpress_sites is just an array.

The hosts file is the remote servers. So adding another IP/host there actually means you have another remote server/VM.

I downloaded the bedrock-ansible and bedrock repos into the following locations:

I followed the instructions from bedrock-ansible, set the vagrant file and group_vars and try to run ‘vagrant up.’ Everything works as supposed to, the machine boots, mounts shared folders, and then ttys to run provisioner: ansible and I receive the following error message:
The executable ‘ansible-playbook’ Vagrant is trying to run was not
found in the PATH variable. This is an error. Please verify
this software is installed and on the path.

I have tried every variation of adjusting the path:
ansible.playbook = './bedrock-ansible/site.yml’
ansible.playbook = './site.yml’
ansible.playbook = '…/bedrock-ansible/site.yml’
ansible.playbook = ‘…/site.yml’

I am assuming the error has something to do with my path. I made no adjustments to site.yml and have not moved it from the original location. Am I missing something?

That error message just means that the executable ansible-playbook couldn’t be found. Did you install Ansible first? If running ansible-playbook doesn’t work in your terminal, then it won’t work through Vagrant either.

**SOLVED! Thanks again Scott.

Can’t tell you enough how much I appreciate the work you guys do. You guys are revolutionizing developer workflow!

Also - I like the Bedrock and Ansible setup, however, 2 questions.

  1. Have you looked into using Docker vs. Vagrant/Ansible?
  2. Reasons for choosing Vagrant over Ansible?
  3. Future plans for Docker?

Anyways, keep up the good work and NO HURRY in getting back to me. Cheers!!

Glad you’re enjoying everything :smile:

  1. Not too much yet. Docker is awesome but probably not needed in most basic server setups (which WP sites often are)

  2. Well we’re using both of them? Didn’t choose one over the other. Vagrant is meant for development environments so that’s what we’re using it for. And Ansible for server provisioning.

  3. Probably not anytime soon.

The VM that is created is 512 mb. My macbook runs with 8gb ram. - is there a variable I can change to increase the amount of dedicated ram to the virtual machine? at the bottom

See question #3 and my answer in this thread: Php error when app/themes or app/plugins directories are not empty

I’m a little bit confused here–does this mean I can run multiple sites from a single Bedrock Ansible project simultaneously, like one would with MAMP and virtual hosts? If that’s the case, I may be missing something.

Setting up my group_vars/all file as instructed above works until Composer runs, which throws this error:

stdout: Composer could not find a composer.json file in /srv/www/

My Vagrantfile is pretty minimally modified: :private_network, ip: ''
 # config.vm.hostname = '' # This is taken care of via /group_vars/all, right?

 # adjust paths relative to Vagrantfile
 config.vm.synced_folder '../sites', '/srv/www', owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']

My impression was that the synced folder would be your/sites/dir instead of your/sites/dir/ But it doesn’t look like Vagrant is seeing my development files at all. What am I doing wrong here?

Yeah, config.vm.hostname isn’t really needed but should probably be set to something. Could just be or something for identification purposes.

Right now you need to explicitly set up every individual site as a synced folder.

config.vm.synced_folder '../sites/site1', '/srv/www/site1/current', owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']
config.vm.synced_folder '../sites/site2', '/srv/www/site2/current', owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']

Ohh. Duh. Well there’s my problem. I thought I tried adding multiple synced folders and it only found one of them, but it probably failed on the first one because my directory structure was bad.

I’ll try it as soon as I’m back at the ole desk, though I’m strongly considering keeping one VM per project.