Match config prompts that aren't maint-mode (#47678)

This commit is contained in:
Nathaniel Case 2018-11-12 11:18:06 -05:00 committed by GitHub
parent 320d72f08f
commit 1fff542623
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,8 +19,9 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import sys
import copy
import re
import sys
from ansible import constants as C
from ansible.module_utils._text import to_text
@ -117,8 +118,10 @@ class ActionModule(_ActionModule):
socket_path = self._connection.socket_path
conn = Connection(socket_path)
# Match prompts ending in )# except those with (maint-mode)#
config_prompt = re.compile(r'^.*\((?!maint-mode).*\)#$')
out = conn.get_prompt()
while to_text(out, errors='surrogate_then_replace').strip().endswith(')#'):
while config_prompt.match(to_text(out, errors='surrogate_then_replace').strip()):
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
conn.send_command('exit')
out = conn.get_prompt()