The find module doesn't seem to work with certain file types (block devices)

Just curious if this is a bug in the find module or if it’s working as intended?

Running ansible 2.0.0.2

Demo snippet:

`

  • name: module find mpath
    find: paths=‘/dev/mapper’ patterns=‘mpathp
    register: modfind_result

  • debug: var=modfind_result

  • name: shell find mpath
    shell: find /dev/mapper -name mpathp
    register: shfind_result

  • debug: var=shfind_result

`

Output:

`

TASK [module find mpath] *******************************************************
ok: [devwebdb0]

TASK [debug] *******************************************************************
ok: [devwebdb0] => {
“modfind_result”: {
“changed”: false,
“examined”: 3,
“files”: ,
“matched”: 0,
“msg”: “”
}
}

TASK [shell find mpath] ********************************************************
changed: [devwebdb0]

TASK [debug] *******************************************************************
ok: [devwebdb0] => {
“shfind_result”: {
“changed”: true,
“cmd”: “find /dev/mapper -name mpathp”,
“delta”: “0:00:00.404326”,
“end”: “2016-02-10 14:51:21.624126”,
“rc”: 0,
“start”: “2016-02-10 14:51:21.219800”,
“stderr”: “”,
“stdout”: “/dev/mapper/mpath5p1”,
“stdout_lines”: [
“/dev/mapper/mpath5p1”
],
“warnings”:
}
}

`

modfind_result.examined=3, so it appears to be seeing the device files, however modfind_result.files=, which would make me think it’s not matching the pattern. Using patterns=“*” or leaving it out entirely returns the same results however, and it works just fine if I try and match against a text or binary file.

find uses stat.S_ISREG to check if it is a regular file, so devices, sockets, pipes will all be ignored, we might want to add an option to control the file types.