Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Ansible with_fileglob include hidden files?

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?

like image 590
kramer65 Avatar asked Nov 30 '22 08:11

kramer65


1 Answers

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/.*
like image 142
kramer65 Avatar answered Feb 07 '23 03:02

kramer65