From 94d40c8515ccedb1ababc7d43c47dd19d86631db Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Fri, 20 Apr 2018 23:49:19 +0530 Subject: [PATCH] Fix ios and iosxr terminal prompt regex (#39063) (#39089) Fixes #38732 Make matching leading newline for cli prompt optional as there are cases when returned repsonse for ios/iosx remote host doesn't have newline before cli prompt. (cherry picked from commit eebfa66c2bc1ac57b2599e6f432026a05abaad43) --- changelogs/fragments/ios_terminal_regex_fix.yaml | 2 ++ lib/ansible/plugins/terminal/ios.py | 2 +- lib/ansible/plugins/terminal/iosxr.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ios_terminal_regex_fix.yaml diff --git a/changelogs/fragments/ios_terminal_regex_fix.yaml b/changelogs/fragments/ios_terminal_regex_fix.yaml new file mode 100644 index 00000000000..612f28c6089 --- /dev/null +++ b/changelogs/fragments/ios_terminal_regex_fix.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Fix ios and iosxr terminal prompt regex (https://github.com/ansible/ansible/pull/39063) \ No newline at end of file diff --git a/lib/ansible/plugins/terminal/ios.py b/lib/ansible/plugins/terminal/ios.py index af9e3bf29ad..61927bda906 100644 --- a/lib/ansible/plugins/terminal/ios.py +++ b/lib/ansible/plugins/terminal/ios.py @@ -30,7 +30,7 @@ from ansible.plugins.terminal import TerminalBase class TerminalModule(TerminalBase): terminal_stdout_re = [ - re.compile(br"[\r\n][\w\+\-\.:\/\[\]]+(?:\([^\)]+\)){0,3}(?:[>#]) ?$") + re.compile(br"[\r\n]?[\w\+\-\.:\/\[\]]+(?:\([^\)]+\)){0,3}(?:[>#]) ?$") ] terminal_stderr_re = [ diff --git a/lib/ansible/plugins/terminal/iosxr.py b/lib/ansible/plugins/terminal/iosxr.py index 100b3d5863a..6a9657d0ab5 100644 --- a/lib/ansible/plugins/terminal/iosxr.py +++ b/lib/ansible/plugins/terminal/iosxr.py @@ -29,7 +29,7 @@ from ansible.errors import AnsibleConnectionFailure class TerminalModule(TerminalBase): terminal_stdout_re = [ - re.compile(br"[\r\n][\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"), + re.compile(br"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"), re.compile(br']]>]]>[\r\n]?') ]