见 https://stackoverflow.com/questions/42186301/ansible-create-multiple-folders-if-dont-exist
见 https://stackoverflow.com/questions/25505146/how-to-copy-files-between-two-nodes-using-ansible
- hosts: ServerB
tasks:
- name: Transfer file from ServerA to ServerB
synchronize:
src: /path/on/server_a
dest: /path/on/server_b
delegate_to: ServerA
-----
- hosts: ServerA
tasks:
- name: Transfer file from ServerA to ServerB
synchronize:
src: /path/on/server_a
dest: /path/on/server_b
mode: pull
delegate_to: ServerB
亲测有效