|
|
@ -238,34 +238,38 @@ class PlaybookExecutor:
|
|
|
|
|
|
|
|
|
|
|
|
def _do_var_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None):
|
|
|
|
def _do_var_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None):
|
|
|
|
|
|
|
|
|
|
|
|
if prompt and default is not None:
|
|
|
|
if sys.__stdin__.isatty():
|
|
|
|
msg = "%s [%s]: " % (prompt, default)
|
|
|
|
if prompt and default is not None:
|
|
|
|
elif prompt:
|
|
|
|
msg = "%s [%s]: " % (prompt, default)
|
|
|
|
msg = "%s: " % prompt
|
|
|
|
elif prompt:
|
|
|
|
else:
|
|
|
|
msg = "%s: " % prompt
|
|
|
|
msg = 'input for %s: ' % varname
|
|
|
|
else:
|
|
|
|
|
|
|
|
msg = 'input for %s: ' % varname
|
|
|
|
def do_prompt(prompt, private):
|
|
|
|
|
|
|
|
if sys.stdout.encoding:
|
|
|
|
def do_prompt(prompt, private):
|
|
|
|
msg = prompt.encode(sys.stdout.encoding)
|
|
|
|
if sys.stdout.encoding:
|
|
|
|
|
|
|
|
msg = prompt.encode(sys.stdout.encoding)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# when piping the output, or at other times when stdout
|
|
|
|
|
|
|
|
# may not be the standard file descriptor, the stdout
|
|
|
|
|
|
|
|
# encoding may not be set, so default to something sane
|
|
|
|
|
|
|
|
msg = prompt.encode(locale.getpreferredencoding())
|
|
|
|
|
|
|
|
if private:
|
|
|
|
|
|
|
|
return getpass.getpass(msg)
|
|
|
|
|
|
|
|
return raw_input(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if confirm:
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
result = do_prompt(msg, private)
|
|
|
|
|
|
|
|
second = do_prompt("confirm " + msg, private)
|
|
|
|
|
|
|
|
if result == second:
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
self._display.display("***** VALUES ENTERED DO NOT MATCH ****")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# when piping the output, or at other times when stdout
|
|
|
|
|
|
|
|
# may not be the standard file descriptor, the stdout
|
|
|
|
|
|
|
|
# encoding may not be set, so default to something sane
|
|
|
|
|
|
|
|
msg = prompt.encode(locale.getpreferredencoding())
|
|
|
|
|
|
|
|
if private:
|
|
|
|
|
|
|
|
return getpass.getpass(msg)
|
|
|
|
|
|
|
|
return raw_input(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if confirm:
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
result = do_prompt(msg, private)
|
|
|
|
result = do_prompt(msg, private)
|
|
|
|
second = do_prompt("confirm " + msg, private)
|
|
|
|
|
|
|
|
if result == second:
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
self._display.display("***** VALUES ENTERED DO NOT MATCH ****")
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
result = do_prompt(msg, private)
|
|
|
|
result = None
|
|
|
|
|
|
|
|
self._display.warning("Not prompting as we are not in interactive mode")
|
|
|
|
|
|
|
|
|
|
|
|
# if result is false and default is not None
|
|
|
|
# if result is false and default is not None
|
|
|
|
if not result and default is not None:
|
|
|
|
if not result and default is not None:
|
|
|
|