If you manage multiple Ubuntu computers, performing the same task on every machine can quickly become repetitive. Installing software, updating packages, or rebooting systems one by one wastes time and increases the chances of mistakes.
In this guide, I'll use Ubuntu for the examples, as that's what I use in my environment. If you're using another Linux distribution—such as Fedora, Rocky Linux, openSUSE, or Arch Linux—the overall Ansible workflow is essentially the same. You may only need to adjust distribution-specific commands, such as the package manager or package names. If needed, refer to your distribution's documentation for those differences.
Step 1: Install Ansible
Install Ansible on your management computer.
sudo apt update
sudo apt install ansible
Verify the installation:
ansible –version
Step 2: Install and Enable SSH
Ansible communicates with remote computers over SSH, so each client needs an SSH server installed.
On every Ubuntu/Xubuntu computer, run:
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
Test the connection from your management PC:
ssh username@192.168.1.101
Replace username with the user account on the remote computer.
Step 3: Create an SSH Key
Generate an SSH key on the management computer:
ssh-keygen -t ed25519
Press Enter to accept the default options.
Step 4: Copy the SSH Key
Copy your public key to each computer:
ssh-copy-id username@192.168.1.101
ssh-copy-id username@192.168.1.102
ssh-copy-id username@192.168.1.103
ssh-copy-id username@192.168.1.104
After this, you should be able to log in without entering a password.
Step 5: Create an Inventory File
Create a file named hosts.ini.
[xubuntu]
192.168.1.101
192.168.1.102
192.168.1.103
192.168.1.104
You can group any number of computers in this file and even create multiple groups for different environments.
Step 6: Test the Connection
Verify that Ansible can communicate with every computer.
ansible xubuntu -i hosts.ini -m ping
If everything is configured correctly, you'll see:
192.168.1.101 | SUCCESS => {
"ping": "pong"
}
Step 7: Start Managing Your Computers
Now you're ready to manage all your systems from a single command.
Reboot all computers
ansible xubuntu -i hosts.ini -b -m reboot
Install GIMP on every computer
ansible xubuntu -i hosts.ini -b -m apt -a "name=gimp state=present"
Update all systems
ansible xubuntu -i hosts.ini -b -a "apt update && apt upgrade -y"
Run any Linux command
ansible xubuntu -i hosts.ini -a "hostname"
Check disk usage
ansible xubuntu -i hosts.ini -a "df -h"
Copy a file to every computer
ansible xubuntu -i hosts.ini -m copy -a "src=wallpaper.jpg dest=/home/username/"
With Ansible, managing multiple Linux computers becomes simple and efficient. Instead of logging into each computer individually, you can perform administrative tasks across your entire network with a single command.
