From 9c36c0aa80c041ca58595bc4efd37d813c876ca7 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Thu, 11 Feb 2016 07:11:36 -0500 Subject: [PATCH] minor bug fixes and updates to shell --- lib/ansible/module_utils/shell.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/shell.py b/lib/ansible/module_utils/shell.py index 13506c4322..9a63c9821d 100644 --- a/lib/ansible/module_utils/shell.py +++ b/lib/ansible/module_utils/shell.py @@ -44,6 +44,8 @@ CLI_ERRORS_RE = [ re.compile(r"connection timed out", re.I), re.compile(r"[^\r\n]+ not found", re.I), re.compile(r"'[^']' +returned error code: ?\d+"), + re.compile(r"syntax error"), + re.compile(r"unknown command") ] def to_list(val): @@ -77,6 +79,8 @@ class Shell(object): self.ssh = None self.shell = None + self._matched_prompt = None + self.prompts = list() self.prompts.extend(CLI_PROMPTS_RE) @@ -169,7 +173,9 @@ class Shell(object): raise ShellError('%s' % response) for regex in self.prompts: - if regex.search(response): + match = regex.search(response) + if match: + self._matched_prompt = match.group() return True def get_cli_connection(module):