diff options
author | Xu Yuandong <yuandongdeyouxiang@gmail.com> | 2019-10-18 17:09:47 +0800 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-10-31 12:50:55 -0700 |
commit | bd26e706380e8777e457447a262b2392753c6119 (patch) | |
tree | d224251ae2c81b90338908c4eaeed7b12345fbe0 | |
parent | 1d81a139afc018c6dca72407d635e2b30220dda6 (diff) | |
download | ansible-bd26e706380e8777e457447a262b2392753c6119.tar.gz |
action/ce.py:clear configuration candidate when return to user-view. (#63513)temporary-2.9.1-branch-releng-only
* 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
(cherry picked from commit 47c31c201b694d043e156747a4a99275bd66492e)
-rw-r--r-- | changelogs/fragments/63513-ce_action_wait_prompt_trigger_time_out.yaml | 2 | ||||
-rw-r--r-- | lib/ansible/plugins/action/ce.py | 6 |
2 files changed, 7 insertions, 1 deletions
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 0000000000..bd4ac9c6d0 --- /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 18a3570d97..303ea53bbf 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 |