Being able to put deploy systems on autopilot can save a company huge amounts of time. Imagine having to update hundreds of sites every time a new security patch is provided. There are great companies who specialize in providing this service to their clients, however these can be costly if you are on a tight budget. A solution that can be implemented and set up to be custom to your specific needs is Ansible. With Ansible and Ansistrano (Ansible + Capistrano) this is possible! The pair together can allow you to deploy patches and updates to hundreds of sites on multiple servers with one simple command. It also gives you the ability to control the deployment and run whatever additional commands you want based on a wide range of variables such as if the site is Drupal 7 or Drupal 8. Following on our previous post on Ansible, here are a few more details on how Ansible does this:
Hosts
The hosts feature of Ansible allows you to set and control your deployment systems on all your servers. In its simplest form, it is a list of hosts you want to run your Ansible Playbook against. A great feature that is regularly used is that you can organize your lists together in groups that you would want to run your Ansible Playbooks on. You can also use lists to have a set of variables that you want to apply to a specific group of hosts. For example, you may have development servers that need to run with different parameters than your production servers. This can save you a lot of time when it’s time to run patches that need to be applied and you want to push them all to your production and development environments all at one time.
Vars (Variables)
The vars feature allows you to set variables that your jobs will need to use in order to run successfully. The best thing about this feature is it allows you to set variables based on any criteria you want; you can set and check for them during any point the playbook is running. For example, we have servers for Drupal 7 sites that are different from Drupal 8 sites due to the fact that each version runs better with different versions on Drush. You can even set vars needed for specific hosts or a group of hosts.
Roles
Think of roles as a set of tasks, variables (either set within the roles or retrieved from the hosts files), files to reference against, and a set of test files to make sure things are running smoothly. The great thing about roles is that they can be reused in other Ansible projects that you have or shared with other members of your team. Roles can also be shared with the Ansible community (or you may discover roles that you may want to use for your own project). This ecosystem makes Ansible extremely modular where you can share or use quality tested roles by others to fully automate your deployment system.
The more an IT team can streamline their deployment process, the more time they have to address bugs. Innovative solutions to mundane tasks increase productivity and benefit customers. Using Ansible for our deployment systems has surely made the maintenance of our projects a lot easier and helped to keep the many libraries that depend on our service happy. But how did we actually integrate this into our process? What were the lessons learned? And how is Ansistrano being used in maintaining over 100 Drupal sites? I’ll answer these questions in a follow up article.