Closed jedla01 closed 4 years ago
I've passed through this
types: [file]
- tracks only files! not dicts ! They use identity lib which allows to set types: [dictionary]
, but in case of git it will be only submodule dict.
So there is no way
with pre-commit to pass directories at all.
I tried and ended with pre-commit hook which wraps ansible-lint: /tasks/
in path/tasks/
- it should be path to the roleSo this work for roles
ansible-lint .
to just ansible-lint
types: [yaml]
- so you have only .yaml and .yml@ssbarnea ^
I've passed through this
@Woytek-Polnik can you paste your config so we can use it as an example?
@jedla01 Please pot link to repo which reproduces the issue with latest version of ansible-lint, I am 99% sure that https://pypi.org/project/ansible-lint/4.2.0/ fixed it.
Thanks all. The original test were conducted on non-public role repo. I will retest with the last ansible-lint version and in case of issue, I will create public repo with example.
I've passed through this
@Woytek-Polnik can you paste your config so we can use it as an example?
https://github.com/zerodowntime/ansible-lint-roles-precommit-hook maybe will be helpfull
# Ansible lint roles
- repo: https://github.com/zerodowntime/ansible-lint-roles-precommit-hook.git
rev: v1.0.0
hooks:
- id: ansible-lint-roles
files: /tasks/ # reflects tasks
exclude: (roles.d) # I have own roles in `roles` dir and 3rd-party roles in `roles.d`
args: [-c, .ansible-lint.yml]
stages: [commit]
# Ansible lint playbooks
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.2.0rc1
hooks:
- id: ansible-lint
name: Ansible lint for playbooks
types: [text, yaml] # reflects yaml changes
files: /playbooks/ # we have all playbooks in 1 dir so we can contrain its path
args: [-c, .ansible-lint.yml]
pass_filenames: true
always_run: false
stages: [manual] # I have it manually because in playbooks I use `lookup env pwd` which breaks my paths
# Ansible lint inventory
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.2.0rc1
hooks:
- id: ansible-lint
name: Ansible lint for inventory
types: [text, yaml] # reflects yaml changes
files: /inventory/
exclude: vault
args: [-c, .ansible-lint.yml]
pass_filenames: true
stages: [commit]
is this still relevant?
No relevant anymore.
Issue Type
Ansible and Ansible Lint details
Desired Behaviour
While developing an ansible role, where root of repository is the root of a role, having set no ansible-lint rules executions nor custom rules, the output from
ansible-lint .
andpre-commit run --all-files
should be same or results from from should be at least subset of errors found to the other test. (As runningansible-lint
is not run against tests folder).Actual Behaviour (Bug report only)
When running
ansible-lint .
in to role folder I am getting errors in tasks, mostly 305 Use shell only when shell functionality is required. While runningpre-commit run --all-files
or run on the file directly founds no errors at all. Pre-commit config: