Docs / Automation & IaC / How to Create Ansible Playbooks for Common Tasks

How to Create Ansible Playbooks for Common Tasks

By Admin · Mar 1, 2026 · Updated Apr 23, 2026 · 24 views · 1 min read

How to Create Ansible Playbooks for Common Tasks

Ansible playbooks are YAML files that describe automation tasks to run on your Breezes. They transform repetitive system administration into reusable, version-controlled code.

Playbook Structure

Every playbook follows a consistent structure:

---
- name: Deploy web application
  hosts: webservers
  become: true
  vars:
    app_dir: /var/www/myapp

  tasks:
    - name: Install Nginx
      apt:
        name: nginx
        state: present

    - name: Copy Nginx config
      template:
        src: templates/nginx.conf.j2
        dest: /etc/nginx/sites-available/default
      notify: reload nginx

    - name: Ensure app directory exists
      file:
        path: "{{ app_dir }}"
        state: directory
        owner: www-data
        mode: '0755'

  handlers:
    - name: reload nginx
      service:
        name: nginx
        state: reloaded

Common Modules

  • apt / yum — package management
  • service — start, stop, restart services
  • template — deploy Jinja2 configuration templates
  • copy — copy static files to remote hosts
  • file — manage file and directory permissions
  • user — create and manage user accounts

Inventory File

Define your Breezes in inventory.ini:

[webservers]
breeze-web-01 ansible_host=192.168.1.10
breeze-web-02 ansible_host=192.168.1.11

[databases]
breeze-db-01 ansible_host=192.168.1.20

Use ansible-playbook -i inventory.ini playbook.yml --check to preview changes before applying them to production Breezes.

Was this article helpful?