Ansible Playbook Generator
Generate Ansible playbooks with tasks, handlers, variables, and roles. Includes inventory.ini and ansible.cfg generation. 100% client-side — nothing leaves your browser.
Play Settings
Connection
Variables
Tasks
Handlers
Roles
Output Options
# Generated by RawOps.dev — Ansible Playbook Generator
# Mode: web-server
---
- name: Configure Web Server
hosts: webservers
become: true
vars:
http_port: '80'
server_name: example.com
# Tasks
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
update_cache: 'yes'
become: true
notify: Restart Nginx
tags: [install]
- name: Deploy site configuration
template:
src: templates/nginx.conf.j2
dest: /etc/nginx/sites-available/default
mode: '0644'
become: true
notify: Restart Nginx
tags: [configure]
- name: Ensure Nginx is running and enabled
service:
name: nginx
state: started
enabled: 'yes'
become: true
tags: [service]
- name: Allow HTTP through firewall
ufw:
rule: allow
port: '{{ http_port }}'
proto: tcp
become: true
tags: [firewall]
# Handlers are triggered by 'notify' in tasks
handlers:
- name: Restart Nginx
service:
name: nginx
state: restarted
Quick Recipes
Click a recipe to populate the form with a ready-to-use playbook configuration.
Ansible Playbook Guide
An Ansible playbook is a YAML file that describes a set of automation tasks to be executed on remote servers. Playbooks are the core of Ansible's configuration management — they define what should happen on which hosts, in what order.
Playbook vs Role vs Collection
| Concept | Purpose | Scope |
|---|---|---|
| Playbook | Orchestration — defines what to run where | One file, one or more plays |
| Role | Reusable component — tasks, handlers, templates, defaults | Directory structure |
| Collection | Distribution unit — roles, modules, plugins, docs | Galaxy namespace |
Idempotency
Ansible modules are designed to be idempotent — running a playbook multiple times produces the same result. The apt module with state: present installs a package only if it's not already installed. command and shell modules are exceptions — they always run. Use creates or when to make them conditional.
Task Execution Order & Strategies
Within a play, execution order is: pre_tasks → roles → tasks → post_tasks. Handlers run after each section, not after each task. The serial keyword controls how many hosts run in parallel — essential for rolling updates.
Common Modules Reference
| Module | Purpose | Example |
|---|---|---|
| apt / yum / dnf | Package management | apt: name=nginx state=present |
| copy / template | File deployment | template: src=app.conf.j2 dest=/etc/app.conf |
| service / systemd | Service management | service: name=nginx state=started enabled=yes |
| file | File/directory attributes | file: path=/opt/app state=directory mode=0755 |
| lineinfile | Edit single lines in files | lineinfile: path=/etc/ssh/sshd_config regexp='^Port' line='Port 2222' |
| user / group | User/group management | user: name=deploy groups=sudo shell=/bin/bash |
| command / shell | Run commands (not idempotent) | command: cmd='make install' chdir=/opt/app |
| uri | HTTP requests | uri: url=http://localhost/health status_code=200 |
Best Practices
- Name every task — meaningful names make
ansible-playbook -voutput readable and debugging faster. - Use tags — tags let you run specific parts:
ansible-playbook site.yml --tags deploy - Handlers for restarts — never restart a service in a task directly. Use
notifyto trigger a handler. Handlers only run once per play, even if notified multiple times. - Use Ansible Vault — never store passwords in plaintext. Use
{{ vault_db_password }}and encrypt withansible-vault encrypt_string. - Prefer modules over shell — modules are idempotent and cross-platform.
commandandshellshould be a last resort. - Use roles for reusability — extract common tasks into roles. Structure:
roles/nginx/tasks/main.yml.
Privacy First
All playbook generation happens entirely in your browser using JavaScript. Your hostnames, variables, credentials references, and infrastructure details are never sent to any server. This tool has zero backend dependencies.