Back to Skills

Ansible Ops

Write, review, lint, convert, and debug Ansible with production best practices — FQCN, idempotency, validated templates, no_log secrets, and ansible-lint/yamllint

ansibledevopslintinginfrastructureautomation
By Sajjad Hassanzadeh
3Updated 1 month agoMIT

Skill Content

# Ansible Ops Skill

Turns Claude into a senior Ansible engineer that produces idempotent, lint-clean,
production-grade Ansible — and reviews or fixes existing Ansible to the same bar.

## Usage
```
/ansible-ops
```

## Behavior
The skill detects and respects the project's existing conventions, then applies four
workflows depending on the request.

### Write / scaffold
- Playbooks, roles (standard layout), inventory, group_vars/host_vars, and Jinja2 templates
- FQCN modules, named tasks, role-prefixed variables, validated templates, notify/handlers

### Review & lint
- Runs `ansible-playbook --syntax-check`, `yamllint`, and `ansible-lint`
- Produces a severity-ranked report (error / warning / nit) and offers fixes via diff
- Scaffolds `.yamllint`, `.ansible-lint`, and pre-commit config when missing

### Convert bash → Ansible
- Maps each shell command to its native module instead of wrapping in `command:`
- Extracts literals into role defaults; wraps module-less commands with `changed_when`/`creates`

### Debug
- Triages failing plays: connection/auth/become, module arg errors, idempotency drift

## What it enforces
- Fully-qualified collection names (`ansible.builtin.*`)
- Idempotency (`changed_when` / `creates` on commands)
- `no_log: true` on secret-handling tasks; Ansible Vault for secrets
- Explicit `mode:` on copy/template/file; `validate:` before writing config
- Multi-OS guards and pinned collections
- Never overwrite files silently — diff and confirm first

## Notes
Ships with a lint-clean example role that passes ansible-lint's strictest (production)
profile, verified in CI on every push. MIT licensed.

How to use

  1. Copy the skill content above
  2. Create a .claude/skills directory in your project
  3. Save as .claude/skills/ansible-ops.md
  4. Use /ansible-ops in Claude Code to invoke this skill
<div align="center">

ansible-ops-toolkit

License: MIT Claude Code Skill Ansible Core Validate CI

</div>
   ▛▀▀▜
   ▌◍◍▐   Claude Code · Opus 4.8
   ▙▄▄▟   ansible-ops-toolkit/
          └ SessionStart says: [ansible-ops 0.1.0]
──────────────────────────────────────────────────────────────

    _    _   _ ____ ___ ____  _     _____    ___  ____  ____
   / \  | \ | / ___|_ _| __ )| |   | ____|  / _ \|  _ \/ ___|
  / _ \ |  \| \___ \| ||  _ \| |   |  _|   | | | | |_) \___ \
 / ___ \| |\  |___) | || |_) | |___| |___  | |_| |  __/ ___) |
/_/   \_\_| \_|____/___|____/|_____|_____|  \___/|_|   |____/

──────────────────────────────────────────────────────────────
❯ /ansible-ops  —  write · review · lint · convert · debug Ansible

A Claude Code skill for writing, reviewing, linting, converting, and debugging Ansible — playbooks, roles, inventory, and Jinja2 templates — following production best practices. Ships with a small, lint-clean example role you can copy.

It encodes the conventions that hold up at fleet scale: FQCN modules, idempotency, validation-first tasks, notify/handler patterns, hierarchical tags, <role>_<knob> variable naming, no_log on secrets, multi-OS guards, and pinned collections.

What it enforces

AreaRule
ModulesFully-qualified collection names (ansible.builtin.*)
TasksEvery play/task named; the why, capitalized
IdempotencyModules over shell; changed_when / creates when you must shell out
Variables<role>_*, defaulted in defaults/main.yml
Templatesansible_managed header + validate: before write
SecretsAnsible Vault + no_log: true
FilesExplicit mode: on copy/template/file
SafetyNever overwrite silently — diff & confirm first
Lintyamllint + ansible-lint (production profile) + pre-commit

Layout

.claude-plugin/        # plugin + marketplace manifests
skills/ansible-ops/    # the skill: SKILL.md, references/, evals/
examples/nginx-role/   # tiny, lint-clean reference project (CI-verified)
.github/workflows/     # yamllint + ansible-lint on every push

Install

Plugin marketplace (recommended):

/plugin marketplace add Hassanzadeh-sd/ansible-ops-toolkit
/plugin install ansible-ops-toolkit

npx skills:

npx skills add Hassanzadeh-sd/ansible-ops-toolkit

Manual: copy skills/ansible-ops/ into ~/.claude/skills/ (global) or a project's .claude/skills/.

Then invoke with /ansible-ops or just ask in natural language ("write an Ansible role for nginx", "lint my playbooks", "convert this bash script to Ansible", "why is this play failing").

Try the example

cd examples/nginx-role
ansible-playbook --syntax-check site.yml
yamllint -c ../../.yamllint .
ansible-lint

Credits

Built by @Hassanzadeh-sd. Inspired by hello-ansible-skills, ansible-skills, and ansible-designer. MIT licensed.

View source on GitHub