action/ce.py:clear configuration candidate when return to user-view. (#63513)

* clear configuration candidate when return to user-view.

* add a changelog fragment for the pr.

* Update 63513-ce_action_wait_prompt_trigger_time_out.yaml

* Update 63513-ce_action_wait_prompt_trigger_time_out.yaml
This commit is contained in:
Xu Yuandong 2019-10-18 17:09:47 +08:00 committed by John R Barker
parent d22dc5ab8b
commit 47c31c201b
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- action/ce - fix a bug, some new version os will not discard uncommitted configure with a return directly.(https://github.com/ansible/ansible/pull/63513).

View file

@ -93,10 +93,14 @@ class ActionModule(ActionNetworkModule):
socket_path = self._connection.socket_path
conn = Connection(socket_path)
out = conn.get_prompt()
while to_text(out, errors='surrogate_then_replace').strip().endswith(']'):
prompt = to_text(out, errors='surrogate_then_replace').strip()
while prompt.endswith(']'):
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
if prompt.startswith('[*'):
conn.exec_command('clear configuration candidate')
conn.exec_command('return')
out = conn.get_prompt()
prompt = to_text(out, errors='surrogate_then_replace').strip()
result = super(ActionModule, self).run(task_vars=task_vars)
return result