Fixes prompt doubling issue that impacted missing ios enable password prompts. (#33794)

* Fixes a prompt doubling issue that impacted missing ios enable password prompts.

Due to get_prompt sending a '\n' the prompts became doubled and out-of-sync with what
was expected.  This caused the enable command prompts to be missed.
Also added verification that on_become succeeded to reach enable prompt.

* Moved prompt doubling comment per shippable
This commit is contained in:
bdowling 2017-12-15 11:31:28 -05:00 committed by Nathaniel Case
commit d59bba4652
2 changed files with 9 additions and 2 deletions

View file

@ -65,8 +65,12 @@ class TerminalModule(TerminalBase):
try:
self._exec_cli_command(to_bytes(json.dumps(cmd), errors='surrogate_or_strict'))
prompt = self._get_prompt()
if not prompt.endswith(b'#'):
raise AnsibleConnectionFailure('failed to elevate privilege to enable mode still at prompt [%s]' % prompt)
except AnsibleConnectionFailure:
raise AnsibleConnectionFailure('unable to elevate privilege to enable mode')
prompt = self._get_prompt()
raise AnsibleConnectionFailure('unable to elevate privilege to enable mode, at prompt [%s]' % prompt)
def on_unbecome(self):
prompt = self._get_prompt()