# local\_action: command rsync and {{ansible\_ssh\_user}}

**URL:** <https://forum.ansible.com/t/local-action-command-rsync-and-ansible-ssh-user/13711>\
**Category:** Ansible Project\
**Created:** [October 17, 2013, 9:38pm UTC](https://forum.ansible.com/t/local-action-command-rsync-and-ansible-ssh-user/13711 "2013-10-17T21:38:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirk\_Byers](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Kirk\_Byers](https://forum.ansible.com/u/Kirk_Byers)\
**Post date:** [October 17, 2013, 9:38pm UTC](https://forum.ansible.com/t/local-action-command-rsync-and-ansible-ssh-user/13711/1 "2013-10-17T21:38:28Z")

</div>

I am running ansible 1.3.3.

I am trying to do an rsync of a set of directories to a remote machine.

This works:

local\_action: command rsync -ae ssh /LOCAL\_PATH kbyers@{{ansible\_ssh\_host}}:/REMOTE\_PATH

But this doesn’t (only change is the ansible\_ssh\_user):

local\_action: command rsync -ae ssh /LOCAL\_PATH {{ansible\_ssh\_user}}@{{ansible\_ssh\_host}}:/REMOTE\_PATH

/etc/ansible/hosts has ansible\_ssh\_user=kbyers defined for this host.

Should this not work?

When the command that fails, the rsync tries to use the local\_user i.e. the user that I ran ansible-playbook as (I see in the output an SSH password prompt…local\_user@remote\_IP )

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 18, 2013, 4:29pm UTC](https://forum.ansible.com/t/local-action-command-rsync-and-ansible-ssh-user/13711/2 "2013-10-18T16:29:07Z")

</div>

When reporting a bug, please explain the behavior of the “doesn’t work” case.

---

<div class="post-metadata">

**Author:** ![Kirk\_Byers](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Kirk\_Byers](https://forum.ansible.com/u/Kirk_Byers)\
**Post date:** [October 19, 2013, 5:35pm UTC](https://forum.ansible.com/t/local-action-command-rsync-and-ansible-ssh-user/13711/3 "2013-10-19T17:35:23Z")

</div>

In the doesn’t work case the user that was used for the rsync SSH connection is not {{ansible\_ssh\_user}} instead it tried to use the local user that I ran the ansible-playbook as.

Kirk

---

<div class="post-metadata">

**Author:** ![Kirk\_Byers](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@Kirk\_Byers](https://forum.ansible.com/u/Kirk_Byers)\
**Post date:** [October 19, 2013, 6:31pm UTC](https://forum.ansible.com/t/local-action-command-rsync-and-ansible-ssh-user/13711/4 "2013-10-19T18:31:58Z")

</div>

Here are some more details:

Here is what my /etc/ansible/hosts looks like:

host1 ansible\_ssh\_host=X.X.X.X ansible\_ssh\_user=kbyers

Here is what the relevant section of my playbook looks like:

- hosts: host1

tasks:

- name: Sync code

local\_action: command rsync -ae ssh /LOCAL\_PATH {{ansible\_ssh\_user}}@{{ansible\_ssh\_host}}:/REMOTE\_PATH

When I execute the above playbook, I receive an SSH password prompt asking me to login to the remote machine (for local\_user@remote\_IP:) where local\_user is the user that I ran the playbook as (not user ‘kbyers’). If I change the above to kbyers@{{ansible\_ssh\_host}}:/REMOTE\_PATH, the playbook executes correctly with no password required (i.e. using SSH authorized\_keys).

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 20, 2013, 1:16am UTC](https://forum.ansible.com/t/local-action-command-rsync-and-ansible-ssh-user/13711/5 "2013-10-20T01:16:37Z")

</div>

Sounds like you need to set ansible\_ssh\_user in inventory to ‘kbeyers’.
