Sample Header Ad - 728x90

Ansible Synchronize - run task with different remote user

2 votes
1 answer
4511 views
I apologize in advance if this is documented somewhere or on the site - I could not find a solution and so I'm asking here. I'm trying to use Ansible's synchronize module to pull files from a remote host, like so:
- hosts: Server.A
  gather_facts: no
  tasks:
    synchronize:
      mode: pull
      src: "file/to/pull"
      dest: "path/to/destination"
    delegate_to: NAS
That is, I want the NAS host to SSH into Server.A and pull the files I'd like to upload. The problem is, the NAS has a non-default user (admin). I set the NAS's admin user via the inventory file, and I can communicate with the NAS ok. However, when I run the
task, it attempts to login to the source server (Server.A) with the admin user, which does not exist, and fails. I've tried changing the
,
the module's
settings, in the playbook, the hosts file and the host_vars, but I can't get it to work and find it very confusing. How would I go about running the
command as a different remote user instead of the local one? Thanks!
Asked by dkd6 (87 rep)
Mar 29, 2021, 12:23 PM
Last activity: May 25, 2025, 03:02 PM