#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🅰️ FREE · YAML PLAYBOOK

Ansible Playbook Generator: Set Up Servers the Repeatable Way

List what a server needs, and get a tidy playbook using fully qualified module names.

  • 📦 Packages and users
  • 📄 Files with restart handler
  • 🧱 UFW firewall rules

How to use the Ansible Playbook Generator

  1. 1. Name the play and hostsUse an inventory group such as webservers.
  2. 2. List the tasksPackages, a user, files to copy, ports to open and a service.
  3. 3. Dry-run firstRun ansible-playbook with --check before applying it for real.

The default playbook

The starting values create a play named Set up web servers for the webservers group with become: true. It has 6 tasks: install nginx, git and curl with ansible.builtin.package, create a deploy user, copy files/nginx.conf to /etc/nginx/conf.d/app.conf, allow ports 22, 80 and 443 in UFW with a loop, enable UFW with a default deny policy, and start and enable nginx.

The copy task carries notify: Restart nginx, which points at a handler of that name. Handlers run once at the end of the play and only if something changed, so editing the config restarts the service, while a re-run with nothing new leaves it alone.

Good habits the output follows

  • Fully qualified names like ansible.builtin.copy avoid clashes between collections and are what current Ansible documentation uses.
  • Idempotent tasks: running the playbook twice gives the same result, because each module checks the current state first.
  • Port 22 is opened before the firewall is enabled, so you do not lock yourself out of SSH.
  • File modes are quoted as "0644" so YAML does not turn them into a decimal number.

UFW tasks need the community.general collection and a Debian or Ubuntu host; on RHEL-family systems use ansible.posix.firewalld instead. Check edits with the YAML validator, and write a matching service unit with the systemd service file generator.

Frequently asked questions

What is an inventory?

A file listing your servers and groups, for example a [webservers] section with host names or IPs. Pass it with -i.

Do I need to install anything on the servers?

No agent is needed. Ansible connects over SSH and needs Python on the managed hosts, which most Linux distributions include.

Is the Ansible Playbook Generator free?

Yes, the Ansible Playbook Generator is free. The first time you generate your first playbook, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools