/ansible-lint

ansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for you

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

PyPI version Ansible-lint rules explanation Discussions pre-commit

Ansible-lint

ansible-lint checks playbooks for practices and behavior that could potentially be improved. As a community-backed project ansible-lint supports only the last two major versions of Ansible.

Visit the Ansible Lint docs site

Using ansible-lint as a GitHub Action

This action allows you to run ansible-lint on your codebase without having to install it yourself.

# .github/workflows/ansible-lint.yml
name: ansible-lint
on:
  pull_request:
    branches: ["main", "stable", "release/v*"]
jobs:
  build:
    name: Ansible Lint # Naming the build is important to use it as a status check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run ansible-lint
        uses: ansible/ansible-lint@main # or version tag instead of 'main'

For more details, see ansible-lint-action.

Using ansible-lint with Trunk Check

trunk check is a meta-linter which allows you to run ansible-lint on your codebase without having to install it yourself, and can scan all of your files or only the most recent changes.

Once you have initialized trunk in your repo, to enable the latest ansible-lint, just run:

trunk check enable ansible-lint

Then just run:

trunk check

and it will check your modified files via ansible-lint and, if applicable, show you the results. For more information, check the trunk docs. You can also see ansible-lint issues inline in VS Code via the Trunk VS Code extension. The code for the integration is here.

Contributing

Please read Contribution guidelines if you wish to contribute.

Licensing

The ansible-lint project is distributed as GPLv3 due to use of GPLv3 runtime dependencies, like ansible and yamllint.

For historical reasons, its own code-base remains licensed under a more liberal MIT license and any contributions made are accepted as being made under original MIT license.

Authors

ansible-lint was created by Will Thames and is now maintained as part of the Ansible by Red Hat project.