Docs / Cloud & DevOps / How to Use Ansible to Configure Your Server

How to Use Ansible to Configure Your Server

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 504 views · 1 min read

Ansible automates server configuration so you can reproduce setups consistently.

Install (on your local machine)

pip install ansible

Create Inventory

Create hosts.ini:

[webservers]\nYOUR_IP ansible_user=root

Create a Playbook

Create setup.yml:

---\n- hosts: webservers\n  tasks:\n    - name: Update apt cache\n      apt: update_cache=yes\n\n    - name: Install packages\n      apt:\n        name:\n          - nginx\n          - php-fpm\n          - mysql-server\n        state: present\n\n    - name: Start Nginx\n      service: name=nginx state=started enabled=yes

Run

ansible-playbook -i hosts.ini setup.yml

Was this article helpful?