Ansible-lint: how to exclude .gitlab-ci.yml with tag !reference

falon
Thu, 26 Sep 2024 08:07:17 +0000
Get Help

Hello,

I have an Ansible workspace folder for AWX with playbooks of this type:



     <.git folder>
     <collections folder>
     .gitlab-ci.yml
     <many playbook files>.yml

.gitlab-ci.yml contains a !reference tag, which passes yamllint tests and the pipeline syntax check too:

parallel: !reference [.parallel-hidden-job, parallel]

When I run ansible-lint in the main folder I see:

$ cd main folder
$ ansible-lint

WARNING  Listing 1 violation(s) that are fatal
load-failure[runtimeerror]: Failed to load YAML file: .gitlab-ci.yml
.gitlab-ci.yml:1 could not determine a constructor for the tag '!reference'
  in "<unicode string>", line 63, column 13

This file is not a playbook. I read here that it should not get an error from the linter.

# ansible-lint --version
ansible-lint 24.9.2 using ansible-core:2.16.11 ansible-compat:24.9.1 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8

Now I adopt these workarounds:

run ansible-lint --exclude .gitlab-ci.yml

or

# cat .ansible-lint-ignore
.gitlab-ci.yml  load-failure[runtimeerror]

which produces a warning.

Maybe there are better solutions.

Thank you very much for every hints.
Kind Regards
Marco

8 posts - 4 participants