# Indicating username with delegate\_to

**URL:** <https://forum.ansible.com/t/indicating-username-with-delegate-to/13996>\
**Category:** Ansible Project\
**Created:** [November 25, 2013, 6:05pm UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996 "2013-11-25T18:05:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Swink](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@Joshua\_Swink](https://forum.ansible.com/u/Joshua_Swink)\
**Post date:** [November 25, 2013, 6:05pm UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/1 "2013-11-25T18:05:43Z")

</div>

Is there a way to indicate the remote username when using delegate\_to? I’m trying to use the Nagios plugin, but it tries to log in to the Nagios server as the name of the user on the service host. Here’s my example recipe for shutting down a service:

---

<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:** [November 26, 2013, 12:55am UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/2 "2013-11-26T00:55:41Z")

</div>

Delegate\_to will use the same credentials.

I think this would warrant something like “delegate\_user:” as a new keyword. If anyone wants to have at it, it would likely be accepted.

---

<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:** [November 26, 2013, 2:00am UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/3 "2013-11-26T02:00:35Z")

</div>

remote\_user: on the same task should do just that.

---

<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:** [November 26, 2013, 2:07am UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/4 "2013-11-26T02:07:55Z")

</div>

Yeah, this is true. Point!

Just start a new play for that task and start a new play immediately after if need be.

We should prefer this to a new keyword.

- hosts: webservers  
remote\_user: foo  
tasks:

- …

- hosts: webservers  
remote\_user: nagios  
tasks:

- …

- hosts: webservers  
remote\_user: foo  
tasks:

- …

---

<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:** [November 26, 2013, 2:15am UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/5 "2013-11-26T02:15:30Z")

</div>

since 1.4 you should not need to do it at play level, you should be able to specify remote\_user: at task level too.

---

<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:** [November 26, 2013, 2:15am UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/6 "2013-11-26T02:15:58Z")

</div>

Indeed, this is why I keep you around, sir 🙂

---

<div class="post-metadata">

**Author:** ![Ken\_Lemoine1](https://avatars.discourse-cdn.com/v4/letter/k/dfb087/32.png) [@Ken\_Lemoine1](https://forum.ansible.com/u/Ken_Lemoine1)\
**Post date:** [January 5, 2014, 3:21am UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/7 "2014-01-05T03:21:03Z")

</div>

I’d be interested. Cannot seem to find a way to use delegate\_to with a different username. Has anyone figured out a workaround?

---

<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:** [January 5, 2014, 6:56pm UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/8 "2014-01-05T18:56:37Z")

</div>

See what Brian said in this very thread about setting “remote\_user” on the task.

---

<div class="post-metadata">

**Author:** ![Ken\_Lemoine1](https://avatars.discourse-cdn.com/v4/letter/k/dfb087/32.png) [@Ken\_Lemoine1](https://forum.ansible.com/u/Ken_Lemoine1)\
**Post date:** [January 5, 2014, 7:59pm UTC](https://forum.ansible.com/t/indicating-username-with-delegate-to/13996/9 "2014-01-05T19:59:18Z")

</div>

Yes I saw that as soon as I sent that post. LOL. Thx!
