ansible sudo example in docs fails

15 views
Skip to first unread message

Dean Schulze

unread,
Oct 12, 2018, 11:05:17 PM10/12/18
to Ansible Project
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?




Kai Stian Olstad

unread,
Oct 13, 2018, 1:48:33 AM10/13/18
to ansible...@googlegroups.com
On Saturday, 13 October 2018 05.05.17 CEST Dean Schulze wrote:
> 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

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

"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

# With latest version of ansible `sudo` is deprecated so use become
# as bruce, sudoing to root"
$ 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.


--
Kai Stian Olstad


Reply all
Reply to author
Forward
0 new messages