Synchronize module does not allow set local user

I want to copy a directory from local (usign nekmo user) to a remote server (usign xxxxx_ssh user). I have the following:

  • hosts: vhome
    remote_user: xxxxxx_ssh
    tasks:
  • name: Rsync
    synchronize: dest=/home/webs/DOCS/django src={{ project_path }}/docs/_build/html

This works remotely but not locally:

GATHERING FACTS ***************************************************************
<vhome.xxxxx.es> ESTABLISH CONNECTION FOR USER: xxxxx_ssh
<vhome.xxxxx.es> REMOTE_MODULE setup

ok: [vhome.xxxxx.es]

TASK: [Rsync] *****************************************************************
<127.0.0.1> ESTABLISH CONNECTION FOR USER: xxxxx_ssh
[…]
Permission denied (publickey,password).

The local user must be “nekmo”. If I do not put “remote_user” param this does not work remotely (this use “nekmo” as remote user).

I need to set the local user, or afford to ignore the parameter “remote_user” for localhost.

remote_user is ignored on local connections, ansible will always run
with the user that ran ansible (unless you use sudo).