expected sudo prompt

32 views
Skip to first unread message

reapso...@gmail.com

unread,
Jun 21, 2017, 12:30:03 PM6/21/17
to Ansible Project
Hi,

I hit a snag using "become/sudo". I can become/sudo to the root user if the prompt that is returned is as expected (I think). For example, here is the default prompt.

[sudo] password for testuser:

I think Ansible expects some variation of the prompt above to which it sends the become/sudo password.

If the prompt looks like below (its still a sudo prompt, just not the default)

enter PASSCODE:

become/sudo will fail. I think its because the module, whatever module/code that it is, expects a return prompt similar to the default.

I would like to edit the file that expects this prompt to allow for the additional return prompt. I don't know which .py file that would be. I am open to other suggestions. I reviewed the vars_prompt documentation, but I am not sure how I would set it.

Thanks.

Madhu

unread,
Jun 22, 2017, 2:11:27 AM6/22/17
to ansible...@googlegroups.com
You have to use ansible_sudo_pass keyword to set the sudo password.

Sent from my iPhone
--
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/007024ff-3185-4c67-b776-5f8ea2d4faa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Jun 22, 2017, 9:22:51 AM6/22/17
to Ansible Project
Ansible uses `sudo -p` to set the prompt it gets, so it always matches.


----------
Brian Coca

Imre Széll

unread,
Jul 3, 2017, 8:51:51 AM7/3/17
to Ansible Project
I'm afraid it is not entirely true. I suffer from this issue as well.
I have a few machines that are centrally managed and the sudo password prompt is set to a fixed string. This setting overrides what Ansible or command line invocation specifies with -p flag. The other part of the problem is that Ansible does not handle if I specify my own prompt with the sudo_flags in the configuration file - it will use two -p flags on the final command (like: -p "from config" -p "generated") which still won't match the string in my case. Is there another way to handle this issue?

Brian Coca

unread,
Jul 3, 2017, 10:05:04 AM7/3/17
to Ansible Project
no, if you are overriding -p, Ansible won't be able to match the prompt.


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages