Install
openclaw skills install ansible-generatorGenerate, create, or scaffold Ansible playbooks, roles, tasks, handlers, inventory, vars.
openclaw skills install ansible-generatorUse this skill when the request is to generate or scaffold Ansible content, for example:
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.
Run these stages in order. Do not skip a stage unless the Validation Exceptions Matrix explicitly allows it.
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 |
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 |
Before drafting content, extract the following from local references/templates.
references/best-practices.md
references/module-patterns.md
assets/templates/playbook/basic_playbook.ymlassets/templates/role/ (including meta/argument_specs.yml and molecule/default/ for test scaffolding)assets/templates/inventory/hostsassets/templates/inventory/hosts.ymlassets/templates/project/ansible.cfg, assets/templates/project/requirements.yml, assets/templates/project/.ansible-lint[PLACEHOLDER] that must be replaced.ansible.builtin.* first).Apply these generation standards:
ansible.builtin.* first choice).state, creates/removes, changed_when when needed).true/false booleans (not yes/no).no_log: true for sensitive values.ansible.builtin.dnf for RHEL 8+/CentOS 8+ (legacy yum only for older systems).Use the matrix below to keep validation deterministic and non-blocking.
| 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 |
assets/templates/playbook/basic_playbook.yml as structure.pre_tasks/tasks/post_tasks as needed, handlers, tags.assets/templates/role/ structure.defaults/main.yml; keep higher-priority role vars in vars/main.yml.vars/Debian.yml, vars/RedHat.yml) when relevant.meta/argument_specs.yml for variable validation.molecule/default/ scaffold (from assets/templates/role/molecule/) for production-ready roles.group_vars/all.yml -> group -> host.hosts) for simple topologies; use YAML format (hosts.yml) when the user requests it or when the hierarchy is complex.ansible.cfg, requirements.yml, and .ansible-lint.When the request depends on non-builtin modules/collections:
references/module-patterns.md first.mcp__context7__resolve-library-idmcp__context7__query-docsAlways include collection installation guidance when collection modules are used.
User prompt: "Create a playbook to deploy nginx with TLS on Ubuntu and RHEL."
full-generation.best-practices.md, module-patterns.md) and playbook template.apt/dnf), handlers, validation for config templates.ansible-validator.User prompt: "Give me a snippet to create a user and SSH key."
snippet-only.ansible.builtin.user and ansible.builtin.authorized_key.For generated executable artifacts, use this response structure:
## 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:
## 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.