How to copy directory recursively using pattern to remote machine?

Hello All,

I have got the following playbooks where i am trying to copy directories and all its contents recursively which is present in project repo. For identifying the correct directory, i am using a variable which holds the pattern value. For some reason, the task is skipped and the full verbose too doesn’t give me enough information about where it is failing. Can someone please suggest.

`

Hello All,

I have got the following playbooks where i am trying to copy directories and all its contents recursively which is
present in project repo. For identifying the correct directory, i am using a variable which holds the pattern value. For
some reason, the task is skipped and the full verbose too doesn't give me enough information about where it is failing.
Can someone please suggest.

>
---
-hosts:all
gather_facts:no
become:yes
vars:
appid:'1554'
tasks:
-name:Copyeach file over that matches the given pattern
copy:
src:"{{ item }}"
dest:"/tmp"
with_fileglob:
-/home/DS/ram/playbooks/app_dir_{{appid }}*

I think you need to wrap the argument into double_quotes like that:

with_fileglob:
  - "/home/DS/ram/playbooks/app_dir_{{appid }}*"

Otherwise it wouldn't interpolate the appid variable.

Regards
  Racke

Hi Stefan,

Thanks for your comment, i am getting the same issue even after putting that in double quotes.

you are not passing a 'glob' to fileglob, in any case the problem is
that it is returning an empty list, examine it in a debug statement
until you get the output you expect.