# Is remote\_user used if I want to carry out action as that user rathe than ssh\_user?

**URL:** <https://forum.ansible.com/t/is-remote-user-used-if-i-want-to-carry-out-action-as-that-user-rathe-than-ssh-user/16236>\
**Category:** Ansible Project\
**Created:** [September 15, 2014, 11:40pm UTC](https://forum.ansible.com/t/is-remote-user-used-if-i-want-to-carry-out-action-as-that-user-rathe-than-ssh-user/16236 "2014-09-15T23:40:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Wong](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://forum.ansible.com/u/John_Wong)\
**Post date:** [September 15, 2014, 11:40pm UTC](https://forum.ansible.com/t/is-remote-user-used-if-i-want-to-carry-out-action-as-that-user-rathe-than-ssh-user/16236/1 "2014-09-15T23:40:09Z")

</div>

my ansible\_ssh\_user is root, but I want a particular role to use a particular user.

For example, create a directory with this remote\_user as owner and group. I know I can set the owner-permission using file module, but I was expecting the following to work

- hosts: webservers  
remote\_user: “meow”  
roles:
- clone\_repo

tasks:

- name: write directory  
file: path=/home/meow/dir state=directory

In addition to directory creation, clone\_repo actually clone a repo. But remote\_user is not actually used. They are root/root.

Did I misread the doc? [http://docs.ansible.com/playbooks\_intro.html#hosts-and-users](http://docs.ansible.com/playbooks_intro.html#hosts-and-users)

Thanks

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [September 16, 2014, 12:27am UTC](https://forum.ansible.com/t/is-remote-user-used-if-i-want-to-carry-out-action-as-that-user-rathe-than-ssh-user/16236/2 "2014-09-16T00:27:20Z")

</div>

Are you setting ansible\_ssh\_user = root in the inventory file? If so, then yep, this is how ansible is designed but it does confuse people. There’s a few bug reports where the concepts are explained:

[https://github.com/ansible/ansible/issues/4688](https://github.com/ansible/ansible/issues/4688)  
[https://github.com/ansible/ansible/issues/4622](https://github.com/ansible/ansible/issues/4622)

The bug reports also point at a workaround that might work for your use case:

- hosts: webservers

vars:

- ansible\_ssh\_user: “meow”

roles:

- clone\_repo

tasks:

- name: write\_directory  
file: path=/home/meow/dir state=directory

-Toshio

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [September 16, 2014, 2:24am UTC](https://forum.ansible.com/t/is-remote-user-used-if-i-want-to-carry-out-action-as-that-user-rathe-than-ssh-user/16236/3 "2014-09-16T02:24:22Z")

</div>

for a task that you don't want to run as root add:

sudo: yes  
sudo\_user: nonrootuser
