Hello,
I saw that ssh alt replaced ssh on devel :-)) great news + that at this stage it must be activated with pipelining = True because of a doubt on tty.
Have you seen problems related to that ?
For information, from what I tried, I think it could be possible to make ssh_alt work with tty at one condition :
that all modules must be python-interactive compatible (i.e. no pretty newlines breaking identation scope for instance).
it seems that when there is a TTY, python always goes to interactive mode when you pipe into it.
Jerome
Yes, many of our default test systems were using requiretty and were seeing issues with sudoing.
I’d be very very interested in the above if you can make it happen, though I’d like to understand more.
What’s a pretty newline? (Do you perhaps mean that we’d munge the newlines out? If so, I’d be fine with that I think – care would be taken to not affect the module argument interpolation?)
I just tried to rewire the code to have some result with tty enabled. I managed to find this wiring again
here is below the kind of mumbo jumbo that it spits out.
The problem is I think that
def main:
<=== This should be removed
if test:
Hello
===> This should be added
print test
another potential issue is that python interactive mode is probably not thread safe (hangs on blocking commands). Do you know if modules are supposed to use threads ?
another option could be to change the ssh command :
but I don’t know if this can work with tty enabled either.
mumbo jumbo from pilelining with tty enabled :
IndentationError: unexpected indent
if context[i] is None:
File “”, line 1
if context[i] is None:
^
IndentationError: unexpected indent
new_context[i] = cur_context[i]
File “”, line 1
new_context[i] = cur_context[i]
^
IndentationError: unexpected indent
if cur_context != new_context:
File “”, line 1
if cur_context != new_context:
^
IndentationError: unexpected indent
Here is a proof-of-concept of pipelining+tty so that you can see what it could look like with this python-interactive thing.
I must say it was painful (and is still a prototype). This code works with “command: echo ping”. did not test with something else.
https://github.com/jeromew/ansible/commit/b88f385b24ed3a9e04b0ce69de2441ad0d4aa67f
the main idea for pipelining+tty to work is that the module code must work if you copy/paste it in a python interactive shell ; that’s more easy said than done.
2 potential benefits :
- most of the ssh_alt.py can be reverted to ssh.py by removing all the “no-tty” specific handling.
- you get some kind of streamer and could imagine sending modules on that stream without even reconnecting ;
on the downside, the need to tokenize/untokenize the code looks horrible on a maintenance level except if a python expert can put a seal on this (or on an equivalent rewrite).
The stdin.write code should be improved as well. it works now in the prototype so I leave it as is.
Tell me what you think.