nickjj / ansible-docker

Install / Configure Docker and Docker Compose using Ansible.
MIT License
750 stars 224 forks source link

Upgrade edge case #117

Open compscidr opened 2 years ago

compscidr commented 2 years ago

Kind of an edge case, so feel free to close.

I've been using this with ubuntu 22.04 on some other machines on fresh installs and it seems to work pretty well (even though I know its not listed as supported).

I have another machine which I did an upgrade from 20.04, and when it ran the Install Python packages it fails (it seems because it still had the old virtualenv there.

This was the sort error I saw:

failed: [ubuntu-desktop-beast] (item={'name': 'docker', 'state': 'present'}) => {"ansible_loop_var": "item", "changed": false, "cmd": ["/usr/local/lib/docker/virtualenv/bin/pip3", "install", "docker"], "item": {"name": "docker", "state": "present"}, "msg": "\n:stderr: Traceback (most recent call last):\n  File \"/usr/local/lib/docker/virtualenv/bin/pip3\", line 5, in <module>\n    from pip._internal.cli.main import main\nModuleNotFoundError: No module named 'pip'\n"}
failed: [ubuntu-desktop-beast] (item={'name': 'docker-compose', 'version': '', 'path': '/usr/local/bin/docker-compose', 'src': '/usr/local/lib/docker/virtualenv/bin/docker-compose', 'state': 'present'}) => {"ansible_loop_var": "item", "changed": false, "cmd": ["/usr/local/lib/docker/virtualenv/bin/pip3", "install", "docker-compose"], "item": {"name": "docker-compose", "path": "/usr/local/bin/docker-compose", "src": "/usr/local/lib/docker/virtualenv/bin/docker-compose", "state": "present", "version": ""}, "msg": "\n:stderr: Traceback (most recent call last):\n  File \"/usr/local/lib/docker/virtualenv/bin/pip3\", line 5, in <module>\n    from pip._internal.cli.main import main\nModuleNotFoundError: No module named 'pip'\n"}

Fixed it by just clobbering the virtualenv with sudo rm -rf /usr/local/lib/docker/virtualenv and now everything is happy.

Just thought I'd let you know in case you have any ideas on detecting and deadling with this edge case. Also appreciate this project!

nickjj commented 2 years ago

Hi,

Thanks. You mentioned it worked pretty well on 22.04, did it work out of the box with no adjustments on the fresh install?

I'm kind of surprised upgrading would cause that issue or if it's worth trying to find a workaround especially with Docker now installing Docker Compose through its official apt plugin which no longer requires a Python runtime or a virtualenv to be created. Your workaround seems good for the 1 off case. Did this happen every time you upgraded, just once out of X times or only once in the one time you tried it?

compscidr commented 2 years ago

I think from a fresh install it works fine, I'll double check and report back.

Also, have a couple other machines that also need to be upgraded, will do those this evening and again let you know.

compscidr commented 2 years ago

Confirmed on another machine I upgraded that the same issue is occurring, also confirmed that a fresh install works fine.

nickjj commented 2 years ago

Thanks. I wonder why it's picky about not being able to keep that file between upgrades. I am seeing in 22.04 it does work out of the box. Upgrading from 20.04 is kind of edge case'ish but if we can do something easily to address it I'm ok with supporting it. Any suggestions?

compscidr commented 2 years ago

Sorry, got busy for a few weeks there.

Perhaps we could have a handler for the failure case which clobbers that folder or something? I'm not sure if there's a case though where we wouldn't want it to do that. I can give it a try and make a PR when I get a chance.

daniel-sc commented 1 year ago

For me, the problem that it used some virtualenv python to install pip docker (instead of the regular ansible python) happened with a fresh Ubuntu 22.04 using Ansible 6.3.0

nickjj commented 1 year ago

https://github.com/nickjj/ansible-docker#configuring-virtualenv explains why a virtualenv is used for anything that gets pip installed, that's the intended behavior.

votti commented 7 months ago

I also experienced the same issue after upgrading to Ubuntu 22.04`- the removing of the virtualenv fixed the issue.

compscidr commented 6 months ago

Seems like this issue is also present after upgrade from 22.04 -> 24.04, removing the venv still fixes the issue though.