Add a config toggle for agnostic become prompts, defaulting to False for the 2.5 release. Fixes #33999 (#34761)

This commit is contained in:
Matt Martz 2018-01-12 10:28:46 -06:00 committed by GitHub
parent 7957ba7aad
commit 2b66d9966c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -320,14 +320,16 @@ class CLI(with_metaclass(ABCMeta, object)):
becomepass = None
become_prompt = ''
become_prompt_method = "BECOME" if C.AGNOSTIC_BECOME_PROMPT else op.become_method.upper()
try:
if op.ask_pass:
sshpass = getpass.getpass(prompt="SSH password: ")
become_prompt = "BECOME password[defaults to SSH password]: "
become_prompt = "%s password[defaults to SSH password]: " % become_prompt_method
if sshpass:
sshpass = to_bytes(sshpass, errors='strict', nonstring='simplerepr')
else:
become_prompt = "BECOME password: "
become_prompt = "%s password: " % become_prompt_method
if op.become_ask_pass:
becomepass = getpass.getpass(prompt=become_prompt)