How to Install Ansible

· Updated · 1 min read · Ansible Tutorials

Install Ansible for Configuration Automation #

Ansible is a powerful open-source automation tool that helps you automate IT infrastructure and application deployment. It is written in Python and is agentless, meaning it doesn’t require any software to be installed on the machines you want to manage. Ansible uses a simple YAML-based language to define the desired state of your systems, and then it automatically takes the necessary steps to achieve that state.

Ansible architecture: the control node runs playbooks against the hosts in the inventory over SSH, with no agent on the managed nodes
How Ansible works: a control node and agentless managed nodes

Ansible requires a Control Node that connects with the managed hosts through SSH to make the desired changes. Installation is done in the Control Node and this node installs the needed packages in the managed hosts when needed.

Install Ansible on the Control Node #

The Ansible Control Node is the central machine within an Ansible environment responsible for executing automation tasks on managed hosts. It acts as the brains of the operation, housing the Ansible software and managing the communication and execution of playbooks.

To install follow the official installation instructions or run the following apt commands for installation on Ubuntu.

$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt update
$ sudo apt install ansible

Ansible can also be installed with pipx, which keeps it isolated from the system Python and gives access to the latest release:

$ sudo apt install pipx
$ pipx install --include-deps ansible

Check Ansible Installation #

Check that Ansible has been installed.

$ ansible --version
ansible [core 2.16.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Next Steps #

Check the tutorial How To Use Ansible and Terraform Together.

#Ansible #OpenTofu #Terraform