I’m guessing this isn’t possible, but I might have been looking at it too long at this point to know if I’m missing something…
I have a playbook with a role in which one task has a remote_user and a delegate_to option set. That task has to run for each host on the delegate_to server which has a different ssh_user and password. Using ssh-keys or the same password as the ansible_ssh_user, it works okay, however, without ssh keys or the same password, it will fail.
For some people that will be executing this play, they will not be able to use ssh_keys and their passwords are different from the inventory and the delegate_to host. I could prompt for the remote_user and password on play run, however, I have not figured out how to set the password for the single task.
Here is an example. Is there a way to specify the password for jdoe? (note syntax and spacing may be off as I just typed this out)
- name: Sample play
hosts: all
roles:
- myRole
tasks:
debug:
msg: “End of play”
In the role/myRole/tasks/main.yml
-
include: myfacts.yml
-
name: Some task
command: test 0
changed_when: false -
name: Problem task
remote_user: jdoe
command: “shell command”
delegate_to: ###.###.###.###
- name: Some other task
command: “test -f file.txt”
register: myOutput
changed_when: false