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

pull/48573/head
Nathaniel Case 6 years ago committed by GitHub
parent 320d72f08f
commit 1fff542623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,8 +19,9 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import sys
import copy import copy
import re
import sys
from ansible import constants as C from ansible import constants as C
from ansible.module_utils._text import to_text from ansible.module_utils._text import to_text
@ -117,8 +118,10 @@ class ActionModule(_ActionModule):
socket_path = self._connection.socket_path socket_path = self._connection.socket_path
conn = 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() 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) display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
conn.send_command('exit') conn.send_command('exit')
out = conn.get_prompt() out = conn.get_prompt()

Loading…
Cancel
Save