ansible-fix

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.

16 stars

Best use case

ansible-fix is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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.

Teams using ansible-fix should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/ansible-fix/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/devops/ansible-fix/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/ansible-fix/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How ansible-fix Compares

Feature / Agentansible-fixStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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 comments
  - `schema[meta]` - Unquoted version strings
  - `meta-incorrect` - Placeholder metadata values
  - `name[play]` - Unnamed plays
  - `role-name[path]` - Incorrect role import paths

## What It Fixes

The skill runs a Python script that automatically corrects:

1. **yaml[comments]**: Adds space after `#` in comments
   - `#comment` → `# comment`

2. **schema[meta]**: Quotes numeric version strings
   - `min_ansible_version: 2.1` → `min_ansible_version: "2.1"`

3. **meta-incorrect**: Replaces placeholder values with sensible defaults
   - `author: your name` → `author: Ansible User`
   - `company: your company (optional)` → `company: Community`
   - `license: license (GPL-2.0-or-later, MIT, etc)` → `license: MIT`

4. **name[play]**: Adds descriptive names to unnamed plays
   - Adds `name: Test playbook for <hosts>` to plays

5. **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:

1. **Identify the role path** from context (e.g., if you just ran `ansible-galaxy init roles/nginx`, the path is `roles/nginx`). Do not ask the user - proceed automatically.

2. **Run the fixer script**:
   ```bash
   uv run .claude/skills/ansible-fix/ansible-lint-fix.py <role_path>
   ```

   Example:
   ```bash
   uv run .claude/skills/ansible-fix/ansible-lint-fix.py roles/nginx
   ```

3. **Review the output** to see what was fixed:
   - Number of files modified
   - Types of fixes applied
   - Count of each fix type

4. **Verify the fixes** by running ansible-lint:
   ```bash
   ansible-lint <role_path> 2>&1
   ```

5. **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](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`).

Related Skills

ansible

16
from diegosouzapw/awesome-omni-skill

Provides comprehensive guidance for Ansible automation including playbooks, roles, inventory, and module usage. Use when the user asks about Ansible, needs to automate IT tasks, create Ansible playbooks, or manage infrastructure with Ansible.

ansible-workflow

16
from diegosouzapw/awesome-omni-skill

Ansible automation workflow guidelines. Activate when working with Ansible playbooks, ansible-playbook, inventory files (.yml, .ini), or Ansible-specific patterns.

ansible-validator

16
from diegosouzapw/awesome-omni-skill

Comprehensive toolkit for validating, linting, testing, and automating Ansible playbooks, roles, and collections. Use this skill when working with Ansible files (.yml, .yaml playbooks, roles, inventories), validating automation code, debugging playbook execution, performing dry-run testing with check mode, or working with custom modules and collections.

ansible-testinfra

16
from diegosouzapw/awesome-omni-skill

Bootstrap minimal testinfra pytest suite for an Ansible role and remind to run via uv

ansible-roles

16
from diegosouzapw/awesome-omni-skill

Use when structuring and reusing code with Ansible roles for modular, maintainable automation and configuration management.

ansible-role-init

16
from diegosouzapw/awesome-omni-skill

Scaffold a new Ansible role via ansible-galaxy init

ansible-playbooks

16
from diegosouzapw/awesome-omni-skill

Use when writing and organizing Ansible playbooks for automated configuration management and infrastructure orchestration.

ansible-playbook

16
from diegosouzapw/awesome-omni-skill

Write and review Ansible playbooks following best practices. Use when the user says "write ansible", "ansible playbook", "review playbook", "automate with ansible", or asks to configure servers with Ansible.

ansible-inventory

16
from diegosouzapw/awesome-omni-skill

Use when managing hosts and groups in Ansible inventory for organizing infrastructure and applying configurations across environments.

ansible-host-limiter

16
from diegosouzapw/awesome-omni-skill

Ensures ansible and ansible-playbook commands always include the -l (limit) flag to target only ndelucca-server and prevent accidental execution on raspberry-printer or other hosts. Activate this skill whenever running any ansible or ansible-playbook commands.

ansible-expert

16
from diegosouzapw/awesome-omni-skill

Expert-level Ansible for configuration management, automation, and infrastructure as code

ansible-dev-setup

16
from diegosouzapw/awesome-omni-skill

Generate and manage cross-platform Ansible playbooks for development environment setup across macOS, Linux, and Termux. Use when working with development environment automation, package installation configuration, or Ansible playbook generation.