andreasscherbaum / ansible-lxc-ssh

Ansible connection plugin using ssh + lxc-attach
45 stars 22 forks source link

Issue connecting to container #9

Closed nodje closed 5 years ago

nodje commented 6 years ago

I'm using the following config in my inventory/all domain.net ansible_connection=lxc_ssh ansible_ssh_extra_args=joomla and get the following error:

ansible domain.net -m ping -vvv
ansible 2.4.3.0
  config file = /Users/user/Documents/project/ansible/project/ansible.cfg
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.4 (default, Mar  4 2018, 23:39:33) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
Using /Users/user/Documents/project/ansible/project/ansible.cfg as config file
Parsed /Users/user/Documents/project/ansible/project/inventory/all inventory source with ini plugin
META: ran handlers
XXX connect
</user> ESTABLISH SSH CONNECTION FOR USER: None
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 130, in run
    res = self._execute()
  File "/usr/local/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 485, in _execute
    self._connection = self._get_connection(variables=variables, templar=templar)
  File "/usr/local/lib/python3.6/site-packages/ansible/executor/task_executor.py", line 735, in _get_connection
    connection = self._shared_loader_obj.connection_loader.get(conn_type, self._play_context, self._new_stdin)
  File "/usr/local/lib/python3.6/site-packages/ansible/plugins/loader.py", line 382, in get
    obj = obj(*args, **kwargs)
  File "/Users/user/Documents/project/ansible/project/connection_plugins/ansible-lxc-ssh/lxc_ssh.py", line 155, in __init__
    (returncode2, stdout2, stderr2) = self._exec_command("which lxc", None, False)
  File "/Users/user/Documents/project/ansible/project/connection_plugins/ansible-lxc-ssh/lxc_ssh.py", line 1092, in _exec_command
    cmd = self._build_command(ssh_executable, '-tt', self.host, cmd)
  File "/Users/user/Documents/project/ansible/project/connection_plugins/ansible-lxc-ssh/lxc_ssh.py", line 345, in _build_command
    self._split_args(self._play_context.ssh_args)]
  File "/Users/user/Documents/project/ansible/project/connection_plugins/ansible-lxc-ssh/lxc_ssh.py", line 229, in _split_args
    return [to_unicode(x.strip()) for x in shlex.split(to_bytes(argstring)) if x.strip()]
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 305, in split
    return list(lex)
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 295, in __next__
    token = self.get_token()
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 105, in get_token
    raw = self.read_token()
  File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/shlex.py", line 136, in read_token
    nextchar = self.instream.read(1)
AttributeError: 'bytes' object has no attribute 'read'

domain.net | FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

NB: I can successfully ansible domain.net -m ping -vvv when I set inventory/all to domain.net Adding the ssh parameters fails as well.

dmp1ce commented 5 years ago

I think this is related to #5 . I get the same errors until I apply some changes from the https://github.com/TuxCoder/ansible-lxc-ssh/tree/python3-fix branch