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

**URL:** <https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784>\
**Category:** Get Help\
**Tags:** gitlab, ci, awx, ansible-lint\
**Created:** [September 26, 2024, 8:07am UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784 "2024-09-26T08:07:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![falon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/falon/32/2081_2.png) [@falon](https://forum.ansible.com/u/falon)\
**Post date:** [September 26, 2024, 8:07am UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/1 "2024-09-26T08:07:17Z")

</div>

Hello,

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

```auto
<main folder>

     <.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:

```auto
$ 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](https://github.com/ansible/ansible-lint/issues/536#issuecomment-782658834).

```auto
# 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

```auto
# 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

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 26, 2024, 9:23am UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/2 "2024-09-26T09:23:38Z")

</div>

Hi.  
The tag [load-failure](https://ansible.readthedocs.io/projects/lint/rules/load-failure/) is not skippable.  
If you don’t want to lint a file; add it to exclude\_paths in your ansible-lint configuration file.

```yaml
$ cat .config/ansible-lint.yml
---
exclude_paths:
  - ".gitlab-ci.yml"

```

---

<div class="post-metadata">

**Author:** ![falon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/falon/32/2081_2.png) [@falon](https://forum.ansible.com/u/falon)\
**Post date:** [September 30, 2024, 2:32pm UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/3 "2024-09-30T14:32:28Z")

</div>

Thank you for this solution, it’s good for me.

I just have some doubts that `ansible-lint` must check a “special” file named _.gitlab-ci.yml_ by default.

Anyway I skip the file 🙂

Kind Regards  
Marco

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [September 30, 2024, 3:03pm UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/4 "2024-09-30T15:03:55Z")

</div>

> [@falon](#):
>
> I just have some doubts that `ansible-lint` must check a “special” file named _.gitlab-ci.yml_ by default.

The file is special to GitLab, but to everything else it is a regular YAML file. So why shouldn’t ansible-lint / yamllint it check it?

---

<div class="post-metadata">

**Author:** ![falon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/falon/32/2081_2.png) [@falon](https://forum.ansible.com/u/falon)\
**Post date:** [September 30, 2024, 3:26pm UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/5 "2024-09-30T15:26:21Z")

</div>

Yes, I explain: my doubt arises just from `.git/` folder.

`ansible-lint` seems to ignore it, if I don’t run it explicitly on the folder:

```shell
# cd project_dir_with_git_folder
# ansible-lint

Passed: 0 failure(s), 0 warning(s) on 19 files. Last profile that met the validation criteria was 'production'.

# ansible-lint .git/*

WARNING Listing 1 violation(s) that are fatal
load-failure: Failed to load or parse file.
.git/pippo.yml:1

             Rule Violation Summary
 count tag profile rule associated tags
     1 load-failure min core, unskippable

Failed: 1 failure(s), 0 warning(s) on 13 files.

```

Why is `.git` folder skipped then? 😅

It seems that `.git` folder is a special folder for `ansible-lint`. But `.gitlab-ci.yml` is not a special file.

Not very important really, just to understand 😉  
Thank you very much  
Kind Regards  
Marco

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [September 30, 2024, 8:31pm UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/6 "2024-09-30T20:31:24Z")

</div>

`.git` is special for Git, which is explicitly supported by ansible-lint (it ignores all files ignored by Git, including Git’s own housekeeping, which is in `.git`).

The reason why ansible-lint explicitly supports Git is that it’s the most common VCS used for Ansible roles and collections. That doesn’t mean it supports GitHub, GitLab, Gitea etc. specific files/directories though.

(There are some tools in the Ansible ecosystem which automatically handle Git repositories differently than regular directories, and some who do not. I’ve spent some time wondering whether this is a good idea, and what’s the best way to handle this. For antsibull-changelog I made this [configurable](https://ansible.readthedocs.io/projects/antsibull-changelog/changelog-configuration/#vcs-optional-string). I’m not sure that’s the best solution, but 🤷.)

---

<div class="post-metadata">

**Author:** ![falon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/falon/32/2081_2.png) [@falon](https://forum.ansible.com/u/falon)\
**Post date:** [October 1, 2024, 7:15am UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/7 "2024-10-01T07:15:21Z")

</div>

Now I understand, thank you for this kind clarification.

Kind Regards  
Marco

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 31, 2024, 7:15am UTC](https://forum.ansible.com/t/ansible-lint-how-to-exclude-gitlab-ci-yml-with-tag-reference/8784/8 "2024-10-31T07:15:26Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
