How do I get the find module to work in Ansible? My playbook does not create a /tmp/results.txt file, but I expect it to do so with the content of the results of the find module.

Here is my playbook:

- name: Do stuff
  become: yes
  hosts: fun
  tasks:
  - name: Delete directory
    find:
      paths: /home/jdoe/subdir
      patterns: "jj*jj"
      use_regex: yes
    register: find_results
  - shell: "echo {{ item.path }} &gt; /tmp/results.txt"
    with_items: "{{ find_results.files }}"


A managed node with the "fun" label has this subdirectory:
/home/jdoe/subdir/jj3jj/

What is wrong with my playbook?
Remove use_regex: yes. Quoting from the doc


  If false the patterns are file globs (shell) if true they are python regexes.


If you want to use Python regex then the pattern would be probably something like this

patterns: '[j]{2}.[j]{2}'


You probably want to append to file >>

echo {{ item.path }} &gt;&gt; /tmp/results.txt