diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py index 3f198d11205..da506d9c5b9 100644 --- a/lib/ansible/plugins/connection/network_cli.py +++ b/lib/ansible/plugins/connection/network_cli.py @@ -312,7 +312,8 @@ class Connection(ConnectionBase): else: display.vvvv('unable to load cliconf for network_os %s' % network_os) - self.receive() + self.receive(prompts=self._terminal.terminal_initial_prompt, answer=self._terminal.terminal_initial_answer, + newline=self._terminal.terminal_inital_prompt_newline) display.vvvv('firing event: on_open_shell()', host=self._play_context.remote_addr) self._terminal.on_open_shell() diff --git a/lib/ansible/plugins/terminal/__init__.py b/lib/ansible/plugins/terminal/__init__.py index f4928082f37..23b497cfb3b 100644 --- a/lib/ansible/plugins/terminal/__init__.py +++ b/lib/ansible/plugins/terminal/__init__.py @@ -52,6 +52,15 @@ class TerminalBase(with_metaclass(ABCMeta, object)): re.compile(br'\x08.') ] + #: terminal initial prompt + terminal_initial_prompt = None + + #: terminal initial answer + terminal_initial_answer = None + + #: Send newline after prompt match + terminal_inital_prompt_newline = True + def __init__(self, connection): self._connection = connection diff --git a/lib/ansible/plugins/terminal/aruba.py b/lib/ansible/plugins/terminal/aruba.py index 663923afc91..2ab91779c9e 100644 --- a/lib/ansible/plugins/terminal/aruba.py +++ b/lib/ansible/plugins/terminal/aruba.py @@ -29,10 +29,18 @@ from ansible.plugins.terminal import TerminalBase class TerminalModule(TerminalBase): + ansi_re = [ + # check ECMA-48 Section 5.4 (Control Sequences) + re.compile(br'(\x1b\[\?1h\x1b=)'), + re.compile(br'((?:\x9b|\x1b\x5b)[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e])'), + re.compile(br'\x08.') + ] + terminal_stdout_re = [ re.compile(br"[\r\n]?[\w]*\(.+\) ?#(?:\s*)$"), re.compile(br"[pP]assword:$"), re.compile(br"(?<=\s)[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\s*#\s*$"), + re.compile(br"[\r\n]?[\w\+\-\.:\/\[\]]+(?:\([^\)]+\)){0,3}(?:[>#]) ?$"), ] terminal_stderr_re = [ @@ -47,6 +55,12 @@ class TerminalModule(TerminalBase): re.compile(br"'[^']' +returned error code: ?\d+"), ] + terminal_initial_prompt = b'Press any key to continue' + + terminal_initial_answer = b'\r' + + terminal_inital_prompt_newline = False + def on_open_shell(self): try: self._exec_cli_command(b'no pag')