Ansible Automation Playbook Creator
Generates production-ready, idempotent Ansible playbooks and roles for any infrastructure automation or configuration task.
Example run
Generated by Claude Opus 5.5 on September 23, 2026
Inputs used
- Infrastructure task
- Deploy and harden an NGINX reverse proxy (fronting a Node.js app on port 3000) with automatic Let's Encrypt TLS certificate issuance and renewal via certbot
- Inventory group
- webservers_prod
- Target os
- Ubuntu 22.04 LTS (Jammy), kernel 5.15
- Environment
- production
- Constraints
- Servers are direct internet-facing VPS instances (no load balancer in front). Must use UFW for firewall management, allowing only 22/tcp (restricted to office VPN CIDR 203.0.113.0/24), 80/tcp and 443/tcp. TLS certs must be issued via Let's Encrypt using the DNS-01 challenge against Cloudflare (API token stored in Ansible Vault). fail2ban is already installed and must remain untouched. Prometheus node_exporter runs on port 9100 and must stay reachable only from the internal monitoring subnet 10.0.5.0/24. All package installs must go through the internal APT mirror at http://apt-mirror.internal.example.com (repo already configured in /etc/apt/sources.list.d/internal.list). Company policy forbids raw shell/command modules unless no native module exists, and every state-changing task must log to /var/log/ansible-deployments.log via a handler.
Most gaps can become variables in defaults/main.yml. However, a few decisions affect safety or correctness on internet-facing production hosts. Please confirm or correct these before I generate the playbook. Proposed defaults are in bold, so you can just reply "defaults are fine" or change any of them.
Blocking (no safe default)
- Domains and ACME contact. Which FQDN(s) does each host serve, and should any host have SAN or wildcard certs? Which email address should Let's Encrypt use? My plan is a per-host
nginx_server_nameslist inhost_vars, with the email ingroup_vars. - Cloudflare token scope. Can you confirm the Vault token is a scoped API token with
Zone:DNS:Editon the relevant zones? It should not be a Global API Key. This affects the credentials file format certbot needs.
Safety-critical (lockout or disruption risk)
-
SSH hardening scope. You asked for hardened defaults, but changing
sshd_configon a VPS risks locking you out. Should I apply the following?PermitRootLogin noPasswordAuthentication noKbdInteractiveAuthentication noMaxAuthTries 3X11Forwarding no- An
AllowGroupslist, or leave it unset
The change would be validated with
sshd -tand delivered as a drop-in (/etc/ssh/sshd_config.d/10-hardening.conf) rather than by editing the main file. Or should SSH be left out of scope entirely? -
Existing UFW rules. Is UFW currently active with rules that aren't in your list, for example rules added by fail2ban or other tooling?
- Option A (default): leave existing rules alone, add the required ones, and set default deny incoming / allow outgoing.
- Option B: reset UFW and enforce exactly the declared ruleset. This is stricter but can drop sessions and remove rules you forgot about.
Also, should the Ansible control node's own SSH path always come from 203.0.113.0/24? Otherwise the run will cut itself off.
-
ACME environment. I'd issue against the Let's Encrypt staging endpoint first (toggle variable), then flip to production. This avoids rate limits if DNS propagation or the token misbehaves. Is that acceptable?
Design choices
-
Certbot source. Snap is off the table because of the mirror requirement, so I'd install
certbotandpython3-certbot-dns-cloudflarefrom the Jammy APT repos via your mirror. Can you confirm the mirror carriesuniverse? Renewal would use the packagedcertbot.timer, plus a deploy hook that reloads nginx. -
Node.js app. Is the app already deployed and managed (systemd/pm2) outside this playbook, with the playbook only proxying to
127.0.0.1:3000? Should I also block port 3000 from outside? UFW default-deny already covers that. Do you need WebSocket upgrade headers? I'd include them by default. -
TLS and header policy. My defaults would be:
- TLS 1.2 + 1.3 with the Mozilla "intermediate" ciphers
- OCSP stapling off, since Let's Encrypt ended OCSP support in 2025
- HSTS
max-age=63072000withoutpreload X-Content-Type-Options,X-Frame-Options DENY,Referrer-Policy,server_tokens off- Basic rate limiting (
limit_req)
Should anything change, for example HSTS
includeSubDomains/preloador a CSP? -
Deployment log format. For
/var/log/ansible-deployments.log, I'd use a handler that appends a line viaansible.builtin.lineinfile(no shell): ISO-8601 timestamp, host, playbook, and changed task/role, with the file at0640 root:admand logrotate config included. Is that okay, or do you need a specific format, such as JSON for log shipping? -
node_exporter. Should the playbook only manage the UFW rule (9100/tcp from 10.0.5.0/24) and never touch the node_exporter service itself? Should I also add an explicit deny for 9100 from elsewhere, or rely on default deny?
Once you answer, I'll deliver the full role and the rest of what you asked for:
- Role layout:
defaults,taskssplit by tag (packages,firewall,ssh,nginx,tls,logging),handlers, andtemplates. - Inventory:
inventory.ini, plusgroup_varswith Vault placeholders. - Run and validation: run commands with
--check --diff, rollback notes, and the Validation section.
Related prompts
Cybersecurity Audit Specialist
Run a structured cybersecurity audit of an organization, prioritizing risks and producing an actionable remediation roadmap.
DevOps Automation Specialist
Acts as a DevOps engineer to design, optimize, and troubleshoot CI/CD pipelines, infrastructure as code, and cloud automation.
Docker Container Builder
Generates production-ready, optimized Dockerfiles with multi-stage builds, caching, and tagging for any application.
Cloud Infrastructure Architect
Design a scalable, secure, cost-optimized cloud architecture with IaC, diagrams, and a phased rollout plan.