Goal and Environment
I am using ansible against Ubuntu 16.04 .
The ultimate goal is to use mongodb_user module.
This requires pymongo, so this require python-pip
What am I doing
- name: Package prerequisites for pymongo ansible module
apt:
force_apt_get: yes
name: ['python-pip', 'python-setuptools']
install_recommends: no
state: present
become: true
tags:
- mongo
register: output
- name: Upgrade pip to latest vesion
pip:
name: pip
extra_args: --upgrade
register: output
- debug:
var: output
The problem
This is actual output; please note:
- seems
pipignores upgrade instructions - the
/usr/bin/pip2binary , while I was expecte
"output": {
"changed": true,
"cmd": [
"/usr/bin/pip2",
"install",
"--upgrade",
"pip"
],
"failed": false,
"name": [
"pip"
],
"requirements": null,
"state": "present",
"stderr": "You are using pip version 8.1.1, however version 18.1 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n",
"stderr_lines": [
"You are using pip version 8.1.1, however version 18.1 is available.",
"You should consider upgrading via the 'pip install --upgrade pip' command."
],
"stdout": "Collecting pip\n Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl\nInstalling collected packages: pip\nSuccessfully installed pip-8.1.1\n",
"stdout_lines": [
"Collecting pip",
" Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl",
"Installing collected packages: pip",
"Successfully installed pip-8.1.1"
],
"version": null,
"virtualenv": null
}
The strange thing is that, from command line I got
$ /usr/bin/pip2 -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$ /home/mirko/.local/bin/pip -V
pip 18.1 from /home/mirko/.local/lib/python2.7/site-packages/pip (python 2.7)
A try
I tried to manually upgrade pip after install of python-pip and got another strange thing: pip do not want to uninstall old pip...
sudo pip install pip --upgrade
[sudo] password for mirko:
The directory '/home/mirko/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mirko/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 1.2MB/s
Installing collected packages: pip
Found existing installation: pip 8.1.1
Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Question(s)
What is the right way to use pip with ansible vs an Ubuntu 16.04?
Must/Can I force ansible to use "my" pip?
Must/Can I deinstall the "wrong" pip?
Have I done something wrong to create this dual-version problem?