I am trying to add a validation step to a gitlab repo holding a single ansible role (with no playbook). The structure of the role looks like :
- .gitlab-ci.yml
- tasks/
- templates/
- files/
- vars/
- handlers/
With the gitlab-ci looking like :
stages:
- lint
job-lint:
image:
name: cytopia/ansible-lint:latest
entrypoint: ["/bin/sh", "-c"]
stage: lint
script:
- ansible-lint --version
- ansible-lint . -x 106 tasks/*.yml
I need to skip the naming rule, thus ignoring rule 106. Otherwise, I would like all files at the root repo to be checked. Since there is no playbook, lint has to be given the files that need to be checked... or at least, that is what I understoodd : I may have this point wrong. But anyway, if I give no name, lint does return ok but actually performs no check.
My problem is that I don't know how to tell him to check all the yaml in a recursive way, or even within a subdirectory. The above code returns an error :
ansible-lint: error: unrecognized arguments: tasks/deploy.yml tasks/localhost.yml tasks/main.yml tasks/managedata.yml tasks/psqlconf.yml
Any idea on how to check all the files from a subdirectory or through the whole role?
PS : I am using cytopia image for ansible-lint, but I have no problem using another, provided it's hosted on dockerhub.
You should certainly be able to pass multiple YAML files as arguments to
ansible-lint
. I have version4.1.1a0
, and I'm able to use it like this, for example:I notice that you seem to have placed a
.
before your-x 106
; that looks like an error. It doesn't look likeansible-lint
will accept a directory name as an argument (it doesn't cause it to fail; it just doesn't accomplish anything).I've tried this both with a locally installed
ansible-lint
and using thecytopia/ansible-lint
image, which appears to perform identically: