Updated: 28 September 2026 · Applies to: Ansible (ansible-core 2.16+) on Ubuntu 24.04, Debian 12, AlmaLinux 9 and Rocky Linux 9
Configuration management means describing how your servers should be set up in files, so you can apply the same setup again and again. Ansible does this over SSH. This guide gets you started with a Ucartz VPS running 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
Why it helps
- New servers are set up identically in minutes.
- Changes are reviewed and versioned in Git like code.
- Running the playbook again is safe: Ansible only changes what differs.