Updated: 28 September 2026 · Applies to: Ansible (ansible-core 2.16+) on Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9

Ansible is an agentless automation tool: it connects over SSH and runs tasks written in YAML playbooks. These steps set up one control machine and several managed servers with Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9.

Install Ansible on your control machine

sudo apt install ansible                      # Ubuntu 24.04 / Debian 12 (distribution version)
sudo add-apt-repository ppa:ansible/ansible && sudo apt install ansible   # Ubuntu: latest version
sudo dnf install ansible-core                  # AlmaLinux / Rocky 9
pipx install --include-deps ansible            # any system, latest version, per user

Check with ansible --version. Only the control machine needs Ansible; managed servers need SSH and Python 3.

Inventory and first commands

Create inventory.ini:

[web]
web1.example.com
web2.example.com ansible_port=2222

[db]
db1.example.com

[all:vars]
ansible_user=admin
ssh-copy-id admin@web1.example.com                  # key login to each server
ansible all -i inventory.ini -m ping
ansible web -i inventory.ini -a "uptime"
ansible web -i inventory.ini -b -m ansible.builtin.package -a "name=nginx state=present"

A playbook

# site.yml
- hosts: web
  become: true
  tasks:
    - name: Install nginx
      ansible.builtin.package:
        name: nginx
        state: present
    - name: Start nginx
      ansible.builtin.service:
        name: nginx
        state: started
        enabled: true
ansible-playbook -i inventory.ini site.yml --check    # dry run
ansible-playbook -i inventory.ini site.yml

Tip: Use roles to organise larger setups (ansible-galaxy role init webserver), and keep secrets in Ansible Vault (ansible-vault create secrets.yml).

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket