summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoshi_pp <toshiq2@gmail.com>2018-06-09 16:49:29 +0900
committerToshio Kuratomi <a.badger@gmail.com>2018-06-11 11:55:20 -0700
commit9a4ad89ec5771f22bfd59e746377f207762e470a (patch)
tree99fc06f8981a340abf0dcee60601c04c8892f531
parent204fc7becfb0426b5bc9334971c75bf9ca3c1581 (diff)
downloadansible-9a4ad89ec5771f22bfd59e746377f207762e470a.tar.gz
Fix a process execution using lxc connection plugin on Python3.
python2-lxc module needs bytes, on the other hand python3-lxc requires text. To solve such incompatibility, use to_native other than to_bytes. This fixes #41060.
-rw-r--r--lib/ansible/plugins/connection/lxc.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ansible/plugins/connection/lxc.py b/lib/ansible/plugins/connection/lxc.py
index 5219b28d68..0c623ab534 100644
--- a/lib/ansible/plugins/connection/lxc.py
+++ b/lib/ansible/plugins/connection/lxc.py
@@ -45,7 +45,7 @@ except ImportError:
from ansible import constants as C
from ansible import errors
-from ansible.module_utils._text import to_bytes
+from ansible.module_utils._text import to_bytes, to_native
from ansible.plugins.connection import ConnectionBase
@@ -116,8 +116,9 @@ class Connection(ConnectionBase):
''' run a command on the chroot '''
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
- executable = to_bytes(self._play_context.executable, errors='surrogate_or_strict')
- local_cmd = [executable, '-c', to_bytes(cmd, errors='surrogate_or_strict')]
+ # python2-lxc needs bytes. python3-lxc needs text.
+ executable = to_native(self._play_context.executable, errors='surrogate_or_strict')
+ local_cmd = [executable, '-c', to_native(cmd, errors='surrogate_or_strict')]
read_stdout, write_stdout = None, None
read_stderr, write_stderr = None, None