Execution of ansible-playbook -e orchestrator=openstack -i inventory/ playbooks/configure_instances.yml fails during installation of the oslo.config OpenStack library with a message to upgrade the Python pip.
ansible-playbook -e orchestrator=openstack -i inventory/ playbooks/configure_instances.yml
oslo.config
Manual installation of pip does not help considering that the above ansible-playbook execution removes any existing pip installation and starts all over again.
ansible-playbook
This article explains how to troubleshoot and resolve the issue.
The following messages are seen in the log:
11-03 16:28:58:749 TASK [kolla_deployer : install packages used to generate passwords] ****************************************** *************************************************************************************** ***************************************************** 11-03 16:28:58:757 failed: [localhost] (item=[u'pycrypto', u'oslo.config', u'oslo.utils']) => {"ansible_loop_var": "item", "changed": false, "cmd": ["/usr/bin/pip2", "install", "-U", "pycrypto", "oslo.config", "oslo.utils"], "item": ["pycrypto", "oslo.config", "oslo.utils"], "msg": "stdout: Collecting pycrypto\n Downloading https://files.pythonhosted.org/packages/60/db /645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz (446kB)\nCollecting oslo.config\n Downloading https://files.pythonhosted.org/packages/ef/ac/b9015ba65085e73971ec0caa34e99e0a5e16fd7e521274d5224507b004a4/oslo.config-8.5.0.tar.gz (159kB)\n Complete output from command python setup.py egg_info:\n /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'requires_python'\n warnings.warn(msg)\n /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'\n warnings.warn(msg)\n /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'\n warnings.warn(msg)\n /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'\n warnings.warn(msg)\n \n Installed /tmp/pip-build-zXOmDg /oslo.config/pbr-5.5.1-py2.7.egg\n Marker evaluation failed, see the following error. For more information see: http://docs.openstack.org/pbr/latest/user/using.html#environment-markers\n ERROR:root:Error parsing\n Traceback (most recent call last):\n File \"/tmp/pip-build-zXOmDg/oslo.config/pbr-5.5.1-py2.7.egg/pbr/core.py\", line 96, in pbr\n attrs = util.cfg_to_args(path, dist.script_args)\n File \"/tmp/pip-build-zXOmDg/oslo.config/pbr-5.5.1-py2.7.egg/pbr/util.py\", line 273, in cfg_to_args\n kwargs = setup_cfg_to_setup_kwargs(config, script_args)\n File \"/tmp/pip-build-zXOmDg/oslo.config/pbr-5.5.1- py2.7.egg/pbr/util.py\", line 472, in setup_cfg_to_setup_kwargs\n if pkg_resources.evaluate_marker('(%s)' % env_marker):\n File \"/usr/lib/python2.7/site-packages/pkg_resources.py\", line 1364, in evaluate_marker\n return interpret(parser.expr(text).totuple(1)[1])\n File \"/usr/lib/python2.7/site-packages/pkg_resources.py\", line 1342, in interpret\n return op(nodelist)\n File \"/usr/lib/python2.7/site-packages/pkg_resources.py\", line 1307, in atom\n return interpret(nodelist[2])\n File \"/usr/lib/python2.7/site-packages/pkg_resources.py\", line 1342, in interpret\n return op(nodelist)\n File \"/usr/lib/python2.7/site-packages/pkg_resources.py\", line 1324, in comparison\n raise SyntaxError(repr(cop)+\" operator not allowed in environment markers\")\n SyntaxError: '<' operator not allowed in environment markers\n error in setup command: Error parsing /tmp/pip-build-zXOmDg/oslo.config/setup.cfg: SyntaxError: '<' operator not allowed in environment markers\n \n ----------------------------------------\n\n:stderr: Command \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-build-zXOmDg/oslo.config/\nYou are using pip version 8.1.2, however version 21.0.1 is available. \nYou should consider upgrading via the 'pip install --upgrade pip' command.\n"} 11-03 16:28:59:118
As indicated in the above logs, notice that the system is using an earlier version of pip (package installer for python), which is not compatible with the oslo wheel file. Notice also that the installation is using Python 2.7 ( /usr/lib/python2.7/site-packages/pkg_resources.py ) and not 3.x.
/usr/lib/python2.7/site-packages/pkg_resources.py
This issue is caused by pip installation failure.
[root@cftsvm54 ]# cd playbooks/roles/instance/tasks/ [root@cftsvm54 tasks]# cat RedHat.yml --- - name: set selinux to permissive selinux: policy: targeted state: permissive # we need to remove python-requests installed by distutils # cause it conflicts with requests lib installed by pip during docker-compose install - name: remove python-requests installed by distutils package: name: python-requests state: absent register: res retries: 5 until: res | success - name: Install pip block: - name: Install easy_install package: name: python-setuptools state: present register: res retries: 5 until: res | success - name: Install pip easy_install: name: pip state: latest when: - ansible_distribution != "RedHat" - ansible_distribution != "Red Hat Enterprise Linux" # Do not use easy_install for RedHat. There is a bug that might cause # easy_install to hang: # https://github.com/ansible/ansible/issues/15769 # https://bugzilla.redhat.com/show_bug.cgi?id=1702797 # Use shell to intall pip for RedHat to work around the bug - name: Install pip for Red Hat block: - name: Get pip installer get_url: url: https://bootstrap.pypa.io/get-pip.py dest: /tmp/get-pip.py - name: Install pip shell: python /tmp/get-pip.py register: rc retries: 5 until: rc | success when: (ansible_distribution == "RedHat" or ansible_distribution == "Red Hat Enterprise Linux")
If you try to download and look into the get-pip.py file from the above location, you will see that the latest get-pip.py from the default location supports a minimum Python version of 3.x.
get-pip.py
import sys this_python = sys.version_info[:2] min_version = (3, 6) if this_python < min_version: message_parts = [ "This script does not work on Python {}.{}".format(*this_python), "The minimum supported Python version is {}.{}.".format(*min_version), "Please use https://bootstrap.pypa.io/pip/{}.{}/get-pip.py instead.".format(*this_python), ] print("ERROR: " + " ".join(message_parts)) sys.exit(1)
import sys this_python = sys.version_info[:2] min_version = (3, 6) if this_python < min_version: message_parts = [ "This script does not work on Python {}.{}".format(*this_python), "The minimum supported Python version is {}.{}.".format(*min_version), "Please use https://bootstrap.pypa.io/pip/{}.{}/get-pip.py instead.".format(*this_python), ] print("ERROR: " + " ".join(message_parts))
sys.exit(1)
To ensure that the installation succeeds, change the path in the playbooks/roles/instance/tasks/RedHat.yml file to point to the correct URL: https://bootstrap.pypa.io/pip/2.7/get-pip.py .
playbooks/roles/instance/tasks/RedHat.yml
https://bootstrap.pypa.io/pip/2.7/get-pip.py
[root@cftsvm54 contrail-ansible-deployer]# cat playbooks/roles/instance/tasks/RedHat.yml | more --- - name: set selinux to permissive selinux: policy: targeted state: permissive # we need to remove python-requests installed by distutils # cause it conflicts with requests lib installed by pip during docker-compose install - name: remove python-requests installed by distutils package: name: python-requests state: absent register: res retries: 5 until: res | success - name: Install pip block: - name: Install easy_install package: name: python-setuptools state: present register: res retries: 5 until: res | success - name: Install pip easy_install: name: pip state: latest when: - ansible_distribution != "RedHat" - ansible_distribution != "Red Hat Enterprise Linux" # Do not use easy_install for RedHat. There is a bug that might cause # easy_install to hang: # https://github.com/ansible/ansible/issues/15769 # https://bugzilla.redhat.com/show_bug.cgi?id=1702797 # Use shell to intall pip for RedHat to work around the bug - name: Install pip for Red Hat block: - name: Get pip installer get_url: url: https://bootstrap.pypa.io/pip/2.7/get-pip.py dest: /tmp/get-pip.py - name: Install pip shell: python /tmp/get-pip.py register: rc retries: 5 until: rc | success when: (ansible_distribution == "RedHat" or ansible_distribution == "Red Hat Enterprise Linux")