remote_user specified in play available to roles in the play

87 views
Skip to first unread message

Jeremy Gailor

unread,
Aug 26, 2014, 2:28:08 PM8/26/14
to ansible...@googlegroups.com
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.

Brian Coca

unread,
Aug 26, 2014, 6:26:20 PM8/26/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Aug 26, 2014, 7:04:59 PM8/26/14
to ansible...@googlegroups.com
Did you want to reference that variable in a template somewhere?




On Tue, Aug 26, 2014 at 6:26 PM, Brian Coca <bria...@gmail.com> wrote:
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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CADn%2BHsyZW0DzZj6e_98c%2BKcrq93ozz3a9ex%2Bk%2Binc%2BMXz6s0%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jeremy Gailor

unread,
Aug 27, 2014, 12:49:29 PM8/27/14
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Aug 27, 2014, 3:06:47 PM8/27/14
to ansible...@googlegroups.com
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 }}




Jeremy Gailor

unread,
Aug 27, 2014, 3:42:33 PM8/27/14
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Aug 27, 2014, 4:11:56 PM8/27/14
to ansible...@googlegroups.com
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.





Tomasz Kontusz

unread,
Aug 28, 2014, 2:27:14 AM8/28/14
to ansible...@googlegroups.com


Michael DeHaan <mic...@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?
><https://groups.google.com/d/msgid/ansible-project/CADn%2BHsyZW0DzZj6e_98c%2BKcrq93ozz3a9ex%2Bk%2Binc%2BMXz6s0%2BA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ansible Project" group.
>>>> To unsubscribe from this group and stop receiving emails from it,
>send
>>>> an email to ansible-proje...@googlegroups.com.
>>>> To post to this group, send email to ansible...@googlegroups.com.
>>>> To view this discussion on the web visit
>https://groups.google.com/d/
>>>> msgid/ansible-project/2efe7be0-435f-406b-bab6-
>>>> cebb7a5ec489%40googlegroups.com
>>>>
><https://groups.google.com/d/msgid/ansible-project/2efe7be0-435f-406b-bab6-cebb7a5ec489%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google
>Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it,
>send an
>> email to ansible-proje...@googlegroups.com.
>> To post to this group, send email to
>ansible...@googlegroups.com.
>> To view this discussion on the web visit
>>
>https://groups.google.com/d/msgid/ansible-project/d95ef348-b9fc-4c40-b523-67a23975b1c8%40googlegroups.com
>>
><https://groups.google.com/d/msgid/ansible-project/d95ef348-b9fc-4c40-b523-67a23975b1c8%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>

--
Wysłane za pomocą K-9 Mail.

Michael DeHaan

unread,
Aug 28, 2014, 5:00:48 PM8/28/14
to ansible...@googlegroups.com
I do.  Parameter is probably a good word.




Reply all
Reply to author
Forward
0 new messages