POSTS
Setup your MacOS (or other OS) development team with Ansible
By Carlos Buenosvinos
- 2 minutes read - 398 wordsImagine that a new developer joins your team, installing everything needed for developing, including the application being developed is not an easy o fast task. I’m sure you have a wiki process, a markdown file in your repo or something similar. For a normal PHP web application, there is so much to do: installing PHP, composer and global tools, npm and/or bower, mysql, redis, etc. or setting up you Docker/Vagrant environment if you choose an isolated environment.
I remember when GitHub released Boxen in 2012. A tool for managing Mac development boxes with love. It’s based in Puppet. The main idea is use Puppet for provisioning not remote machines or servers but you local Mac. Let’s see a silly idea about how to do it with Ansible.
tl;dr
For set up MacOS local development environments, you can use Ansible with local connections (ansible_connection=local in your inventory file) and the homebrew module.
Introduction
On a Mac, and also on other OS, there are different options for developing: local development with built-in web servers, Docker or Vagrant. The first one is the fastest one, but has its pitfalls (polluting your local environment with things you need for a specific project, routing tricks or lack of HTTPS support), the second one is still fast if you’re not in MacOS (that uses a VirtualBox machine for running Docker due to its lack of containers support) and the last one, the more flexible in all the environments but slower in performance due to its low sharing capabilities (Vbox Share folders, NFS, or Rsync).
Set the environment up
What it’s a common issue is set up everything on your machine. You can do it step by step following a guide somewhere in your repo or wiki, or help the process using a provisioning tool such as Ansible. The trick is using Ansible, with local connection (in order to perform all the tasks in your local machine) and the Homebrew module. Let’s see a silly example about how to use all of this.
Inventory File
Playbook
And now, you can just run your environment with:
Conclusion
You know, automate all the things. Including also your local development environment. If your playbook is checked in your project repository, a new developer just needs to install brew, ansible, checkout the project and run the playbook. I prefer Vagrant, but in some cases, this trick can be useful. Hope it helps!