linux tux

It’s been a while since my last article, my new awesome job is making me go deep in it, and I have little to no free time to write here, my apologies! :)

Let’s get back on the track with an article about one of my favourite automation tools, Ansible, and how to install it on your Linux workstation!

What is Ansible?

Ansible is an open source automation tool that allows the users to run commands and execute lists of tasks.
You could argue that this is an universal definition of an automation tool, and you are totally right, but let me introduce you the core features of Ansible.

Ansible is agentless.

Being agentless means that remote hosts doesn’t have to install and run resource-consuming agents just to keep the connection with the control node up and running.
The resources of your machines are safe, and will never be wasted anymore. Ansible uses SSH to connect to the hosts you need to connect to, so little to no configuration is needed on the remote site.
The one and only requirement that Ansible has, it’s Python (2.6+) installed both on the control node and managed hosts. This means that all you have to do is to provide a python environment on your machines and be ready to deploy your awesome automation playbooks!

Ansible provides easy-to-read scripting

Ansible’s ‘lists of tasks’ are called Playbooks, which are writtend in an human readable format, YAML (reference to yaml).
Below you can find a quick sample.

This is as simple as it seems, it runs on localhost, and executes a task, printing a debug message on your screen.

This means that you will never have headaches anymore trying to understand complex and unreadable code and configuration files to get your stuff working, nice isn’t it?

Ansible is a swiss knife, highly customizable and doesn’t depend on the platform

Since it is agentless, it has no bounds to any particular platform or technology, plus it provides two core components that make it unique and potentially limitless.

Plugins

Managing core features, like connections, privilege escalation, flow control (loops, conditions). Written in python, they can be customizable and extended with a little knowledge, allowing close to infinite possibilities of covering what is not covered at the moment by the out-of-the-box plugins!

Modules

Modules manage the core functions of Ansible, and represent its collection of tools that provides all the functionalities that allow the operator to run commands, highly customizable via attributes and options.

Plugins and modules are written in Python, this means that anyone with Python knowledge can modifiy and/or create them. Below you can find some references to official documentation regarding how plugins and modules are implemented, and how to start creating one on your own!

Ansible Doc – Developing modules
Ansible Doc – Developing plugins

Being written in Python is the reason why we need to have Python installed to run them!

Ansible doesn’t have a GUI, but is mostyly command-line based, and it is available for Linux/MacOS/Windows.

Installing Ansible

Let’s see how we can install Ansible on our Linux box!

This basically depends on the distribution you are running.

It is included in most distribution’s base repositories, so you can just use your preferred packet manager to install it.

Since it is agentless and will nost store any additional information, installation will just provide the files needed by Ansible, and the executable files that will run. No databases, no useless daemons or agents.

On Fedora:

Copy to Clipboard

On RHEL and CentOS:

$ sudo yum install ansible

On Debian

Copy to Clipboard

After you installed it, verify your installation typing:

Copy to Clipboard

Now that you are good to go, I let you below some references to start moving your steps in Ansible world. Maybe in another post we will see how to start creating our own playbooks!

If you liked the article, please share it!