Skip to main content
skill CX Codex

ansible-generator — Claude Code skill for generating Ansible content

ansible-generator — a Claude Code skill that generates Ansible playbooks, roles, tasks, inventory, and config. It also runs in snippet-only and docs-only modes.

Apache-2.0 952 installs ★ 343 updated 2026-07-26

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add akin-ozer/cc-devops-skills --skill ansible-generator -a claude-code
Open on GitHub

What ansible-generator does

The skill handles requests for Ansible content: a playbook to deploy nginx with TLS, a role for PostgreSQL backups, inventory files for prod and staging, reusable tasks, or a fresh project with ansible.cfg and requirements.yml.

Generation follows a fixed pipeline. The skill first classifies the request as full generation, snippet-only, or docs-only. Then it collects the minimum inputs: target hosts, become, OS family, goal. Missing details get safe defaults like hosts: all and become: false.

Output is built from local templates in assets/templates/: a basic playbook structure, role scaffolding with meta/argument_specs.yml and molecule/default/, inventory templates in INI and YAML, and project configs. Standards are strict: FQCN module names with ansible.builtin.* first, idempotent tasks, true/false booleans instead of yes/no, and no_log: true for secrets. RHEL 8+ and CentOS 8+ get ansible.builtin.dnf rather than yum.

After generation, the skill runs ansible-validator when available. Offline or without the validator, it does manual checks: YAML shape, placeholder scan, FQCN and idempotency review. Snippets skip full validation, and docs-only mode needs none. For validation-only or debug requests, this skill is the wrong tool — use ansible-validator instead.

What it helps with

  • generate a playbook from a task description
  • scaffold a role with molecule tests and argument_specs
  • create inventory files for prod and staging
  • write reusable tasks with documented variables
  • initialize a project with ansible.cfg, requirements.yml, and .ansible-lint

Example prompts for the agent

  • Create a playbook to deploy nginx with TLS
  • Generate an Ansible role for PostgreSQL backups
  • Write inventory files for prod and staging

How to install ansible-generator

1Skills CLI (Vercel)

npx skills add akin-ozer/cc-devops-skills --skill ansible-generator -a claude-code

2Manually: put the files in place

~/.claude/skills/ansible-generator/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/ansible-generator/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about ansible-generator

How do I install ansible-generator in Claude Code?

Run npx skills add akin-ozer/cc-devops-skills --skill ansible-generator -a claude-code. The skill lands in ~/.claude/skills/ansible-generator/SKILL.md.

What does ansible-generator do?

It generates Ansible content: playbooks, roles, task files, handlers, inventory, and vars. It can produce a complete file set or a short snippet.

How is ansible-generator different from ansible-validator?

ansible-generator creates content, while ansible-validator checks it for syntax errors and lint failures. Use ansible-validator for validation and debugging.

Source text

SKILL.md · Apache-2.0
---
name: ansible-generator
description: Generate, create, or scaffold Ansible playbooks, roles, tasks, handlers, inventory, vars.
---

# Ansible Generator

## Trigger Phrases

Use this skill when the request is to generate or scaffold Ansible content, for example:

- "Create a playbook to deploy nginx with TLS."
- "Generate an Ansible role for PostgreSQL backups."
- "Write inventory files for prod and staging."
- "Build reusable Ansible tasks for user provisioning."
- "Initialize an Ansible project with ansible.cfg and requirements.yml."
- "Give me a quick Ansible snippet to install Docker."

Do not use this skill as the primary workflow when the request is validation/debug-only (syntax errors, lint failures, Molecule/test failures). Use `ansible-validator` for those cases.

## Deterministic Execution Flow

Run these stages in order. Do not skip a stage unless the `Validation Exceptions Matrix` explicitly allows it.

### Stage 0: Classify Request Mode

Determine one mode first:

| Mode | Typical user intent | Deliverable |
| --- | --- | --- |
| `full-generation` | "create/build/generate" a full playbook/role/inventory/project file set | Complete file(s), production-ready |
| `snippet-only` | "quick snippet/example" without full file context | Focused task/play snippet |
| `docs-only` | explanation, pattern comparison, or conceptual guidance only | Explanatory content, optional examples |

### Stage 1: Collect Minimum Inputs

If details are missing, ask briefly. If the user does not provide them, proceed with safe defaults and state assumptions.

| Resource type | Required inputs | Safe defaults if missing |
| --- | --- | --- |
| Playbook | target hosts, privilege (`become`), OS family, objective | `hosts: all`, `become: false`, OS-agnostic modules |
| Role | role name, primary service/package, supported OS | role name from task domain, Debian + RedHat vars |
| Tasks file | operation scope, required vars, execution context | standalone reusable tasks with documented vars |
| Inventory | environments, host groups, hostnames/IPs | `production`/`staging` groups with placeholders |
| Project config | collections/roles dependencies, lint policy | minimal `ansible.cfg`, `requirements.yml`, `.ansible-lint` |

### Stage 2: Reference Extraction Checklist

Before drafting content, extract the following from local references/templates.

#### Required references

- `references/best-practices.md`
  - Extract: FQCN requirements, idempotency rules, naming, security expectations.
- `references/module-patterns.md`
  - Extract: correct module/parameter patterns for the exact task type.

#### Required templates by output type

- Playbook: `assets/templates/playbook/basic_playbook.yml`
- Role: `assets/templates/role/` (including `meta/argument_specs.yml` and `molecule/default/` for test scaffolding)
- Inventory (INI): `assets/templates/inventory/hosts`
- Inventory (YAML): `assets/templates/inventory/hosts.yml`
- Project config: `assets/templates/project/ansible.cfg`, `assets/templates/project/requirements.yml`, `assets/templates/project/.ansible-lint`

#### Extraction checks

- Identify every `[PLACEHOLDER]` that must be replaced.
- Decide module selection priority (`ansible.builtin.*` first).
- Capture at least one OS-appropriate package pattern when OS-specific behavior is needed.
- Capture required prerequisites (collections, binaries, target assumptions).

### Stage 3: Generate

Apply these generation standards:

1. Use FQCN module names (`ansible.builtin.*` first choice).
2. Keep tasks idempotent (`state`, `creates/removes`, `changed_when` when needed).
3. Use descriptive verb-first task names.
4. Use `true`/`false` booleans (not `yes`/`no`).
5. Add `no_log: true` for sensitive values.
6. Replace all placeholders before presenting output.
7. Prefer `ansible.builtin.dnf` for RHEL 8+/CentOS 8+ (legacy `yum` only for older systems).

### Stage 4: Validate (Default) or Apply Exception (Fallback)

Use the matrix below to keep validation deterministic and non-blocking.

## Validation Exceptions Matrix

| Scenario | Default behavior | Allowed fallback | What to report |
| --- | --- | --- | --- |
| `full-generation` | Run `ansible-validator` after generation and after each fix pass | If validator/tools are unavailable, run manual static checks (YAML shape, placeholder scan, FQCN/idempotency/security review) and provide exact deferred validation commands | Explicitly list which checks ran, which were skipped, and why |
| `snippet-only` | Skip full validator by default; do inline sanity checks | Run full validator only if user asks or snippet is promoted to full file | State that validation was limited because output is snippet-only |
| `docs-only` | No runtime validation | None needed | State that no executable artifact was generated |
| Offline environment (no web/docs access) | Continue with local references and templates | Skip external doc lookups; prefer builtin-module implementations; provide notes for later external verification | State offline constraint and impacted checks/lookups |

## Resource Generation Guidance

### Playbooks

- Use `assets/templates/playbook/basic_playbook.yml` as structure.
- Include: header comments, `pre_tasks`/`tasks`/`post_tasks` as needed, handlers, tags.
- Add health checks when service deployment/configuration is involved.

### Roles

- Build from `assets/templates/role/` structure.
- Keep defaults in `defaults/main.yml`; keep higher-priority role vars in `vars/main.yml`.
- Include OS-specific vars (`vars/Debian.yml`, `vars/RedHat.yml`) when relevant.
- Add `meta/argument_specs.yml` for variable validation.
- Include `molecule/default/` scaffold (from `assets/templates/role/molecule/`) for production-ready roles.

### Task Files

- Keep scope narrow and reusable.
- Document required input variables in comments.
- Use conditionals for environment/OS-sensitive operations.

### Inventory

- Build logical host groups and optional group hierarchies.
- Use variable layering intentionally: `group_vars/all.yml` -> group -> host.
- Default to INI format (`hosts`) for simple topologies; use YAML format (`hosts.yml`) when the user requests it or when the hierarchy is complex.

### Project Configuration

- Provide baseline `ansible.cfg`, `requirements.yml`, and `.ansible-lint`.
- Keep defaults practical and editable.

## Custom Modules and Collections

When the request depends on non-builtin modules/collections:

1. Identify collection + module and required version sensitivity.
2. Check local `references/module-patterns.md` first.
3. If still unresolved and network/tools are available, query Context7:
   - `mcp__context7__resolve-library-id`
   - `mcp__context7__query-docs`
4. If Context7 is unavailable, use official Ansible docs / Ansible Galaxy pages.
5. If external lookup is unavailable, provide a builtin fallback approach and state the limitation.

Always include collection installation guidance when collection modules are used.

## Canonical Example Flows

### Flow A: Full Generation (Playbook)

User prompt: "Create a playbook to deploy nginx with TLS on Ubuntu and RHEL."

1. Classify as `full-generation`.
2. Gather/confirm required inputs (hosts, cert paths, become, service name).
3. Extract required references (`best-practices.md`, `module-patterns.md`) and playbook template.
4. Generate complete playbook with OS conditionals (`apt`/`dnf`), handlers, validation for config templates.
5. Run `ansible-validator`.
6. Fix issues and rerun until checks pass (or apply matrix fallback if tooling unavailable).
7. Present output with validation summary, usage command, and prerequisites.

### Flow B: Quick Snippet (Task Block)

User prompt: "Give me a snippet to create a user and SSH key."

1. Classify as `snippet-only`.
2. Extract minimal module patterns for `ansible.builtin.user` and `ansible.builtin.authorized_key`.
3. Generate concise snippet with FQCN, idempotency, and variable placeholders.
4. Perform inline sanity checks (YAML shape, FQCN, obvious idempotency/security).
5. Present snippet and note that full validator run was skipped due to snippet-only mode.

## Output Requirements

For generated executable artifacts, use this response structure:

```markdown
## Generated [Resource Type]: [Name]

**Validation Status:** [Passed / Partially validated / Skipped with reason]
- YAML syntax: [status]
- Ansible syntax: [status]
- Lint: [status]

**Summary:**
- [What was generated]
- [Key implementation choices]

**Assumptions:**
- [Defaults or inferred values]

**Usage:**
```bash
[Exact command(s)]
```

**Prerequisites:**
- [Collections, binaries, environment needs]
```

## Done Criteria

This skill execution is complete only when all applicable items are true:

- Trigger decision is explicit (`full-generation`, `snippet-only`, or `docs-only`).
- Required references/templates were consulted for the selected artifact type.
- Generated output has no unresolved placeholders.
- Validation followed default behavior or a documented exception from the matrix.
- Any skipped checks include a concrete reason and deferred command(s).
- Final output includes summary, assumptions, usage, and prerequisites.

© akin-ozer · Apache-2.0 · akin-ozer/cc-devops-skills

Similar skills

All skills for DevOps and infrastructure →

From the same set30

The whole set →
ansible-validator ansible-validator — a skill that runs Ansible playbooks and roles through linters, check mode, Molecule and secret scanners. Useful when the code exists and you need to know what is wrong with it. CX Codex +1 1,800installs terragrunt-generator terragrunt-generator generates modern Terragrunt HCL files, root configurations, and multi-environment layouts. Helpful when organizing dev, staging, and prod infrastructure. CX Codex +1 1,300installs k8s-debug k8s-debug walks through pod failures, stuck rollouts, DNS and storage problems with kubectl. Useful when a cluster misbehaves right after a deploy. CX Codex +1 939installs jenkinsfile-generator jenkinsfile-generator generates declarative and scripted Jenkinsfiles, Kubernetes pod templates, and Jenkins Shared Library scaffolds. Useful when creating CI/CD pipelines with parallel stages or security checks. CX Codex +1 897installs dockerfile-validator dockerfile-validator validates Dockerfiles for syntax, security flaws, and build practices using a structured validation script. Useful for hardening images before CI/CD merges. CX Codex +1 822installs bash-script-validator bash-script-validator is a Claude Code skill that checks Bash and POSIX shell scripts for syntax faults, ShellCheck findings, and security issues. It activates for script reviews, linting, fixes, or portability requests. CX Codex +1 775installs dockerfile-generator dockerfile-generator — a skill that writes production-ready Dockerfiles and .dockerignore, validates them, then fixes what the validator flags. Handy when you need to containerize a service without hand-tuning layers. CX Codex +1 773installs gitlab-ci-validator gitlab-ci-validator validates syntax and security rules in .gitlab-ci.yml. Useful before opening a merge request to catch broken pipelines locally. CX Codex +1 758installs

Project sponsors

Companies that keep this analytics open