# ansible sudo example in docs fails

**URL:** <https://forum.ansible.com/t/ansible-sudo-example-in-docs-fails/28778>\
**Category:** Ansible Project\
**Created:** [October 13, 2018, 3:05am UTC](https://forum.ansible.com/t/ansible-sudo-example-in-docs-fails/28778 "2018-10-13T03:05:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dean\_Schulze](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Dean\_Schulze](https://forum.ansible.com/u/Dean_Schulze)\
**Post date:** [October 13, 2018, 3:05am UTC](https://forum.ansible.com/t/ansible-sudo-example-in-docs-fails/28778/1 "2018-10-13T03:05:17Z")

</div>

I’m new to Ansible and working through the Getting Started in the docs. It shows to use sudo mode just add --sudo flag, but that fails:

ansible tv -m ping (works)

ansible tv -m ping --sudo (fails with sudo: a password is required)

Shouldn’t Ansible prompt me for a password for sudo mode?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 13, 2018, 5:48am UTC](https://forum.ansible.com/t/ansible-sudo-example-in-docs-fails/28778/2 "2018-10-13T05:48:21Z")

</div>

> I'm new to Ansible and working through the Getting Started in the docs. It  
> shows to use sudo mode just add --sudo flag, but that fails:

Do you mean this one  
[https://docs.ansible.com/ansible/2.7/user\_guide/intro\_getting\_started.html](https://docs.ansible.com/ansible/2.7/user_guide/intro_getting_started.html)

If so, I do recommend reading everything on that page first, because the information you are asking is there just a little scattered around on the page.

> ansible tv -m ping (works)  
> ansible tv -m ping --sudo (fails with sudo: a password is required)
> 
> Shouldn't Ansible prompt me for a password for sudo mode?

> From the bottom of this section

[https://docs.ansible.com/ansible/latest/user\_guide/intro\_getting\_started.html#remote-connection-information](https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html#remote-connection-information)

&nbsp;&nbsp;"If using sudo features and when sudo requires a password, also supply --ask-become-pass (previously --ask-sudo-pass which has been deprecated)."

--sudo is also deprecated you find that information in the example in this section  
[https://docs.ansible.com/ansible/2.7/user\_guide/intro\_getting\_started.html#your-first-commands](https://docs.ansible.com/ansible/2.7/user_guide/intro_getting_started.html#your-first-commands)

&nbsp;&nbsp;# With latest version of ansible `sudo` is deprecated so use become  
&nbsp;&nbsp;# as bruce, sudoing to root"  
&nbsp;&nbsp;$ ansible all -m ping -u bruce -b

The -b is short version of --become that has replaced -s/--sudo, and the example should have used --become instead of -b to make it more clear.

Good luck in your quest to learn Ansible it's a great tool.
