$ recombobulate _
home / tips / use-claude-to-write-ansible-playbooks
0

Use Claude to Write Ansible Playbooks

bagwaa @bagwaa · Mar 26, 2026 · Workflows
use-claude-to-write-ansible-playbooks

Ansible playbooks are powerful but the YAML syntax and module names are tedious to look up every time. Claude knows the module library, idempotency requirements, and best practices — just describe what you need.

Write an Ansible playbook that provisions a fresh Ubuntu 22.04 server:
install Nginx, PHP-FPM 8.3, and Redis. Configure a systemd service for
a Laravel queue worker. Use variables for all configurable values
and add handlers to restart services only when their config changes.

Claude uses the correct modules (apt, template, systemd, file), adds become: yes where root is needed, structures tasks into logical plays, and writes proper handlers rather than restarting services unconditionally.

# Ask for targeted deployment tasks
Write an Ansible task to deploy a new version of a Docker Compose app:
- Pull the latest images
- Run database migrations
- Restart only the affected services (not the full stack)
- Notify a Slack webhook on success or failure

# Ask for role structure
Create an Ansible role structure for a PostgreSQL server setup with
separate tasks files for install, configure, and backup. Include
default variables and a molecule test stub.

Claude will also flag common mistakes — like forgetting to use notify instead of direct service restarts, or missing when conditions for idempotency.

Describe your infrastructure once in plain English — Claude handles the YAML.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Scan Pending Changes for Security Issues with /security-review

The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.

bagwaa @bagwaa · 2 hours ago
0
Run Setup Scripts on Every Session with the SessionStart Hook

The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.

bagwaa @bagwaa · 2 hours ago
0
Write Property-Based Tests with fast-check and Claude

Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.

bagwaa @bagwaa · 2 hours ago