diff --git a/changelogs/fragments/63513-ce_action_wait_prompt_trigger_time_out.yaml b/changelogs/fragments/63513-ce_action_wait_prompt_trigger_time_out.yaml new file mode 100644 index 00000000000..bd4ac9c6d0d --- /dev/null +++ b/changelogs/fragments/63513-ce_action_wait_prompt_trigger_time_out.yaml @@ -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). diff --git a/lib/ansible/plugins/action/ce.py b/lib/ansible/plugins/action/ce.py index 18a3570d975..303ea53bbfb 100644 --- a/lib/ansible/plugins/action/ce.py +++ b/lib/ansible/plugins/action/ce.py @@ -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