Ansible Playbook Generator
Build an Ansible playbook with apt, service, copy, template, user, and git tasks.
Written by Golam Rabbani, Founder & Lead Engineer
How to use this ansible playbook generator
- Name the play and enter the host pattern (e.g. webservers, all, db[0:2]).
- Toggle become (sudo) and gather_facts as you need them.
- Fill in the first task — pick a module (apt, service, copy, template, file, user, shell, lineinfile, git) and the fields that appear.
- Click + Add task to chain more tasks; each one gets validated for required fields.
- Click Generate and Copy playbook, then save the result as site.yml and run it with ansible-playbook site.yml.
About this ansible playbook generator
The Ansible playbook generator builds a `playbook.yml` task by task. Every module is emitted using its fully-qualified collection name — `ansible.builtin.apt`, `ansible.builtin.service`, `ansible.builtin.template`, and so on — so the output runs on any modern Ansible version (2.10+) regardless of `collections:` configuration.
Per-task validation catches the common omissions: an apt task without a package name, a copy task without `src`/`dest`, a git task without a repo URL. Sensible defaults are filled in where it matters: copy/template tasks default to mode `0644`, service tasks set `enabled: true` so the unit starts on boot, lineinfile sets `create: true` so it makes the file if missing, apt sets `update_cache: true` so you do not run with stale package lists.
As an example, "Configure web servers" against hosts `webservers` with become on, gather_facts on, and two tasks — install nginx via apt, start nginx via service — generates:
--- - name: Configure web servers hosts: webservers become: true gather_facts: true tasks: - name: Install nginx ansible.builtin.apt: name: nginx state: present update_cache: true - name: Start nginx ansible.builtin.service: name: nginx state: started enabled: true
All generation runs in the browser; nothing is uploaded.
FAQ
- Why does every task use ansible.builtin.* instead of the short name?
- Since Ansible 2.10, modules live in collections and the FQCN (fully-qualified collection name) is the recommended form — it removes ambiguity if multiple collections expose a `copy` module and makes lint tools happy. Short names like `apt:` still work, but FQCN is the durable choice.
- When should I use the package module instead of apt or yum?
- `ansible.builtin.package` auto-detects the underlying package manager — useful when one playbook targets a mix of Debian and RHEL hosts. Pick it for OS-agnostic installs; use `apt` or `yum` when you need module-specific options (e.g. `update_cache`, `enablerepo`).
- How do I save the generated playbook?
- Save the output as `site.yml` (or any `.yml`) in your Ansible project. Make sure your inventory contains a group matching the `hosts:` pattern. Run it with `ansible-playbook -i hosts.ini site.yml`, optionally adding `--check` for a dry run or `-v` for verbose output.
- Does become work for me automatically when I tick it?
- It tells Ansible to escalate privileges for every task in the play, defaulting to `sudo`. Your remote user still needs sudo rights on the target hosts — for password-less sudo, that means a NOPASSWD line in `/etc/sudoers`, otherwise pass `--ask-become-pass` on the command line.
- Does the generator send my playbook anywhere?
- No. The form, validation, and YAML rendering all run in your browser. The play name, host pattern, and task fields are never uploaded or logged.
- Is this Ansible playbook generator free to use?
- Yes, it is completely free with no account, no signup, and no usage limits.