# expected sudo prompt

**URL:** <https://forum.ansible.com/t/expected-sudo-prompt/24768>\
**Category:** Ansible Project\
**Created:** [June 20, 2017, 2:01am UTC](https://forum.ansible.com/t/expected-sudo-prompt/24768 "2017-06-20T02:01:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![reapsowrepeat](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@reapsowrepeat](https://forum.ansible.com/u/reapsowrepeat)\
**Post date:** [June 20, 2017, 2:01am UTC](https://forum.ansible.com/t/expected-sudo-prompt/24768/1 "2017-06-20T02:01:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Madhu](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Madhu](https://forum.ansible.com/u/Madhu)\
**Post date:** [June 22, 2017, 6:11am UTC](https://forum.ansible.com/t/expected-sudo-prompt/24768/2 "2017-06-22T06:11:11Z")

</div>

You have to use ansible\_sudo\_pass keyword to set the sudo password.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 22, 2017, 1:22pm UTC](https://forum.ansible.com/t/expected-sudo-prompt/24768/3 "2017-06-22T13:22:36Z")

</div>

Ansible uses `sudo -p` to set the prompt it gets, so it always matches.

---

<div class="post-metadata">

**Author:** ![Imre\_Szell](https://avatars.discourse-cdn.com/v4/letter/i/58956e/32.png) [@Imre\_Szell](https://forum.ansible.com/u/Imre_Szell)\
**Post date:** [July 3, 2017, 9:14am UTC](https://forum.ansible.com/t/expected-sudo-prompt/24768/4 "2017-07-03T09:14:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [July 3, 2017, 2:04pm UTC](https://forum.ansible.com/t/expected-sudo-prompt/24768/5 "2017-07-03T14:04:52Z")

</div>

no, if you are overriding -p, Ansible won't be able to match the prompt.
