I'm using the following task in my Ansible script to copy all files from a local data folder to the server:
- name: copy basic files to folder
  copy:
    src: "{{ item }}"
    dest: ~/data/
    mode: 755
    owner: "www-data"
    group: "www-data"
  with_fileglob:
    - ../files/data/*
This works fine, except for that it skips hidden files (such as .htaccess).
Does anybody know how I can make with_fileglob also include hidden files?
Ok, found the answer myself. I found that with_fileglob simply calls the python glob.glob() function. So after some fideling around I found  just had to add a fileglob with .* to it:
- name: copy basic files to folder
  copy:
    src: "{{ item }}"
    dest: ~/data/
    mode: 755
    owner: "www-data"
    group: "www-data"
  with_fileglob:
    - ../files/data/*
    - ../files/data/.*
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With