-b and password prompting in ansible 1.9

352 views
Skip to first unread message

Anand Buddhdev

unread,
Mar 26, 2015, 12:06:21 PM3/26/15
to ansible...@googlegroups.com
I usually use ansible with the "-sK" flags (use sudo, and ask for sudo password). Now I've noticed the new "-b" flag. So I wanted to use it, but I'm told I can't use "-b" and "-K" together. So I have to type:

-b --ask-become-pass

Is there a plan to introduce a short form for --ask-become-pass?

Regards,
Anand

Brian Coca

unread,
Mar 26, 2015, 12:18:17 PM3/26/15
to ansible...@googlegroups.com
I was actually planning to soften the restriction and allow -K to work with -b




--
Brian Coca

Vince Skahan

unread,
Mar 28, 2015, 10:29:47 PM3/28/15
to ansible...@googlegroups.com
On Thursday, March 26, 2015 at 9:18:17 AM UTC-7, Brian Coca wrote:
I was actually planning to soften the restriction and allow -K to work with -b



That would be helpful.

The new syntax is unclear to me, and I'm not understanding why you deprecated the old clear/concise syntax.

Consider a raspberry pi where you login as user 'pi' and sudo your commends:

old:
 -k -u pi --sudo
new:
    -k -u pi -b --become-user=root --become-method=sudo

Or do your defaults mean that the new way would just be:
      -k -u pi -b

(in which case, what value was replacing a nice and clear/concise --sudo with a cryptic -b where we need to know the defaults for which user and method) ?

Brian Coca

unread,
Mar 29, 2015, 2:39:02 AM3/29/15
to ansible...@googlegroups.com
First, the sudo and su options continue to work, so you can continue
to run the commands as you did before.

The new 'become' is to have a single way to deal with the expanding
privilege escalation methods (pbrun, pfexec, runas, etc).

Sadly making something more flexible tends to add complexity, a 3rd
parameter in this case 'become_method'. Sudo is set as the default for
this, but you can change this in ansible.cfg to suit your needs.

--
Brian Coca

Anand Buddhdev

unread,
Mar 29, 2015, 3:35:42 AM3/29/15
to ansible...@googlegroups.com
On 29 March 2015 at 04:29, Vince Skahan <vince...@gmail.com> wrote:

The new syntax is unclear to me, and I'm not understanding why you deprecated the old clear/concise syntax.

Actually, I think the new -b option makes sense in general. It avoids the need to add new command-line parameters for additional privilege escalation methods. However, I was just concerned that I needed to type --ask-become-pass each time, instead of a short option. So either allowing -K to keep working, or introducing a new short option for password prompting would be good.

I notice that lowercase 'p' is still unused. How about making '-p' short for --ask-become-password? Then, ansible would figure out the become method, and prompt accordingly. So I could type:

ansible -bp

and ansible would prompt:
sudo password:

If I also add --become-method=su (or set it in ansible.cfg), then ansible would prompt for the "su" password.

Anand

Brian Coca

unread,
Mar 29, 2015, 10:00:14 AM3/29/15
to ansible...@googlegroups.com
Sadly -p is taken for roles path, which does not currently affect
ansible-playbook, but will be added in v2. My current candidate is -w.


--
Brian Coca

Anand Buddhdev

unread,
Mar 29, 2015, 10:43:06 AM3/29/15
to ansible...@googlegroups.com
On 29 March 2015 at 16:00, Brian Coca <bc...@ansible.com> wrote:

Sadly -p is taken for roles path, which does not currently affect
ansible-playbook, but will be added in v2. My current candidate is -w.

Oh shame. I guess Dutch people will find it easier to remember though (password is wachtwoord in Dutch) :)

Anand

Brian Coca

unread,
Mar 29, 2015, 10:44:44 AM3/29/15
to ansible...@googlegroups.com
I wonder if that is why that is the switch for password on ldap tools ....


--
Brian Coca

Jan-Piet Mens

unread,
Mar 29, 2015, 11:55:42 AM3/29/15
to ansible...@googlegroups.com
> I wonder if that is why that is the switch for password on ldap tools ....

passWord because it came after `p'ort IIRC ;-)

-JP
Reply all
Reply to author
Forward
0 new messages