diff --git a/lib/ansible/plugins/cliconf/__init__.py b/lib/ansible/plugins/cliconf/__init__.py index 414eddc611..e140bdab15 100644 --- a/lib/ansible/plugins/cliconf/__init__.py +++ b/lib/ansible/plugins/cliconf/__init__.py @@ -25,6 +25,7 @@ from abc import ABCMeta, abstractmethod from functools import wraps from ansible.errors import AnsibleError, AnsibleConnectionFailure +from ansible.module_utils._text import to_bytes from ansible.module_utils.six import with_metaclass try: @@ -99,10 +100,16 @@ class CliconfBase(with_metaclass(ABCMeta, object)): the results to the caller. The command output will be returned as a string """ + kwargs = {'command': to_bytes(command), 'sendonly': sendonly} + if prompt is not None: + kwargs['prompt'] = to_bytes(prompt) + if answer is not None: + kwargs['answer'] = to_bytes(answer) + if not signal.getsignal(signal.SIGALRM): signal.signal(signal.SIGALRM, self._alarm_handler) signal.alarm(self._connection._play_context.timeout) - resp = self._connection.send(command, prompt, answer, sendonly) + resp = self._connection.send(**kwargs) signal.alarm(0) return resp diff --git a/lib/ansible/plugins/cliconf/vyos.py b/lib/ansible/plugins/cliconf/vyos.py index 8425721dc5..57b60b3761 100644 --- a/lib/ansible/plugins/cliconf/vyos.py +++ b/lib/ansible/plugins/cliconf/vyos.py @@ -59,7 +59,7 @@ class Cliconf(CliconfBase): self.send_command(to_bytes(cmd)) def get(self, command, prompt=None, answer=None, sendonly=False): - return self.send_command(to_bytes(command), prompt=to_bytes(prompt), answer=to_bytes(answer), sendonly=sendonly) + return self.send_command(command, prompt=prompt, answer=answer, sendonly=sendonly) def commit(self, comment=None): if comment: