@@ -57,17 +57,54 @@ Keep in mind that this will override any existing file content.
5757
5858## Pre-commit setup
5959
60- To use Ansible-lint with [ pre-commit] , add the following to the
60+ To use Ansible-lint with the [ pre-commit] tool , add the following to the
6161` .pre-commit-config.yaml ` file in your local repository.
6262
63+ Do not confuse the [ pre-commit] tool with the git hook feature that has the same name.
64+ While the [ pre-commit] tool can also make use of git hooks, it does not require
65+ them and it does not install them by default.
66+
67+ [ pre-commit.ci] is a hosted service that can run pre-commit for you
68+ on each change but you can also run the tool yourself using the CI of your choice.
69+
6370Change ** rev:** to either a commit sha or tag of Ansible-lint that contains
6471` .pre-commit-hooks.yaml ` .
6572
6673``` yaml
74+ ---
75+ ci :
76+ # This section is specific to pre-commit.ci, telling it to create a pull request
77+ # to update the linter version tag every month.
78+ autoupdate_schedule : monthly
79+ # If you have other Ansible collection dependencies (requirements.yml)
80+ # `pre-commit.ci` will not be able to install them because it runs in offline mode,
81+ # and you will need to tell it to skip the hook.
82+ # skip:
83+ # - ansible-lint
84+ repos :
6785- repo : https://github.com/ansible/ansible-lint
6886 rev : ... # put latest release tag from https://github.com/ansible/ansible-lint/releases/
6987 hooks :
7088 - id : ansible-lint
89+ # Uncomment if you need the full Ansible community bundle instead of ansible-core:
90+ # additional_dependencies:
91+ # - ansible
7192```
7293
94+ !!! warning
95+
96+ [pre-commit] always uses python virtual environments. If you happen to
97+ use the [Ansible package] instead of just [ansible-core] you might be surprised
98+ to see that pre-commit is not able to find these collections, even if
99+ your local Ansible does. This is because they are installed inside a location
100+ that is not available to the virtual environment in which pre-commit hook
101+ is installed. In this case, you might want to uncomment the commented lines
102+ from the hook definition above, so the bundle will be installed.
103+
104+ You should note that collection installed into `~/.ansible` are found by
105+ the hook.
106+
73107[ pre-commit ] : https://pre-commit.com/
108+ [ Ansible package ] : https://pypi.org/project/ansible/
109+ [ ansible-core ] : https://pypi.org/project/ansible-core/
110+ [ pre-commit.ci ] : https://pre-commit.ci/
0 commit comments