Ansible find files only if contains particular string

I need a small help in writing an ansible playbook. I have written the below till now which is listing all files with config basically. but I need to filter out the files which are basically .git/config

- hosts: all
  connection: local
  gather_facts: no

  - name: "Serching old git URL"
    become: true
    become_user: root
      paths: builds
      file_type: file
      recurse: yes
        - config$
      use_regex: true
      contains: ''

    register: configfiles
  - debug:
      msg: "{{configfiles.files | map(attribute='path')| list }}"

Below is the 0utput


Thanks you for the help

Asked By: Siba Swain


There is an excludes option to the find command that I think will do what you want.
excludes: ‘.*./.git.config’

Answered By: user103944
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.