Indicating username with delegate_to

1,642 views
Skip to first unread message

Joshua Swink

unread,
Nov 25, 2013, 1:05:43 PM11/25/13
to ansible...@googlegroups.com
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:

---
- hosts: abc_hosts
  serial: 1
  tasks:
  - name: Disable Nagios alerts
    nagios: host={{ ansible_ssh_host }} action=silence
    delegate_to: nagios.myplace.xyz
  - name: Disable ABC service
    shell: service ABC stop


If the username on abc_hosts is "abc" and the username on the Nagios server is "nagios", the plugin will try to log in to nagios.myplace.xyz as "abc". I need it to use user "nagios" here.

Michael DeHaan

unread,
Nov 25, 2013, 7:55:41 PM11/25/13
to ansible...@googlegroups.com
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.





--
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.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Brian Coca

unread,
Nov 25, 2013, 9:00:35 PM11/25/13
to ansible...@googlegroups.com
remote_user: on the same task should do just that.

Michael DeHaan

unread,
Nov 25, 2013, 9:07:55 PM11/25/13
to ansible...@googlegroups.com
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:
     - ...







On Mon, Nov 25, 2013 at 9:00 PM, Brian Coca <bria...@gmail.com> wrote:
remote_user: on the same task should do just that.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Brian Coca

unread,
Nov 25, 2013, 9:15:30 PM11/25/13
to ansible...@googlegroups.com
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.

Michael DeHaan

unread,
Nov 25, 2013, 9:15:58 PM11/25/13
to ansible...@googlegroups.com
Indeed, this is why I keep you around, sir :)




On Mon, Nov 25, 2013 at 9:15 PM, Brian Coca <bria...@gmail.com> wrote:
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.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Ken Lemoine

unread,
Jan 4, 2014, 10:21:03 PM1/4/14
to ansible...@googlegroups.com
I'd be interested.  Cannot seem to find a way to use delegate_to with a different username.  Has anyone figured out a  workaround?

Michael DeHaan

unread,
Jan 5, 2014, 1:56:37 PM1/5/14
to ansible...@googlegroups.com
See what Brian said in this very thread about setting "remote_user" on the task.





--
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.

For more options, visit https://groups.google.com/groups/opt_out.

Ken Lemoine

unread,
Jan 5, 2014, 2:59:18 PM1/5/14
to ansible...@googlegroups.com
Yes I saw that as soon as I sent that post. LOL. Thx!

Sent from my mobile.  Please excuse the brevity, spelling & punctuation.
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/-gr3k70JNlw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages