In start-up culture, there is often everything to do. Things we like to do, things we like less. Things that we know how to do, others that we have less control over. My job is development, and I’m much less comfortable when it comes to managing production and therefore an infrastructure.
I recently reviewed in depth the infrastructure that I manage to set up redundancy. I didn’t see myself configuring the servers the same manually, first because it takes time and then because they just wouldn’t have been the same…
So I turned to machine management automation tools and quickly chose Ansible. And I must admit that it is a real crush after I got the Ansible certification.
Simple and well thought out:
As with all tools, it is a bit difficult at first because you have to understand the concept. But Ansible is simple. Once you understand the following 3 things, you have everything you need to get started:
How to declare the infrastructure inventory (inventory, machines and groups of machines)
How to model the actions (playbooks) that Ansible should play on machines
How Ansible connects to machines
Ansible is very easy to install and can be run from its own machine. The only constraint is that this machine must be able to connect to the various servers in SSH via a key (without asking for the password).
A rich ecosystem:
Ansible provides a rich set of modules to perform the most common tasks very easily. Install a system package? There is of course what it takes. There is also everything you need to install an npm package, restart a service, or modify a configuration file. The documentation is pretty well done and contains quite a few examples.
Easy to handle:
You can quickly configure a blank machine without accessing it manually via SSH. And not only from elsewhere! Once the machine is installed, Ansible is able to upgrade it. Indeed, an Ansible scenario is not a simple succession of instructions as we would do in a script. Rather than defining commands, we describe states. For example, I want this package to be installed or that such file does not exist or contains such lines. All Ansible modules work on this principle and act only if there is something to do. And if the expected result is already there, so much the better there is nothing to do. Handling that manually in a script is very difficult. With Ansible, it’s automatic!
Designed for developers:
With Ansible, it’s a bit like describing your infrastructure in code via DSL (based on YAML in this case). For a developer, it’s cool because that’s what we’re used to doing, and incidentally, we can version this configuration. We are also faced with similar problems, in particular the reuse of certain parts. Through roles, Ansible offers an elegant and effective solution for factoring common bricks and, again, the developer finds it easy because it is very similar to the programming concepts that we use on a daily basis.
Manage multiple machines simultaneously:
Ansible playbooks are operations to be applied to a set of machines. When we launch a playbook, Ansible will connect to all the servers concerned in parallel and play the different stages of the scenario.
It is thus possible to configure a new machine in a single command. Or can also apply changes to all or only part of the machines in the par, for example running the configuration playbook of a database machine on all the machines in the corresponding group.