Setting up Vagrant + Ansible


Just starting on a new project and wanna get going with a Vagrant workflow.
When setting up the VM what components do I need fully utilize Bedrock?

I already saw that this recipe is a good start (ansible-examples/wordpress-nginx at master · ansible/ansible-examples · GitHub) but what other parts are needed? (I guess setting up Composer, Grunt and Capistrano is needed aswell – any leads for recipes to do that?)

On another note – Can I setup a single DO instance for both stage + prod?

I am working on something similar at the moment, but it is not ready yet. I would suggest not to use that specific example as a basis, because it is very old (in ansible terms) and it is not very compartmentalized. Instead go to and get the highest rated/most used roles from there, to install them is very easy. Then build your playbook(s) from that as a basis. I would also suggest looking at the best practice, its a very good resource. As far as I know you don´t need to do anything with the composer, grunt and capistrano connected to ansible, if you use bedrock as a basis (they have taken care of it for you). Just remember to block your .env and other sensitive files in your nginx.conf.

1 Like

Just a note that as of Bedrock 1.1 you don’t need to block sensitive files since we’ve moved the web root files into a web/ directory.

And you should be using Ansible to install Composer and Node/npm/Grunt. Capistrano runs locally so there’s nothing needed on the server except for Git, and you’d probably want to set up a base directory for your deploy_to with the proper user permissions.

edit: You can use a single server for staging and prod if you want. Just a matter of having 2 databases and 2 virtual hosts with different domains.

1 Like

Hm. I set up Vagrant on my DO droplet but wasn’t able to route the traffic to the guest vm.
Any thoughts on that?

Do I need to setup an iptable rule to forward incoming traffic to my guest vm or how does that work?

I’ve never run Vagrant/VM on anything but my local computer, but by default DO boxes don’t have any firewall rules in place I believe. I’d look into and their public network docs.