Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Installing

Install Ansible-lint to apply rules and follow best practices with yourautomation content.

Note

Ansible-lint does not currently support installation on Windows systems.

Warning

Ansible-lint does not support any installation methods that are not mentioned inthis document. Before raising any bugs related to installation, review all ofthe following details:

  • You should use the installation methods outlined in this document only.
  • You should upgrade the Python installer (pip orpipx) to the latest version available from pypi.org. If you use a system package manager, you will need to upgrade the installer to a newer version.
  • If you are installing from a git zip archive, which is not supported but should work, ensure you use the main branch and the latest version of pip and setuptools.
  • If you are installing Ansible-lint within a container or system package, you should not report the issue here. Contact the relevant container or package provider instead.
  • If you are usingpoetry, read thisdiscussion.

Pull requests to improve installation instructions are welcome. Any new issuesrelated to the installation will be closed and locked.

For a container image, we recommend usingcommunity-ansible-dev-toolswhich includesansible-dev-tools (it combines critical Ansible development packages intoa unified Python package). If you have a use case that thecommunity-ansible-dev-toolscontainer doesn't satisfy, please contact the team through thediscussion forum.

You can also run Ansible-lint on your source code with theAnsible-lint GitHub actioninstead of installing it directly.

Installing the latest version

Recommendation

Therecommended approach to installansible-lint is using theansible-dev-tools package.Ansible Development Toolsaims to streamline the setup and usage of several tools needed in order tocreateAnsible content. It combines critical Ansibledevelopment packages into a unified Python package.

# This also installs ansible-core if it is not already installedpip3installansible-dev-tools

You can install the most recent version of Ansible-lint with thepip3 orpipx Python package manager. Usepipx to isolate Ansible-lint from yourcurrent Python environment as an alternative to creating a virtual environment.

# This also installs ansible-core if it is not already installedpip3installansible-lint

Note

If you want to install the exact versions of all dependencies that were used totest a specific version of ansible-lint, you can addlock extra. This willonly work with Python 3.10 or newer. Do this only inside a virtual environment.

pip3install"ansible-lint[lock]"

Installing on Fedora and RHEL

You can install Ansible-lint on Fedora, or Red Hat Enterprise Linux (RHEL) withthednf package manager.

dnfinstallansible-lint

Note

On RHEL,ansible-lint package is part of "Red Hat Ansible AutomationPlatform" subscription, which needs to be activated.

Installing from source code

Note:pip>=22.3.1 is required for installation from the source repository.Please consult thePyPA User Guide to learn more about managing Pip versions.

pip3installgit+https://github.com/ansible/ansible-lint

Installing Ansible Lint as a GitHub Action

To use the action simply create a file.github/workflows/ansible-lint.yml withcontent similar to the example below:

# .github/workflows/ansible-lint.ymlname:ansible-linton:pull_request:branches:["stable","release/v*"]jobs:build:name:Ansible Lint# Naming the build is important to use it as a status checkruns-on:ubuntu-24.04steps:-uses:actions/checkout@v4-name:Run ansible-lintuses:ansible/ansible-lint@main# optional (see below):with:args:""setup_python:"true"working_directory:""requirements_file:""

All the arguments are optional and most users should not need them:

  • args: Arguments to be passed to ansible-lint command.
  • setup_python: If python should be installed. Default istrue.
  • working_directory: The directory where to run ansible-lint from. Default isgithub.workspace. That might be needed if you want to lint only a subset of your repository.
  • requirements_file: Path to the requirements.yml file to install role and collection dependencies.

Due to limitations on how GitHub Actions are processing arguments, we do notplan to provide extra options. You will have to make use ofansible-lint own configuration fileto alter its behavior.

Installing roles and collections from private repositories

To install roles and collections from private repositories, you can:

  1. Create anaccess token
  2. Add the token as andeploy secret
  3. Add the following step before the ansible-lint step.
-name:Prepare Git for Githubshell:bashrun:|git config --global url."https://${{ secrets.ANSIBLE_LINT_TOKEN }}@github.com".insteadOf "https://github.com"

[8]ページ先頭

©2009-2025 Movatter.jp