Ansible - fetch files from one remote node to another
2
votes
2
answers
3174
views
I'd like to use Ansible to upload files from local workstations to a NAS server. Both are managed via Ansible.
The only way I've gotten this to work so far is by mounting the NAS file share as a local directory via NFS, and delegating the copy tasks to the Ansible controller:
- name: Fetch files to NAS
fetch:
src: "{{ item.path }}"
dest: "/NAS/Share/{{inventory_hostname}}/" #
However, this solution is slow and error prone. In addition, I would like to start using Ansible tower, with which I don't think this solution will work at all.
Is this a feasible task to automate via Ansible?
The only solution I can think of is mounting the NAS to the workstations and copying it locally - something I'd prefer to avoid.
Any pointers would be greatly appreciated.
Thanks!
EDIT: Thanks to the great commenters below! I managed to use the synchronize
module from Linux workstations as suggested.
Unfortunately, some of the workstations run Windows, where the module isn't available.
The only currently working solution I could muster is using pscp
, which I prefer to avoid to keep things Ansible-only.
Is there another method I can use to fetch files from Windows workstations to the NAS?
Thanks!
Asked by dkd6
(87 rep)
Feb 7, 2023, 07:59 AM
Last activity: Feb 8, 2023, 02:47 PM
Last activity: Feb 8, 2023, 02:47 PM