Skip to content

Support running ansible-lint --fix automatically on save in VSCode #2151

@localleon

Description

@localleon

Problem

Currently, the VSCode Ansible extension provides linting via ansible-lint, but does not support automatic fixing on save. The new --fix flag (see ansible-lint autofix docs) allows for auto-remediation of detected issues. Integrating this as an optional or default behavior on save would streamline workflows and improve playbook quality.

Solution

  • When saving an Ansible YAML file, VSCode should run ansible-lint --fix.
  • Optionally, provide a configuration toggle to enable/disable autofix on save.
  • Show user feedback if fixes are applied or if errors occur.

This could be compared to a feature like Autoformatting on save from e.g. the RedHat YAML Extension

Alternatives

No response

Additional context

  • Reduces manual effort for fixing lint errors.
  • Keeps playbooks clean and consistent.
  • Leverages new capabilities in ansible-lint for a modern development experience.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions