diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py index 93e6f74939..94db7a9d25 100644 --- a/lib/ansible/plugins/connection/network_cli.py +++ b/lib/ansible/plugins/connection/network_cli.py @@ -539,9 +539,14 @@ class Connection(NetworkConnectionBase): ''' cleaned = [] for line in resp.splitlines(): - if (command and line.strip() == command.strip()) or self._matched_prompt.strip() in line: + if command and line.strip() == command.strip(): continue - cleaned.append(line) + + for prompt in self._matched_prompt.strip().splitlines(): + if prompt.strip() in line: + break + else: + cleaned.append(line) return b'\n'.join(cleaned).strip() def _find_prompt(self, response): diff --git a/lib/ansible/plugins/terminal/junos.py b/lib/ansible/plugins/terminal/junos.py index 735e8bdf37..8562581156 100644 --- a/lib/ansible/plugins/terminal/junos.py +++ b/lib/ansible/plugins/terminal/junos.py @@ -32,7 +32,7 @@ display = Display() class TerminalModule(TerminalBase): terminal_stdout_re = [ - re.compile(br"[\r\n]?[\w@+\-\.:\/\[\]]+[>#%] ?$"), + re.compile(br"({primary:node\d+})?[\r\n]?[\w@+\-\.:\/\[\]]+[>#%] ?$"), ] terminal_stderr_re = [