Atlantic.Net Blog

How to Install and Configure Ansible on Arch Linux

Ansible is a free and open-source automation tool used for automating administrative tasks on multiple Linux servers. It is an agentless tool and supports Linux, Windows, and VMware cloud servers. It is a simple and lightweight alternative to other automation tools, including Chef and Puppet. It is primarily designed for IT professionals for application deployment, system updates, cloud provisioning, configuration management, and much more.

In this post, we will show you how to install Ansible on Arch Linux.


  • A fresh Arch Linux server on the Atlantic.Net Cloud Platform
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Arch Linux as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Step 2 – Configure Repository

By default, the default repository is outdated in Arch Linux, so you will need to modify the default mirror list. You can do it by editing the mirrorlist configuration file:

nano  /etc/pacman.d/mirrorlist

Remove all lines and add the following lines:

## Score: 0.7, United States
Server =$repo/os/$arch
## Score: 0.8, United States
Server =$repo/os/$arch
Server =$repo/os/$arch
## Score: 0.9, United Kingdom
Server =$repo/os/$arch
## Score: 1.5, United Kingdom
Server =$repo/os/$arch
Server =$repo/os/$arch
## Score: 6.6, United States
Server =$repo/os/$arch
## Score: 6.7, United States
Server =$repo/os/$arch
## Score: 6.8, United States
Server =$repo/os/$arch
## Score: 7.1, India
Server =$repo/os/$arch
## Score: 10.1, United States
Server =$repo/os/$arch

Save and close the file, then update all the package indexes with the following command:

pacman -Syu

Step 3 – Install Ansible

By default, the Ansible package is included in the Arch Linux default repository. You can install it with the following command.

pacman -S ansible

After the successful installation, you can verify the Ansible version using the following command.

ansible --version

You will get the following output.

ansible [core 2.14.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0] (/usr/bin/python)
  jinja version = 3.1.2
  libyaml = True

Step 4 – Configure SSH Key-based Authentication

Ansible uses SSH to connect to the remote server, so you will need to set up password-less key-based SSH authentication for remote Linux hosts that you want to manage.

First, generate an SSH key on the Ansible server with the following command:

ssh-keygen -t rsa

You will get the following output.

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/
The key fingerprint is:
SHA256:vNxc7Y1vQAX7odhmpn1fZq4BdkMpXAh8xBUoflyEDl4 [email protected]
The key's randomart image is:
+---[RSA 3072]----+
|         ..+.**o |
|          +.E..o.|
|         o Bo.+o |
|       .  o *+o..|
|        S  o+B+ .|
|       . + o*+.+ |
|        o o. .+o=|
|              .*+|
|              .o+|

Next, copy the generated key to the remote Linux hosts with the following command:

ssh-copy-id -i ~/.ssh/ [email protected]

You will be asked to provide the remote server password to copy the SSH key.

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

Next, check the SSH password-less login with the following command:

ssh [email protected]

Step 5 – Configure Ansible Hosts

Next, you will need to configure Ansible hosts to define your remote Linux servers.

nano /etc/ansible/hosts

Add your remote server information as shown below:

server1 ansible_ssh_host=your-remote-host-ip ansible_ssh_port=22 ansible_ssh_user=root

Save and close the file when you are finished.

Step 6 – How to Use Ansible

At this point, Ansible is installed and configured. Now, it’s time to check how Ansible works.

Let’s run the following command on the Ansible server to check the connectivity of remote hosts.

ansible -m ping all

If everything is fine, you should get the following output:

Ansible check connectivity of all hosts
To test the connectivity of specific hosts like server1, run the following command:

ansible -m ping server1

You should see the following output.
Ansible check connectivity of specific hosts

Step 7 – Ansible Adhoc Commands

Ansible provides ad-hoc commands to manage remote Linux hosts directly via the command line.

To check the memory usage of all Ansible hosts, run the following command:

ansible -m shell -a "free -m" all

You should see the following screen:
Ansible check memory usage of remote hosts
To check the uptime of all Ansible hosts, run the following command:

ansible -m shell -a "uptime" all

You should see the following screen:
Ansible check uptime of remote hosts
To check the disk usage of all Ansible hosts, run the following command:

ansible -m shell -a "df -h" all

You should see the following screen:
Ansible check disk usage of remote hosts


In this post, we explained how to install Ansible on Arch Linux. You can now use Ansible to provision and manage multiple Linux hosts using Ansible. You can deploy an Ansible server on dedicated server hosting from Atlantic.Net!

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year