Skip to content
BENIBIX Learn

Ansible

Development☁️ DevOps & CloudInfrastructure as Code

Also known as Ansible Playbook, Red Hat Ansible, ansible-playbook

A tool that sets up many servers at once. It reads its steps from a YAML file.

Think of it like

Think of it like a teacher who reads one list of steps to a class. Everyone does the same steps at once.

Example

Lucy's playbook installs Nginx on five servers. She runs it once, and all five are set up in a minute.

Why it matters

One file sets up any number of servers the same way. Nothing extra goes on the servers.

Definition

Ansible is an open-source tool for setting up servers and doing IT jobs. You write the steps in a playbook, a YAML file that reads almost like a list. Ansible connects to each server over SSH and runs the steps. It needs no extra program on the servers. If you run a playbook again, it changes only what is different.

Example code

yaml
- hosts: web
  become: true
  tasks:
    - name: Install nginx
      ansible.builtin.apt:
        name: nginx
        state: present
A playbook that makes sure Nginx is installed on every web server.
Ansible sends the steps over SSH. The servers need no extra program.

Common mistake

Running shell commands for every step. Use the built-in steps, so a second run does not redo the work.

Key takeaways

  1. 1
    Playbooks in YAML. Steps that read like a list.
  2. 2
    Over SSH. No agent on the servers.
  3. 3
    Safe to rerun. Only differences change.

Compare