# New user: need support to exclude some files from directory for clang operation in yaml with ansible with zuul jobs

**URL:** <https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228>\
**Category:** Get Help\
**Tags:** yaml, zuul, ansible, ubuntu\
**Created:** [December 18, 2024, 8:19am UTC](https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228 "2024-12-18T08:19:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay107246](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Ajay107246](https://forum.ansible.com/u/Ajay107246)\
**Post date:** [December 18, 2024, 8:19am UTC](https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228/1 "2024-12-18T08:19:48Z")

</div>

I need support to exclude some files from directory for clang operation in yaml with ansible with zuul jobs.

purpose: I need to exclude unwanted files (e.g. exclude 4 / 10 files) from directory to perform clang operation in zuul jobs which is written in yaml with ansbile as below example:

I need help to correct this if there is any syntax issue / any other minor mistakes.

```auto
- job:
    name: clang-component1
    parent: base-clang-tools
    required-projects:
      - name: apps-project
    vars:
      app_name: component1
      repo_root: “{{ zuul.projects[‘url/apps-project’].src_dir }}”
      workspace: “{{ repo_root }}/inside1/component1”
      filtered_cpp_files: >-
      {{
        src_cpp_files.files | # something is missed?
        selectattr(‘path’, ‘search’, ‘^(?!.(file1.cpp|file2.cpp|file3.cpp))..cpp$’) |
        map(attribute=‘path’) |
        list
      }}
      filtered_hpp_files: >-
      {{
        src_cpp_files.files | # something is missed?
        selectattr(‘path’, ‘search’, ‘^(?!.(file1.hpp|file2.hpp|file3.hpp))..hpp$’) |
        map(attribute=‘path’) |
        list
      }}
      additionalsourcefiles: >-
      {{
        ‘dir1/src/*.hpp’,
        'dir1/inc/*.cpp’,
        ‘dir1/inc/*.hpp’
      }}
      runclangfiles: >-
      {{
        filtered_cpp_files + filtered_hpp_files + additionalsourcefiles
      }}
      analysis_code_paths: “{{ runclangfiles }}”

```

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [December 18, 2024, 12:12pm UTC](https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228/2 "2024-12-18T12:12:41Z")

</div>

Could you edit you post to use [fenced code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks) to make it easier to read?

---

<div class="post-metadata">

**Author:** ![Ajay107246](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Ajay107246](https://forum.ansible.com/u/Ajay107246)\
**Post date:** [December 18, 2024, 1:05pm UTC](https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228/3 "2024-12-18T13:05:24Z")

</div>

Hello @chris

I have updated my post, thank you for your suggestion.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [December 18, 2024, 2:01pm UTC](https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228/4 "2024-12-18T14:01:57Z")

</div>

I can’t help with clang or zuul but I’d suggest using the [debug module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html) to check the lists, for example:

```yaml
- name: Debug filtered_cpp_files
  ansible.builtin.debug:
    msg: >-
      {{
        src_cpp_files.files | # something is missed?
        selectattr(‘path’, ‘search’, ‘^(?!.(file1.cpp|file2.cpp|file3.cpp))..cpp$’) |
        map(attribute=‘path’) |
        list
      }}

- name: Debug filtered_hpp_files
  ansible.builtin.debug:
    msg: >-
      {{
        src_cpp_files.files | # something is missed?
        selectattr(‘path’, ‘search’, ‘^(?!.(file1.hpp|file2.hpp|file3.hpp))..hpp$’) |
        map(attribute=‘path’) |
        list
      }}
```

---

<div class="post-metadata">

**Author:** ![Ajay107246](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@Ajay107246](https://forum.ansible.com/u/Ajay107246)\
**Post date:** [December 18, 2024, 2:34pm UTC](https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228/5 "2024-12-18T14:34:17Z")

</div>

thank you,

where I can see debug messages with what value it is considering for this msg, in general?

basically here I need to exclude few files from directory and stored those file path in variable (if really needed as per Ansible syntax, format…) and use that files for further operation (can be anything, run clang, static\_code, etc.)

I would like to understand and correct above code.

NOTE: it is configure in CI, not locally

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [December 18, 2024, 2:51pm UTC](https://forum.ansible.com/t/new-user-need-support-to-exclude-some-files-from-directory-for-clang-operation-in-yaml-with-ansible-with-zuul-jobs/39228/6 "2024-12-18T14:51:24Z")

</div>

You should see the debug results wherever you see the output from Ansible running I guess?
