Use `synchronize:` delegated to the remote host instead of running
`rsync` directly with `command:`.
gather_facts: false
tasks:
- name: "Update ~root - sync directories from ~phd"
- command: "rsync -rlt --info=name ~phd/{{ item }} ~root"
- register: rsync
- changed_when: rsync.stdout != ''
+ synchronize:
+ src: "~phd/{{ item }}"
+ dest: ~root
+ archive: no # avoid setting owner/group
+ recursive: yes
+ links: yes
+ times: yes
+ delegate_to: "{{ inventory_hostname }}"
loop: ['.vim', 'bin', 'lib']
- name: "Update ~root - sync files from ~phd"