As a devops consultant, I have worked with
ansible quite a bit. Following the principles of infrastructure as code and with the motivation to automate as much infrastructure work as possible, many of our configuration are automated and manage as normal code, we commit them with
git and even run yaml syntax check in our ci/cd pipeline.
One of the configuration scripts I did was for automating the configuration of the elastic stack.
This script is availabe at my github repo, https://github.com/Misterhex/ansible-elk
This script configure:
- elasticsearch cluster with N number of nodes.
- metricbeats on all compute nodes.
- import default dashboard for metricbeat
Below is the main playbook file
plays that will run when executed,
plays maps to
Roles are basically recommended encapsulation of a series of
steps that invoke ansible
Modules are built-in idempontent functions that configure the target servers. Servers are grouped and defined in
inventories, they are defined in an
Below is an example inventory file:
Running the playbook
To run the playbook, it is as simple as:
ansible-playbook -i inventory-sample site.yml
In conclusion, ansible is a simple yet awesome tools for automating configuration of softwares/services. Get started with installation here.