I recently submitted a pull request to add support for managing LXC
containers with ansible by directly ssh'ing on the host.
The pull request contains some change to the ssh connection plugin, and
while it shouldn't break anything, I'd feel more comfortable if other
people familiar ansible reviewed it.
The ssh.Connection._communicate method was rewritten to allow more
flexible handling of ssh's stdin/stdout/stderr.
Until now, everything was completely buffered in memory (stdin was read
from a str, stdout/stderr were written to a str). My pull request
introduce a system of callback to deal with the data coming in/out of
the process.
The default behavior of buffering everything in memory remains
unchanged, but the callback system allows more flexibility. For example,
it's possible to write a callback to pipe big files directly through
ssh.
This new possibility is used in the LXC connextion plugin, which pipes
files in and out of ssh instead of using sftp/scp for transfering files.
I’m not sure I’m comfortable with such a large change to ssh.py to support raw LXC, in interest that more people are adopting Docker variants and we would not want to maintain both.
Generally, we have tried to avoid connection plugins that go through multiple layers, especially as a lot of these setups are moving towards immutable management.
That all being said, I’m curious to hear a bit more about this - how do you express which remote container to manage?
The plugin can also work in combinaison with sudo and su, In this case
sudo / su are executed on the host, before lxc-attach.
Even if the lxc connection plugin itself can't be merged, could you
consider merging just the ssh.py bits ? It would make it more flexible
and allow for people to reuse it to write their own connection plugins.
I can think about it, I am not sure what our strategy for connection hopping is going to be just yet. I think it may need to wait for the v2/ refactoring to get further along to consider this, though I probably won’t delay v2/ for this purpose, we may want to get that done first and then consider that on top of that tree.