What is the ansible-lint tool?
ansible-lint checks playbooks for practices and behavior that could potentially be improved.
Ansible-Lint is a command-line tool for linting playbooks, roles, and collections aimed toward any Ansible users. Its main goal is to promote proven practices, patterns, and behaviors while avoiding common pitfalls that can easily lead to bugs or make code harder to maintain.
Links
- ansible-lint https://ansible-lint.readthedocs.io/
- Homebrew https://brew.sh/
Installation in macOS
Let’s install the ansible-lint
tool in macOS using the Homebrew package manager. I suppose the Homebrew is already installed using the Homebrew https://brew.sh/ website. The brew tool works on macOS Intel and Silicon (M1, M2, M1Pro, M2Pro, M1Max, M2Max, M1Ultra, M2Ultra).
before
% ansible-lint
zsh: command not found: ansible-lint
% brew search ansible-lint
==> Formulae
ansible-lint ansible ✔
==> Casks
ansible-dk
installation command
The installation command downloads the required files and dependencies (sqlite, ansible, black, pygments and yamllint) and install them in our system.
% brew install ansible-lint
execution
% brew install ansible-lint
==> Fetching dependencies for ansible-lint: sqlite, ansible, black, pygments and yamllint
==> Fetching sqlite
==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/manifests/3.41.0
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/19202efbc509ad22113d571d4b2aaa86fdbf2e3c5299fde49c6a0bb41d9b0328--sqlite-3.41.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/blobs/sha256:72073c161c9ee425437a
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/c1511ff7e302362a8736c0964fb633597bee677c78599790eb905eb3e5ff27f4--sqlite--3.41.0.arm64_ventura.bottle.tar.gz
==> Fetching ansible
==> Downloading https://ghcr.io/v2/homebrew/core/ansible/manifests/7.3.0
Already downloaded: /Users/lberton/Library/Caches/Homebrew/downloads/8abde3dff30d5f40dee39f30248a558f50232653b325325b924a206bf6cfb3ad--ansible-7.3.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ansible/blobs/sha256:11869f8ad5ad1d3ba34
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:1186
######################################################################## 100.0%
==> Fetching black
==> Downloading https://ghcr.io/v2/homebrew/core/black/manifests/23.1.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/black/blobs/sha256:ae6062bf90830375e496d
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ae60
######################################################################## 100.0%
==> Fetching pygments
==> Downloading https://ghcr.io/v2/homebrew/core/pygments/manifests/2.14.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pygments/blobs/sha256:d4b2214521e36150b2
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d4b2
######################################################################## 100.0%
==> Fetching yamllint
==> Downloading https://ghcr.io/v2/homebrew/core/yamllint/manifests/1.29.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/yamllint/blobs/sha256:27ce7abb1de9cd41d6
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:27ce
######################################################################## 100.0%
==> Fetching ansible-lint
==> Downloading https://ghcr.io/v2/homebrew/core/ansible-lint/manifests/6.14.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ansible-lint/blobs/sha256:df267ef8de202e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:df26
######################################################################## 100.0%
==> Installing dependencies for ansible-lint: sqlite, ansible, black, pygments and yamllint
==> Installing ansible-lint dependency: sqlite
==> Pouring sqlite--3.41.0.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/sqlite/3.41.0: 11 files, 4.5MB
==> Installing ansible-lint dependency: ansible
==> Pouring ansible--7.3.0.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/ansible/7.3.0: 29,252 files, 378.6MB
==> Installing ansible-lint dependency: black
==> Pouring black--23.1.0.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/black/23.1.0: 1,124 files, 13.9MB
==> Installing ansible-lint dependency: pygments
==> Pouring pygments--2.14.0.all.bottle.tar.gz
🍺 /opt/homebrew/Cellar/pygments/2.14.0: 624 files, 8.1MB
==> Installing ansible-lint dependency: yamllint
==> Pouring yamllint--1.29.0.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/yamllint/1.29.0: 821 files, 10.6MB
==> Installing ansible-lint
==> Pouring ansible-lint--6.14.0.arm64_ventura.bottle.tar.gz
🍺 /opt/homebrew/Cellar/ansible-lint/6.14.0: 1,351 files, 14.2MB
% brew search ansible-lint
==> Formulae
ansible-lint ✔ ansible ✔
==> Casks
ansible-dk
verification
% ansible-lint --version
ansible-lint 6.14.0 using ansible 2.14.3
Conclusion
Now you know how to install the ansible-lint
command line utility in macOS.
Academy
Learn the Ansible automation technology with some real-life examples in my Udemy 300+ Lessons Video Course.
My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
Donate
Want to keep this project going? Please donate