Skip to content

Commit

Permalink
Fix VyOS cli prompt issues (ansible#56389)
Browse files Browse the repository at this point in the history
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
  • Loading branch information
NilashishC committed May 14, 2019
1 parent 88be323 commit 30ccc8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/ansible/plugins/action/vyos.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ def run(self, tmp=None, task_vars=None):

conn = Connection(socket_path)
out = conn.get_prompt()
while to_text(out, errors='surrogate_then_replace').strip().endswith('#'):
if to_text(out, errors='surrogate_then_replace').strip().endswith('#'):
display.vvvv('wrong context, sending exit to device', self._play_context.remote_addr)
conn.send_command('exit discard')
out = conn.get_prompt()

result = super(ActionModule, self).run(task_vars=task_vars)
return result
2 changes: 2 additions & 0 deletions lib/ansible/plugins/cliconf/vyos.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def edit_config(self, candidate=None, commit=True, replace=None, comment=None):
self.discard_changes()
else:
self.send_command('exit')
if to_text(self._connection.get_prompt(), errors='surrogate_or_strict').strip().endswith('#'):
self.discard_changes()

if diff_config:
resp['diff'] = diff_config
Expand Down

0 comments on commit 30ccc8e

Please sign in to comment.