Using ansible-lint with Git's pre-commit

While browsing randomly, I stumbled upon the linter for Ansible called, you guess it, ansible-lint. However, another interesting utility came up called pre-commit, which is a framework to manage your Git's pre-commit hooks.

Installation is simple. Use `pip` to install it.
$ sudo -H pip install pre-commit

Create the config file, `.pre-commit-config.yaml` and add the content below.
- repo:
  sha: v3.3.3
    - id: ansible-lint
      files: \.(yaml|yml)$

Install the necessary tool.
$ pre-commit autoupdate
Updating up to date.

Install to the repository's `pre-commit` hook.
$ pre-commit install
pre-commit installed at /home/ang/src/dotfiles-ansible/.git/hooks/pre-commit
$ git commit
[INFO] Installing environment for
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...

No comments:

Post a Comment