---
name: "ansible-playbook-role-craft"
description: "Automate Linux server configuration, package installs, and service lifecycles with Ansible."
metadata:
  author: "Ansible"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "write ansible playbook"
  - "create ansible role"
  - "ansible jinja2 template"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Ansible Playbook Authoring & Production Roles

Authors Ansible automation: structuring roles (tasks, handlers, vars, defaults), idempotency principles, loops, conditional when statements, template modules (Jinja2), and testing with Molecule.

## When to Invoke
Invoke this skill whenever you need to:
- write ansible playbook
- create ansible role
- ansible jinja2 template

## Execution SOP & Rules
1. Structure playbooks into roles/ with tasks/main.yml, handlers/main.yml, and templates/.
2. Ensure every task is strictly idempotent; avoid raw command or shell modules when possible.
3. Notify handlers using notify: 'reload nginx' to coalesce restarts at playbook completion.
4. Test syntax and check execution mode: ansible-playbook site.yml --syntax-check and --check.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
