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

Mitogen does not support Ansible 2.8 Python interpreter detection #597

Closed
ghost opened this issue Jun 12, 2019 · 12 comments · Fixed by #658
Closed

Mitogen does not support Ansible 2.8 Python interpreter detection #597

ghost opened this issue Jun 12, 2019 · 12 comments · Fixed by #658

Comments

@ghost
Copy link

ghost commented Jun 12, 2019

Running Debian 9 locally with Ansible 2.8.1 with Python 3. Controlling a Ubuntu 18.04 server.

I followed the instructions here: https://networkgenomics.com/ansible/

Of course it didn't work for 2.8.X, so I switched it out for master. Now I'm getting this:

TASK [Gathering Facts] ************************************************************************************************************************
fatal: [8.9.11.101]: UNREACHABLE! => {"changed": false, "msg": "EOF on stream; last 300 bytes received: 'bash: /usr/bin/python: No such file or directory\\n'", "unreachable": true}

Oddly enough, /usr/bin/python does exist but it's a symlink to python2.7.

I think it should be trying /usr/bin/python3. Ansible works just fine without mitogen enabled.

I think there's something about a ansible_python_interpreter that I can set, but seems like this should work by default.

What can I try/test? I'm new to both Ansible and Mitogen, so not very familiar with either yet.

Thank you!

@dw
Copy link
Member

dw commented Jun 13, 2019

Hi there,

This is probably something to do with the new "Python interpreter discovery" feature in Ansible 2.8. Mitogen currently lacks support for it.

As a workaround, you can specify ansible_python_interpreter=/usr/bin/python3 for just that machine, or for its group, or simply on the command line using ansible -e ansible_python_interpreter=...

Sorry for the hassle! Interpreter discovery is simultaneously a simple feature and fairly painful, because to solve it requires implementing raw: module support, which Mitogen has always lacked. Coming soon!

@ghost
Copy link
Author

ghost commented Jun 13, 2019

Thank you, that works!

Actually ended up setting that yesterday because Ansible was doing Python 2 on one host and Python 3 on another.

Do you want me to close this out or leave it open for now?

@dw
Copy link
Member

dw commented Jun 14, 2019

All behavioural differences are bugs, so it stays open :) Thanks for reporting!

@dw dw changed the title Ansible 2.8.X with Mitogen master, Python 3: /usr/bin/python not found Mitogen does not support Ansible 2.8 Python interpreter detection Jun 14, 2019
@ghost
Copy link
Author

ghost commented Jun 14, 2019

No problem, sounds good!

@rei-android
Copy link

Any news on this?

@s1113950
Copy link
Collaborator

s1113950 commented Oct 25, 2019

@dw I got a different error with Ansible 2.8.5 and Mitogen 0.2.8:

fatal: [machine]: UNREACHABLE! => {"changed": false, "msg": "EOF on stream; last 100 lines received:\nusername@{machineIP}'s password: ", "unreachable": true}

task:

- name: pull down docker binaries
  get_url:
    url: https://download.docker.com/linux/static/stable/x86_64/docker-{{ docker_version }}.tgz
    dest: /usr/local/share
    mode: 0644
  vars:
    ansible_python_interpreter: source /opt/rh/rh-python36/enable && python

In this case a machine's default system python was super old so we needed to use a user-installed python instead to avoid SNI issues. This works just fine without mitogen.

@s1113950
Copy link
Collaborator

I believe I discovered my issue. It's due to how the ssh command is set up when ansible_python_interpreter is more than just a python path:

[mux  96418] 17:02:52.927805 D mitogen.parent: command line for Connection(None): ssh -o "LogLevel ERROR" -l {login_name} -o "Compression yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 10" -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -o "GlobalKnownHostsFile /dev/null" -o ForwardAgent=yes {IP_ADDR} source /opt/rh/rh-python36/enable '&&' python -c "'import codecs,os,sys;_=codecs.decode;exec(_(_(\"eNqFkUFPwzAMhc/...

This is different than what ansible does in this situation:

8
SSH: EXEC sshpass -d41 ssh -vvv -o ForwardAgent=yes -o StrictHostKeyChecking=no -o 'User="{username}"' -o ConnectTimeout={IP_ADDR} '/bin/sh -c '"'"'sudo -H -S  -p "[sudo via ansible, key=SOMEKEY] password:" -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-{SOMEKEY} ; source /opt/rh/rh-python36/enable && python'"'"'"'"'"'"'"'"' && sleep 0'"'"''

I'll try and submit a PR to fix

@s1113950
Copy link
Collaborator

Will be working on the fix here: #658. Might be going down the rabbit hole a bit but I'm determined 😅

@s1113950
Copy link
Collaborator

My fix is ready

@ssbarnea
Copy link

Really sad to see that there is no progress on this bug, which is a deal breaker.

@snoord
Copy link

snoord commented Jan 27, 2020

Facing the same issue. I have managed to work around this issue by setting the following for my CentOS 7 and CentOS 8 group:

ansible_python_interpreter: /usr/libexec/platform-python

This has allowed me to continue working with both sets of VMs at a time, as when I had previously set the python interpreter to /usr/bin/python3, I lost the ability to use the yum module with the CentOS 7 hosts.

@s1113950
Copy link
Collaborator

I've made a PR here: #658 can those affected please try my patch and see if it fixes things for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants