haxorof/ansible-role-docker-ce

CentOS 7 and pip2 issue

janorn opened this issue · 11 comments

This line in the code adds python-devel and openssl-devel to my installation. This stops pre installed pip from working. And the install to fail as I have some pip packages defined.

+ [docker_python2_build_os_pkgs[_docker_os_dist] | default(docker_python2_build_os_pkgs[_docker_os_dist_file_varity])] }}

As I don't want to upgrade pip I use the variable:

docker_x_skip_pip_auto_upgrade: true

Would be nice if the dev packages don't get installed if this is set.

I know python2 is EOLed but we need to live with it as long as we have some centos 7 servers.

This may have been caused by an update of Centos 7. I will continue to investigate.

This turns out to be yet more pip packages that has removed python2 support.
Now I use these restrictions to make it work.

additional_packages_pip:
  - certifi{{'==2021.10.8' if ansible_python_version is version('3', '<') else '' }}
  - requests{{'<2.28' if ansible_python_version is version('3', '<') else '' }}
  - urllib3{{'<2' if ansible_python_version is version('3', '<') else '' }}
  - websocket-client{{'<1' if ansible_python_version is version('3', '<') else '' }}
  - docker{{'<5' if ansible_python_version is version('3', '<') else '' }}

Thanks! I will run my regression tests on CentOS 7 and see if they fail now also. If they do then I will fix that and the probably similar to what you suggested there.

@janorn I just tried to run the regression tests I have around the docker sdk etc but it did not fail for me on a CentOS 7. What role configuration do you have around docker sdk and pip?

As we run with builtin pip this is what we do:

docker_additional_packages_pip:
  - certifi{{'==2021.10.8' if ansible_python_version is version('3', '<') else '' }}
  - requests{{'<2.28' if ansible_python_version is version('3', '<') else '' }}
  - urllib3{{'<2' if ansible_python_version is version('3', '<') else '' }}
  - websocket-client{{'<1' if ansible_python_version is version('3', '<') else '' }}
  - docker{{'<5' if ansible_python_version is version('3', '<') else '' }}

docker_additional_packages_os:
  - python2-pip
  - python-psycopg2
  - python2-backports-shutil_get_terminal_size

docker_x_skip_pip_auto_upgrade: true

A very simple test is to just do this from a clean centos 7 machine:

yum install -y python2-pip

And after that

pip install docker<5

That should break you pip install due to a new release of certifi released aprox 1 week ago.

So you do not install the Docker SDK the way this role got configuration for like seen in the link below?
https://github.com/haxorof/ansible-role-docker-ce/blob/master/tests/regression/test_postinstall.yml#L21-L33

I ran all those tests on the Vagrant VM image generic/centos7 and it did not fail but will try again and make sure it is using the latest one.

I ran the regression tests again on an updated CentOS 7 and everything works as expected. Might be that you are better off to handle all that pip relates stuff using a separate roll instead of trying to tweak things in this role since the normal scenarios works which installs the Docker SDK like:

- name: Test using PiP to install SDK, compose and stack
  hosts: test-host
  vars:
    docker_users:
      - vagrant
    docker_sdk: true
    docker_compose: true
    docker_stack: true
  roles:
    - haxorof.docker_ce

Here is what is in pip after this kind of installation on the CentOS 7 (generic/centos7):

[vagrant@centos7 ~]$ pip --version
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)

[vagrant@centos7 ~]$ pip freeze
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.      
attrs==21.4.0
backports.shutil-get-terminal-size==1.0.0
backports.ssl-match-hostname==3.5.0.1
bcrypt==3.1.7
cached-property==1.5.2
certifi==2021.10.8
cffi==1.15.0
chardet==4.0.0
configobj==4.7.2
configparser==4.0.2
contextlib2==0.6.0.post1
cryptography==3.3.2
decorator==3.4.0
distro==1.6.0
docker==4.4.4
docker-compose==1.26.2
dockerpty==0.4.1
docopt==0.6.2
enum34==1.1.10
functools32==3.2.3.post2
idna==2.10
importlib-metadata==2.1.3
iniparse==0.4
ipaddress==1.0.16
IPy==0.75
jsondiff==2.0.0
jsonschema==3.2.0
kitchen==1.1.1
paramiko==2.11.0
pathlib2==2.3.7.post1
perf==0.1
policycoreutils-default-encoding==0.1
pycparser==2.21
pycurl==7.19.0
pygobject==3.22.0
pygpgme==0.3
pyliblzma==0.5.3
PyNaCl==1.4.0
pyrsistent==0.16.1
python-dotenv==0.18.0
python-linux-procfs==0.4.9
pyudev==0.15
pyxattr==0.5.1
PyYAML==5.4.1
requests==2.27.1
scandir==1.10.0
schedutils==0.4
seobject==0.1
sepolicy==1.1
six==1.16.0
slip==0.4.0
slip.dbus==0.4.0
subprocess32==3.5.4
texttable==1.6.4
typing==3.10.0.0
urlgrabber==3.10
urllib3==1.26.9
websocket-client==0.59.0
yum-metadata-parser==1.1.4
zipp==1.2.0

Issue is that I can't upgrade pip. I use default pip in centos.

https://centos.pkgs.org/7/epel-x86_64/python2-pip-8.1.2-14.el7.noarch.rpm.html

Hence

docker_x_skip_pip_auto_upgrade: true

That pip version will cause you issues and I added some time ago just a check for not having pip below version 9.0.0: https://github.com/haxorof/ansible-role-docker-ce/blob/master/tasks/postinstall.yml#L121-L127

My role ensure pip2 is at least version 9.0.0 and below version 21.0.0. If it detects you have lower version than 9.0.0 then it will do the upgrade unless you have that docker_x_skip_pip_auto_upgrade set to true

I am aware. However I can't upgrade 🙁. We are moving away from centos 7 but slowly ...