Blog

Cara Setup Ansible: Otomatisasi Konfigurasi Server

07 Oct 2025

Apa itu Ansible?

Ansible adalah tool Infrastructure as Code (IaC) yang menggunakan YAML untuk mengotomatisasi konfigurasi server. Agentless — hanya butuh SSH.

Langkah 1: Install Ansible

apt install ansible -y

Langkah 2: Inventory File

# /etc/ansible/hosts\n[webservers]\nweb1 ansible_host=192.168.1.10\nweb2 ansible_host=192.168.1.11\n\n[dbservers]\ndb1 ansible_host=192.168.1.20

Langkah 3: Playbook Pertama

# lemp.yml\n- hosts: webservers\n  tasks:\n    - name: Install Nginx\n      apt: name=nginx state=present\n    - name: Start Nginx\n      service: name=nginx state=started enabled=yes

Langkah 4: Variables & Templates

Gunakan Jinja2 templates untuk file konfigurasi yang dinamis.

Langkah 5: Ansible Galaxy Roles

Gunakan community roles untuk setup kompleks seperti WordPress atau Docker.

Kesimpulan

Dengan Ansible, setup 1 server atau 100 server sama mudahnya. Cukup satu command.

Semua Artikel