# remote\_user task override not working

**URL:** <https://forum.ansible.com/t/remote-user-task-override-not-working/14807>\
**Category:** Ansible Project\
**Created:** [March 19, 2014, 4:31pm UTC](https://forum.ansible.com/t/remote-user-task-override-not-working/14807 "2014-03-19T16:31:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bernat\_Rafales](https://avatars.discourse-cdn.com/v4/letter/b/a698b9/32.png) [@Bernat\_Rafales](https://forum.ansible.com/u/Bernat_Rafales)\
**Post date:** [March 19, 2014, 4:31pm UTC](https://forum.ansible.com/t/remote-user-task-override-not-working/14807/1 "2014-03-19T16:31:58Z")

</div>

Hi,

I have a playbook in which I need to run tasks with different remote users.

This is what the main playlist looks like:

`  
#Configure and install all we need

- hosts: ec2hosts  
gather\_facts: true  
remote\_user: ec2-user  
sudo: yes  
roles:
- common

`

And all tasks that have to be run as ec2-user work great.

However, I need to run some of the tasks with a different user, named rails. In order to do this, I specify the remote\_user parameter in the task, but for some reason, the task is still executed as ec2-user:

`

- name: rbenv // basic test  
shell: ls -lah  
remote\_user: rails  
sudo: no  
tags: rbenv

`

Resulting in this:

`  
TASK: [common | rbenv // basic test] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<54.73.67.35\> ESTABLISH CONNECTION FOR USER: ec2-user  
\<54.73.67.35\> REMOTE\_MODULE command ls -lah #USE\_SHELL  
\<54.73.67.35\> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/bernatrafalesimulet/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ec2-user’, ‘-o’, ‘ConnectTimeout=10’, u’54.73.67.35’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216 && echo $HOME/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216’”]  
\<54.73.67.35\> PUT /var/folders/mg/1txhtf2d6c1fx4mzmvp9zlbc0000gn/T/tmpcdqUUp TO /home/ec2-user/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216/command  
\<54.73.67.35\> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/Users/bernatrafalesimulet/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=ec2-user’, ‘-o’, ‘ConnectTimeout=10’, u’54.73.67.35’, “/bin/sh -c ‘/usr/bin/python /home/ec2-user/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216/command; rm -rf /home/ec2-user/.ansible/tmp/ansible-tmp-1395246103.49-134656247335216/ \>/dev/null 2\>&1’”]  
changed: [54.73.67.35] =\> {“changed”: true, “cmd”: "ls -lah ", “delta”: “0:00:00.009791”, “end”: “2014-03-19 16:21:53.695525”, “item”: “”, “rc”: 0, “start”: “2014-03-19 16:21:53.685734”, “stderr”: “”, “stdout”: “total 28K\ndrwx------ 4 ec2-user ec2-user 4.0K Mar 19 16:21 .\ndrwxr-xr-x 4 root root 4.0K Mar 19 16:21 …\ndrwxrwxr-x 3 ec2-user ec2-user 4.0K Mar 19 16:21 .ansible\n-rw-r–r-- 1 ec2-user ec2-user 18 Sep 4 2013 .bash\_logout\n-rw-r–r-- 1 ec2-user ec2-user 176 Sep 4 2013 .bash\_profile\n-rw-r–r-- 1 ec2-user ec2-user 124 Sep 4 2013 .bashrc\ndrwx------ 2 ec2-user ec2-user 4.0K Feb 17 10:29 .ssh”}

`

Which shows me the list of files of the ec2-user home folder.

Is there any particular reason why I can’t override the remote\_user, or what am I doing wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![Tonatiuh\_IIII](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@Tonatiuh\_IIII](https://forum.ansible.com/u/Tonatiuh_IIII)\
**Post date:** [April 2, 2014, 2:03pm UTC](https://forum.ansible.com/t/remote-user-task-override-not-working/14807/2 "2014-04-02T14:03:18Z")

</div>

I have the same problem, don’t know why, this should be working. I would really appreciate some help there.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 2, 2014, 8:04pm UTC](https://forum.ansible.com/t/remote-user-task-override-not-working/14807/3 "2014-04-02T20:04:30Z")

</div>

Sounds like you are saying the remote\_user on the task attribute is not overriding the remote\_user on the host.

If you see this behavior on 1.5.3 and later, can you please check to see if you see this behavior on the development branch, and if so, file a bug?

Thank you!

---

<div class="post-metadata">

**Author:** ![Alex\_Dupuy](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Alex\_Dupuy](https://forum.ansible.com/u/Alex_Dupuy)\
**Post date:** [June 5, 2014, 1:16pm UTC](https://forum.ansible.com/t/remote-user-task-override-not-working/14807/4 "2014-06-05T13:16:07Z")

</div>

I am seeing this issue with 1.5.5 and now 1.6.2, so I have filed a bug: [https://github.com/ansible/ansible/issues/7673](https://github.com/ansible/ansible/issues/7673)

@alex

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [June 5, 2014, 4:26pm UTC](https://forum.ansible.com/t/remote-user-task-override-not-working/14807/5 "2014-06-05T16:26:46Z")

</div>

As noted in the issue above, previously this has been caused by setting the ansible\_ssh\_user variable in inventory. I have tested the provided playbook with both the 1.6.2 and devel branches and cannot reproduce the issue outside of setting that variable in inventory.

Holding the issue open for now, but most likely the inventory variable is the issue here.

---

<div class="post-metadata">

**Author:** ![Alex\_Dupuy](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Alex\_Dupuy](https://forum.ansible.com/u/Alex_Dupuy)\
**Post date:** [June 5, 2014, 9:33pm UTC](https://forum.ansible.com/t/remote-user-task-override-not-working/14807/6 "2014-06-05T21:33:58Z")

</div>

James Cammarata was exactly right - my problem was an inventory issue. In my case, the `ansible_ssh_user` was not in the inventory file itself, but rather in the `group_vars/all` file and a more specific `group_vars/newservers` file (the more specific one overrode to match the play’s `remote_user` setting, while the `group_vars/all` value was the same as the task setting, adding to my confusion). I closed the GitHub issue - thanks for pointing me in the right direction.
