Indicating username with delegate_to

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:

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.

remote_user: on the same task should do just that.

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:

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.

Indeed, this is why I keep you around, sir :slight_smile:

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

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

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