# remote\_user specified in play available to roles in the play

**URL:** <https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043>\
**Category:** Ansible Project\
**Created:** [August 26, 2014, 6:28pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043 "2014-08-26T18:28:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Gailor](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@Jeremy\_Gailor](https://forum.ansible.com/u/Jeremy_Gailor)\
**Post date:** [August 26, 2014, 6:28pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/1 "2014-08-26T18:28:08Z")

</div>

One thing I’ve noticed, and have not been able to find a resolution to via IRC or reading the source, is how to make the remote\_user var set at the play level available to all roles in the play. It’s useful to have this for a few tasks, and while it’s easy enough to define it under the roles, it’s just c/p’ing code at that point and doesn’t feel right or as clean as the rest of Ansible can be. I think this would be really useful to add as behavior.

---

<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:** [August 26, 2014, 10:26pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/2 "2014-08-26T22:26:16Z")

</div>

Not sure what you mean. When set at play level, all tasks by default will use that remote\_user. you can override on specific tasks with different remote\_user.​ Of course unless hostvars override with ansible\_ssh\_user

---

<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:** [August 26, 2014, 11:04pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/3 "2014-08-26T23:04:54Z")

</div>

Did you want to reference that variable in a template somewhere?

---

<div class="post-metadata">

**Author:** ![Jeremy\_Gailor](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@Jeremy\_Gailor](https://forum.ansible.com/u/Jeremy_Gailor)\
**Post date:** [August 27, 2014, 4:49pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/4 "2014-08-27T16:49:28Z")

</div>

I was running a playbook and referencing remote\_user in a file under /roles/my\_role/tasks/deploy.yml, (included in /roles/my\_role/tasks/main.yml) and Ansible was giving me an error that {{remote\_user}} did not exist.

---

<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:** [August 27, 2014, 7:06pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/5 "2014-08-27T19:06:44Z")

</div>

This isn’t an output variable that you can use in a template anywhere.

You may be interested in the value of {{ ansible\_ssh\_user }}

---

<div class="post-metadata">

**Author:** ![Jeremy\_Gailor](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@Jeremy\_Gailor](https://forum.ansible.com/u/Jeremy_Gailor)\
**Post date:** [August 27, 2014, 7:42pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/6 "2014-08-27T19:42:32Z")

</div>

Michael,

This is super helpful. Thanks. Since you would be in the know, is there any reason that remote\_user is not passed down to roles, etc.? It seems like it would be something useful to have access to, and was a surprise when I didn’t.

---

<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:** [August 27, 2014, 8:11pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/7 "2014-08-27T20:11:53Z")

</div>

It is – it’s called ansible\_ssh\_user.

Originally the variable in ansible was called “user” but to avoid confusion when used with the “user” module, remote\_user is an alias.

---

<div class="post-metadata">

**Author:** ![Tomasz\_Kontusz](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@Tomasz\_Kontusz](https://forum.ansible.com/u/Tomasz_Kontusz)\
**Post date:** [August 28, 2014, 6:26am UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/8 "2014-08-28T06:26:59Z")

</div>

Michael DeHaan \<michael@ansible.com\> napisał:

> It is -- it's called ansible\_ssh\_user.
> 
> Originally the variable in ansible was called "user" but to avoid  
> confusion  
> when used with the "user" module, remote\_user is an alias.

You mean "task parameter" (or are they called arguments?), and not "variable", right?

---

<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:** [August 28, 2014, 9:00pm UTC](https://forum.ansible.com/t/remote-user-specified-in-play-available-to-roles-in-the-play/16043/9 "2014-08-28T21:00:44Z")

</div>

I do. Parameter is probably a good word.
