excludes not work as expected with find module in ansible playbook

I have created an ansible playbook which finds files older than 7 days and zips the files.

Also trying to exclude files from particular directory but not able to find.

I am not able to the exclude the files under sub directory ,it is also getting zipped
I am able to successfully exclude the already zipped files but not a sub directory under the path

using excludes in find module for compressing files older than 7 days

I have created an ansible playbook which finds files older than 7 days and zips the files.
Also trying to exclude files from particular directory but not able to find.

I am not able to the exclude the files under sub directory ,it is also getting zipped
I am able to successfully exclude the already zipped files but not a sub directory under the path

using excludes in find module for compressing files older than 7 days

Please share your playbook.

Regards
         Racke

Hi Racke,

Please find the below playbook details the username and path are test paths

Hi Racke,

Please find the below playbook details the username and path are test paths

---
- name: Ansible archive Examples
hosts: all
tasks:

\- name : Find files ending with extensions
  become: true
  find:
   paths:
   \- /home/nsubbaraj/replicate/vol/gunnsc01/prod/scoreout
   recurse: yes
   file\_type: any
   excludes:
   \- '\*\.gz'
   \- /home/nsubbaraj/replicate/vol/gunnsc01/prod/scoreout/delete
   depth: 4
   age: 7d
   age\_stamp: mtime
  register: output

\- name: archive the files
  become: yes
  archive:
    remove: yes
    path: "\{\{ item\.path \}\}"
    dest: "\{\{ item\.path \}\}\-\{\{ansible\_date\_time\.date\.replace\('\-',''\)\}\}\.gz"
    format: zip
  with\_items: "\{\{ output\.files \}\}"

##############################

I am able to exclude the gzip files but not the delete directory files under
/home/nsubbaraj/replicate/vol/gunnsc01/prod/scoreout/

I think the values for "excludes" need to be relative to the path(s), so try "delete"
instead of "/home/nsubbaraj/replicate/vol/gunnsc01/prod/scoreout/delete".

Regards
        Racke

Thanks ,I had tried already and tried again but no luck .

I tried with