I am trying to copy a bunch of files from server X (not control machine) to a group of servers,targets: Y1, Y2, ..., Yn (defined in host file)
files:
'-path
'- files
'- file1
'- file2
'- dir
'- file_x
My playbook:
#!/usr/bin/env ansible-playbook
---
vars:
src_dir: /path/files
hosts: {{ targets }}
tasks:
- name: copying files
command: "rsync -avrcz X:{{ src_dir }}/{{ artifacts }} {{ dest_dir }}"
My command line:
./playbook.yml -e '{"targets": "targets", "artifacts" : "{file1,file2,dir/file_x}", "dest_dir": "/yserv/dest/path"}'
This works and I am able to parallelize pretty decently, but I keep getting:
[WARNING]: Consider using synchronize module rather than running rsync
Is there a way to achieve this using synchronize module? Ansible doesn't seem to like bash brace expansion syntax. Passing file list as an array and using with_items is not practical since it makes the whole thing sequential by invoking rsync multiple times and hence very slow (there is a huge list of files to copy)
"You still may need to call rsync directly via command or shell
depending on your use case. synchronize does not provide access to the
full power of rsync, but does make most invocations easier to follow."
> Is, what I am trying to do, beyond Ansible's scope?
No, but the module have not implemented everything and what you are
trying to do is probably not implemented yet.
It OK to use command and shell module, they are included for a reason.
> If not, how should
> I do it? If yes, is there a better tool to achieve this?
- If you have the skills, you could make the changes to the module and
send a pull request on Github.
- Alternative is to pay someone to do it for you.
- Or just use command module and rsync.