ansible-fix
Automatically corrects linting errors in Ansible roles, including formatting, metadata, and naming issues.
Install
mkdir -p .claude/skills/ansible-fix && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16410" && unzip -o skill.zip -d .claude/skills/ansible-fix && rm skill.zipInstalls to .claude/skills/ansible-fix
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
ALWAYS use this skill immediately after running 'ansible-galaxy init' to create a new Ansible role. Also use when the user asks to fix ansible-lint errors or when ansible-lint output shows fixable issues like yaml[comments], schema[meta], meta-incorrect, name[play], or role-name[path] violations.Key capabilities
- →Add space after '#' in comments.
- →Quote numeric version strings in schema metadata.
- →Replace placeholder values in `meta-incorrect` fields.
- →Add descriptive names to unnamed plays.
- →Fix role import paths.
- →Scan all YAML files in a role directory.
How it works
The skill runs a Python script that scans YAML files in a specified Ansible role directory and applies regex-based fixes for common ansible-lint issues.
Inputs & outputs
When to use ansible-fix
- →Fixing lint errors in Ansible roles
- →Standardizing metadata in new roles
- →Formatting YAML comments
- →Correcting role-name path violations
About this skill
Ansible Lint Auto-Fixer
This skill automatically fixes common ansible-lint errors that can be easily automated, saving time when creating new Ansible roles.
When to Use This Skill
ALWAYS invoke this skill proactively:
- Immediately after running
ansible-galaxy init roles/<name> - Do NOT wait for the user to ask - fix lint issues automatically
- This provides a better user experience by delivering clean, lint-free roles
Also use when:
- User explicitly asks to fix ansible-lint errors
- ansible-lint output shows any of these fixable errors:
yaml[comments]- Missing space after # in commentsschema[meta]- Unquoted version stringsmeta-incorrect- Placeholder metadata valuesname[play]- Unnamed playsrole-name[path]- Incorrect role import paths
What It Fixes
The skill runs a Python script that automatically corrects:
-
yaml[comments]: Adds space after
#in comments#comment→# comment
-
schema[meta]: Quotes numeric version strings
min_ansible_version: 2.1→min_ansible_version: "2.1"
-
meta-incorrect: Replaces placeholder values with sensible defaults
author: your name→author: Ansible Usercompany: your company (optional)→company: Communitylicense: license (GPL-2.0-or-later, MIT, etc)→license: MIT
-
name[play]: Adds descriptive names to unnamed plays
- Adds
name: Test playbook for <hosts>to plays
- Adds
-
role-name[path]: Fixes role import paths
roles/nginx→nginx
Instructions
IMPORTANT: This skill should be invoked automatically whenever you create a new role with ansible-galaxy init. Do not wait for the user to ask - proactively fix lint issues to provide a clean role.
When invoked, follow these steps:
-
Identify the role path from context (e.g., if you just ran
ansible-galaxy init roles/nginx, the path isroles/nginx). Do not ask the user - proceed automatically. -
Run the fixer script:
uv run .claude/skills/ansible-fix/ansible-lint-fix.py <role_path>Example:
uv run .claude/skills/ansible-fix/ansible-lint-fix.py roles/nginx -
Review the output to see what was fixed:
- Number of files modified
- Types of fixes applied
- Count of each fix type
-
Verify the fixes by running ansible-lint:
ansible-lint <role_path> 2>&1 -
Report results to the user:
- Show summary of fixes applied
- Confirm if all issues are resolved (0 failures, 0 warnings)
- If issues remain, explain what still needs manual fixing
Supporting Files
The skill uses the ansible-lint-fix.py script. This script:
- Scans all YAML files in the role directory
- Applies regex-based fixes for common patterns
- Reports detailed statistics on what was changed
Examples
Example 1: After creating a new role
User: I just created a new nginx role with ansible-galaxy init roles/nginx
Assistant: [Invokes ansible-fix skill]
- Runs: uv run .claude/skills/ansible-fix/ansible-lint-fix.py roles/nginx
- Reports: Fixed 12 issues across 6 files
- Verifies: ansible-lint shows 0 failures, 0 warnings
Example 2: Fixing existing linting issues
User: Can you fix the ansible-lint errors in my web-server role?
Assistant: [Invokes ansible-fix skill]
- Runs: uv run .claude/skills/ansible-fix/ansible-lint-fix.py roles/web-server
- Reports: Fixed 8 issues across 4 files
- Verifies: ansible-lint results
Best Practices
- Always run ansible-lint after using this skill to verify fixes
- The script is idempotent - safe to run multiple times
- Some issues may require manual intervention (explained in output)
- Review changes before committing to ensure they match project standards
Limitations
This skill only fixes syntactic and formatting issues. It does not:
- Write role tasks or handlers
- Configure role variables
- Implement role logic
- Fix complex YAML structural problems beyond the patterns it recognizes
- Fix role naming issues (role names must match
^[a-z][a-z0-9_]*$- lowercase, numbers, underscores only, no hyphens)
For complex linting issues or role development, manual intervention is needed.
Note: If ansible-lint reports role-name errors about the role name not matching the required pattern, the role directory itself needs to be renamed (e.g., test-role → test_role).
When not to use it
- →When the task is not related to fixing ansible-lint errors.
- →When the user does not want to fix ansible-lint errors.
- →When ansible-lint output does not show fixable issues.
Limitations
- →Only fixes syntactic and formatting issues.
- →Does not write role tasks or handlers.
- →Does not fix complex YAML structural problems.
How it compares
This workflow automates the correction of common ansible-lint errors, providing a clean role without manual editing.
Compared to similar skills
ansible-fix side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| ansible-fix (this skill) | 0 | 5mo | Review | Beginner |
| kcli-plan-authoring | 0 | 4mo | Review | Advanced |
| iot-engineer | 0 | 4mo | No flags | Advanced |
| dev-skills | 0 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by diegosouzapw
View all by diegosouzapw →You might also like
kcli-plan-authoring
karmab
Guides creation of kcli plan files for deploying VMs, networks, and infrastructure. Use when writing YAML plans with Jinja2 templating or debugging plan execution issues.
iot-engineer
Sneha-1608
Use when designing and deploying IoT solutions requiring expertise in device management, edge computing, cloud integration, and handling challenges like massive device scale, complex connectivity scenarios, or real-time data pipelines.
dev-skills
AWDSCAN
devops ruler
azure-mgmt-apicenter-py
bika11
|
writing-nix
khaneliman
Writes idiomatic, performant, and maintainable Nix code. Covers best practices, anti-patterns to avoid (like `with`), module system design, and performance optimization.
ops
denniszielke
>