Ansible: get files list from local directory

ansible

I use ansible 1.9.4 and I would like to get the list of files from a local directory.

In 2.0 version, there is the find module but this version is beta.

How to do this in < 2.0 ?

Best Answer

Some time ago I was building an automation that required something like that - see Ansible send file to the first met destination.

Prior to ansible 2.0 there's no way to do this without using command or shell.

If you really can't upgrade to ansible 2.0, use the command module:

vars:
  directory: /path/to/dir

tasks:

  - command: "ls {{directory}}"
    register: dir_out

  - debug: var={{item}}
    with_items: dir_out.stdout_lines