I want to list ONLY Filenames dev.xml and prd.xml that contain a word called 
“vob.fi.ted.com". Im able to list all filenames dev.xml and prd.xml using find 
module but when I use contains parameter in playbook it doesn’t return those 
files although they have the string in their contents.

 

- hosts: test

  gather_facts: false

  become: yes

  become_user: root

  tasks:

  - name: Ansible find files examples

    find:

      paths: /opt/common

      patterns: "dev.xml,prd.xml"

      contains: "vob.fi.ted.com" -à This is not working

      recurse: yes

    register: files_to_find

 

  - debug:

     msg: "{{ files_to_find.files }}"

 

I get empty for list of files matched like below output.

However when I remove the contains: "vob.fi.ted.com" parameter , I get the list 
of matched files. All the files have 777 permission also.

 

 

 

OUTPUT

 

ok: [xxx.ted.com] => {

    "changed": false,

    "examined": 3408,

    "files": [],                                      ===============è File 
list is empty

    "invocation": {

        "module_args": {

            "age": null,

            "age_stamp": "mtime",

            "contains": "vob.fi.ted.com",

            "file_type": "file",

            "follow": false,

            "get_checksum": false,

            "hidden": false,

            "paths": [

                "/opt/common"

            ],

            "patterns": [

                "dev.xml",

                “prd.xml”

            ],

            "recurse": true,

            "size": null,

            "use_regex": true

        }

    },

    "matched": 0,

    "msg": ""

}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7442b324-6ea8-49ec-8cd3-b0c75456cd05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to