Ansible is a systems automation tool that has proven to be very powerful to our day to day work. It allows us to build more consistent environments as well as manage configurations using a much more structured approach. No more connecting to 10 web servers in a pool to make a configuration change. Make the change in the template and deploy it to all 10 of the servers using Ansible.
I intend on this being the first of what will be a series of posts covering various aspects and examples of how we use Ansible on a daily basis at KISS. In this introductory post I will cover some of the features and use cases of Ansible as well as the basic installation and configuration required to get running. All instructions are specific to CentOS 6.x, however, would be similar for all Unix based OS's that are supported.
While by no means a complete list of features, these are a few that we consider most important.
On CentOS 6, installation is as simple as the following. Note that since Ansible is part of the EPEL repository we pull that in first.
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm yum install ansible
At this point you are ready to start your Ansible project. This can be done in various ways, however, starting out correctly can make a big difference in ensuring your project easily grows with you. We recommend the same format covered in the Best Practices documentation provided by Ansible:
inventory/ - Here we'll define one or more inventory files or install a dynamic cloud inventory script production - Production hosts & groups development - Development hosts & groups ec2.py - The dynamic inventory script for AWS ec2.ini - The configuration file for ec2.py group_vars/ - Here we'll assign variables to specific groups of hosts group1 group2 roles/ common/ - This will be the location of tasks and configuration shared by all hosts tasks/ handlers/ templates/ files/ role1/ - This will be the location of tasks and configuration specific to role1 tasks/ handlers/ templates/ files/ site.yml - This is the primary playbook. playbook1.yml - Playbook specific to a given set of tasks
In this introductory post we covered some of the features and use cases of Ansible as well as how to install it and define a project directory following best practices. Stay tuned for the upcoming posts in this series which will cover Ansible Inventory (Both static and dynamic), common configuration management examples, common build examples, and other advanced topics.