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.