Synchronize module and with_first_found

Hi,

I (an Ansible newb) need to pass a directory of configuration files to
remote nodes, so that the files on the remote end should *exactly*
mirror what I have on the Ansible side. For instance, in my files
directory (using a role) I have the following directories

    etc/yum.repos.d-a.host.fqdn.example.com
    etc/yum.repos.d-b.host.fqdn.example.com
    etc/yum.repos.d-DEFAULT

with CentOS repository definitions inside. Each machine's repository
sources could be customized by making a new directory there with its
FQDN attached to the file name. I'm using the sychronize module in a
task like

    - name: Repository configuration
      synchronize: dest=/etc/yum.repos.d
                   src="{{ item }}"
                   recursive=yes delete=yes owner=no group=no
      with_first_found:
      - "etc/yum.repos.d-{{ ansible_fqdn }}"
      - "etc/yum.repos.d-DEFAULT"

This works incorrectly, since it will put the containing directory,
what has been properly found with with_first_found inside the
destination. This is a classic rsync "issue" easily solved by adding a
"/" at the end. I have tried several combinations an the only one that
I got working is by using src="{{ item }}/" instead of src="{{ item
}}".

I'm wondering if this is the intented behavior? Not world breaking at
all, but it made me wonder; and, of course, I could ways resort to
pure rsync.

Alternatively, what's the best way to synchronize directories based on
file name "templating"? The copy module works as expected but it is
one way as it will never delete on the remote what is not in the
source.

Best regards,
Carlos.

“This works incorrectly, since it will put the containing directory,
what has been properly found with with_first_found inside the
destination.”

Seems like you’d want the trailing slash here, since synchronize is in fact just a thin wrapper around

local_action: rsync …

Seems like you'd want the trailing slash here, since synchronize
is in fact just a thin wrapper around

local_action: rsync ...

I knew that the synchronize module was a wrapper over rsync. What's
new to me is that it is a local_action. I even seem to remember
synchronize failing when the remote system did not have rsync
installed. In any case, I'm experimenting exactly with that: a custom
local_action with rsync.

Thanks a lot,
Carlos.