On Tue, 8 Mar 2022 04:50:59 -0800 (PST)
"[email protected]" <[email protected]> wrote:

> Hi, I have the following task:
> 
> - ansible.builtin.copy:
> src: "{{ item }}"
> dest: /tmp/
> with_fileglob: "files/tmp/{{ inventory_hostname }}/*.yaml"
> 
> Directory files/tmp/bar/ contains yaml files for host *bar*.
> Directory files/tmp/foo/ doesn't exist because host *foo* should not 
> receive any files with this task.
> 
> If I run this task on hosts *bar* and *foo*, I always get a warning:
> [WARNING]: Unable to find 'files/tmp/foo' in expected paths (use -vvvvv to 
> see paths)

The simplest solution is to create empty directories if missing

    - ansible.builtin.file:
        state: directory
        path: "files/tmp/{{ inventory_hostname }}"
      delegate_to: localhost

    - ansible.builtin.copy:
        src: "{{ item }}"
        dest: /tmp/
      with_fileglob: "files/tmp/{{ inventory_hostname }}/*.yaml"


-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20220308150016.10db768a%40gmail.com.

Attachment: pgpfrmtQaK35k.pgp
Description: OpenPGP digital signature

Reply via email to