Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run anymore on Windows #995

Closed
HOSTED-POWER opened this issue May 10, 2023 · 8 comments
Closed

Cannot run anymore on Windows #995

HOSTED-POWER opened this issue May 10, 2023 · 8 comments
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome

Comments

@HOSTED-POWER
Copy link

When we use mitogen with Linux and Windows targets, but on Windows they refuse to run.

Also when we tried to add Python.exe, it simply doesn't work (Windows over SSH with powershell).

{
  "unreachable": true,
  "msg": "EOF on stream; last 100 lines received:\n  File \"<string>\", line 1\r\n    import codecs,os,sys;_=codecs.decode;exec(_(_(eNqVkm9PwjAQxt/zKXx3XRxjHSphcYkEUEzkTxaUGFzIxooWoV26jQmf3hszMPCF8V1/vefunvbO1SeOjI2IR4xoFaVnJeKLC4SFVJ9Esyv5OUwji5g6NU3tyK5eJoVRWvB8JWNG3DKoMkzKkCEUDVPhr7H91PQcBzq+yrgAX4TlkOVNbcu7BdrcR+JtbLAvNk8TP1gxzKqlsaoFXNSibfIhBdhninOBZTTg3+3x3jItenCwYSrmUkztep6Zl7Qxh4kNV3gLo9dxbziYPbWeB+1etzO7d4f92cRtjUZdFzwHKOx/46BvuQ8vJgZOrRcaxBU5DeineAlkzRP5zoSN0zLv/DSRaz9Bf9WlDKrNG3pFq424uVva9WsNtAqWzRRPGKE69B/HQ0x6E4B25jLEN2uVtjMj+TqEMmIClwBUAJqhmB8S2shnrsOOR1hpETlH3USHLIB8QxbRT4P2/lxM/Uyd/aX+7ZKeujzsk6V9A1br5XM=.encode(),base64),zip))\r\n                                                                                                                                                                                                                                                                                        ^\r\nSyntaxError: invalid decimal literal\r",
  "changed": false
}

Is there any easy way to (silently) skip Windows and use for example normal lineair there? Many of our playbooks are written to support both Linux and Windows at the same time, but it seems impossible to support this now.

@HOSTED-POWER HOSTED-POWER added affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome labels May 10, 2023
@HOSTED-POWER
Copy link
Author

I also did a base64 decode and unzip and I see this code which looks quite strange to run on Windows since fork doesn't exist there:

R,W=os.pipe()
r,w=os.pipe()
if os.fork():
 os.dup2(0,100)
 os.dup2(R,0)
 os.dup2(r,101)
 os.close(R)
 os.close(r)
 os.close(W)
 os.close(w)
 if os.uname()[0]=='Darwin'and os.uname()[2][:2]<'19'and sys.executable=='/usr/bin/python':sys.executable='/usr/bin/python2.7'
 if os.uname()[0]=='Darwin'and os.uname()[2][:2]in'2021'and sys.version[:3]=='2.7':os.environ['PYTHON_LAUNCHED_FROM_WRAPPER']='1'
 os.environ['ARGV0']=sys.executable
 os.execl(sys.executable,sys.executable+'(mitogen:1000@automation-job-96141-7s9zj:35)')
os.write(1,'MITO000\n'.encode())
C=_(os.fdopen(0,'rb').read(17101),'zip')
fp=os.fdopen(W,'wb',0)
fp.write(C)
fp.close()
fp=os.fdopen(w,'wb',0)
fp.write(C)
fp.close()
os.write(1,'MITO001\n'.encode())
os.close(2)

For us an option to use normal lineair and forget about mitogen would be nice as well, since installing Python on all Windows server isn't necessarily the plan we would prefer to follow.

@gaige
Copy link

gaige commented May 13, 2023

Ansible strategies are designed to determine how to run plays in the playbook, as such it doesn't support assigning a strategy per host (since the whole distinction between linear and free (for example) is how the host actions are interleaved.

With that said, you could reduce your playbook to a role and run the role separately against windows and linux with the strategy set appropriately for each. (Or similarly you could reduce the playbook to a list of tasks and include it twice, separately for 2 plays one that runs with windows and another with linux).

@HOSTED-POWER
Copy link
Author

HOSTED-POWER commented May 13, 2023

Thanks a lot for explaining! I managed to split the bootstrap and become rules from the main tasks so it can run without mitogen.

However our playbooks are often mixed throughout all tasks because often they accomplish the same type of tasks on both OS.

I think we have no other option then to use mitogen on Windows as well. There could be 2 options then still:

  • Mitogen simulates the behaviour of the normal ansible plugin with persistent multiplexed SSH. Maybe it even could simply call the ansible python plugin because I assume the parameters are more or less the same to call a strategy plugin?
  • Or Mitogen does simply work like on Linux with Python on host as requirement, I read it should be supported on Windows somewhere, so what am I missing here?

@gaige
Copy link

gaige commented May 13, 2023

I'm not a mitogen maintainer (just another user), and I don't have any windows systems in our environment, so I can't give you any authoritative answers on these questions.

I've had some difficulties on my prefered platform as well (SmartOS, a derivative of Solaris). Although it's a unix system, become in particular is problematic on it. As such, I have some playbooks that we just don't run with mitogen. It works great in most other uses, though, so it's been worth the trouble for me to refactor where possible.

@hackatoo
Copy link

@HOSTED-POWER
Confirming the issue. Have the same problem while connecting to Windows Server 2019 with Python 3.10 on a client side and Mitogen 0.3.3 on linux server instance. The PATH for Python is created same as symlink for /usr/bin/python which mitogen try to find on remote host. Im assuming as Windows not supporting UNIX sockets, Mitogen not supports the Windows.
But if some developer confirm this it would be great.

@HOSTED-POWER
Copy link
Author

I managed to fix even path issue, but I discovered it's executing a "python script" which isn't compatible with Windows...

@moreati
Copy link
Member

moreati commented Mar 4, 2024

Mitogen has now support for Windows targets, and no plans to add it.

@moreati moreati closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
@lewisdoesstuff
Copy link

Hi @moreati!

I'm working on using mitogen in our existing Ansible plays, and was expecting to have to work on some logic in our orchestration tool to set the strategy to mitogen_free only if the request contains no Windows hosts.

However, I tried this out earlier and was surprised to see that it worked fine? On both a mix and an entirely Windows based set of targets, everything seems to work as expected.

Any idea why this might be?
We're setting ansible_connection explicitly in the host vars to either ssh or winrm.

Am I right in thinking that, as mitogen doesn't support winrm, Ansible handles this as normal, as if running with free?
If so, fantastic! If not, and I'm about to shoot myself in the foot with this, please let me know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-0.3 Issues related to 0.3.X Mitogen releases bug Code feature that hinders desired execution outcome
Projects
None yet
Development

No branches or pull requests

4 participants