Copy all files with Ansible Copy

I wanted to copy all files in a directory, but didn’t want to create a “with_items” because I am lazy.

The solution is to use “with_fileglob” which can use wildcards and thus select multiple files.

## Example
- name: Copying certificates to tmp
  copy:
    src: "{{ item }}"
    dest: /tmp
    owner: apache
    group: apache
    mode: 0600
  with_fileglob:
    - "files/tmp/*"

This will copy all files in the tmp folder to the client.

Ps. Another option is to use synchronize, but you need rsync on the host and client which is why I prefer copy.