andersch.dev

<2025-03-26 Wed>

Ansible

Ansible is an open-source Infrastructure-as-Code (IaC) tool that uses YAML files (so-called playbooks) to define configuration and deployment of applications.

Its architecture is based on a push model, where commands are executed from a central control node to target machines, making it easy to manage both small and large-scale environments.

It does need special software to be preinstalled and can just use SSH for communication instead.

"Hello World" Example

The inventory file hosts.ini defines the target hosts:

[local]
localhost ansible_connection=local

The playbook hello_world.yml contains all instructions:

---
- name: Hello World Playbook
  hosts: local
  tasks:
    - name: Print Hello World
      debug:
        msg: "Hello, World!"

Running the playbook:

ansible-playbook -i hosts.ini hello_world.yml