In my company, we decided to switch from Rex (an automation tool) to Ansible. It’s a big task, and not knowing Ansible I had to start somewhere. So I looked up some resources for learning. In this article I will describe the different steps you can follow and some tips to start with Ansible.

What is Ansible and why use Ansible?

First step, I think the best way to learn a new technology like Ansible is to go on the official documentation. Here, the objective is to understand the basic concepts and how it works. We don’t need to go much deeper for the beginning. Most of the time, when you go to the official documentation for a new technologie you are confronted with a lot of information. Sometimes it’s too much. That is why, after reading the official documentation and before I go deeper and try to install Ansible I take the time to watch some videos (video that helped me) and to check blog posts (example). You will have a different approach and maybe a better understanding of a new technology.

To resume, Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code. It includes its own declarative language (DSL: Domain Specific Language) to describe the system configuration.

To install it you can use Pip :

sudo apt install Ansible
ansible --version

Or you can rely on the packages in your operating system. However these packages might be outdated, depending on what OS you are using.

Compared to the other alternative tools, Ansible is agentless. That means you only need a ‘ssh’ connection (by default) to execute Ansible commands on the target server. That is a really interesting approach, because we don’t need to do any effort for deployment in the beginning and you will have no upgrade effort afterwards. Except in the machine who controls everything remotely (the controller).

Ansible work with modules. Each module does one small specific task. Like start a Docker container, create a postgres database, start and stop a service, etc … You have the list of all modules available on the Ansible website. To apply these different modules on the target server, Ansible will copy the module to the remote server and execute it. They will do their work and after that they will be removed.

It shall be pointed out that these modules are idempotent: you don’t specify what to do on the remote system. Rather you specify a state you want to have, and Ansible figures out if any change is necessary, and which change that is. One example: you specify that a certain directory must exist, with specific ownership and permissions. If the directory exists,and has the right permissions, there is nothing to do. If the directory does exist but has the wrong permissions, Ansible will update the permissions. If the directory does not exist, Ansible will create it. This approach allows you to re-run the task over and over again, and ideally nothing changes after the first run. This is called “Idempotence”.

Now you have the fundamentals, there are still a lot of things to know about Ansible. I could go further but it’s not the goal of this article, but I would like to share some links and tips if you want to learn more.

First of all you will find a lot of blogs on the internet about Ansible. Some will just quickly go over generalities, and others will be on more specific topics with in-depth expertise. Depending on your level there will always be a lot of documentation. You will also find a number of videos. Here is a link to a blog post or video for beginners on ansible:

If you have the opportunity, conferences can be a great way to learn new skills. It is important to choose talks that are appropriate for your level of expertise. I see that Ansible has its own conference AnsibleFest.