Skip to content

Commit

Permalink
Merge pull request #4 from yetu/master
Browse files Browse the repository at this point in the history
Upgrade pip to "latest" version
  • Loading branch information
Bob Renwick committed Jun 6, 2015
2 parents 573ee89 + b177e4b commit 004b422
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Role Variables
--------------

- `pip_download_dest` specifies where `get-pip.py` should be downloaded to. Defaults to `/tmp`
- `pip_version` specifies which version of pip you want to install. Defaults to `None`, to install the latest version.
- `pip_version` specifies which version of pip you want to install.
- Defaults to `None`, to install the latest version (If pip is installed, upgrades to the latest pip version available)
- Can be set to a specific verion, e.g. `"6.0.8"` to force installation of that version.
- Can be set explicitly to `"LATEST"` to force upgrade to the latest available version (same behaviour as `None`).
- `python` specifies what Python executable to use. Defaults to `python`.
- `pip` specifies what pip executable to check and use. Defaults to `pip`.
12 changes: 10 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ignore_errors: true
changed_when: false
register: pip_is_installed
changed_when: false

- name: download pip
get_url: url=https://bootstrap.pypa.io/get-pip.py dest={{ pip_download_dest }}
Expand All @@ -27,9 +28,16 @@
shell: "{{ pip }} --version | awk '{print $2}'"
register: pip_installed_version
changed_when: false
when: pip_version != None
when: pip_version != None or pip_version != "LATEST"

- name: install required version of pip
command: "{{ pip }} install pip=={{ pip_version }}"
sudo: yes
when: pip_version != None and pip_installed_version.stdout != pip_version
when: pip_version != None and pip_installed_version.stdout != pip_version and pip_version != "LATEST"

- name: Upgrade to latest version of pip
command: "{{ pip }} install -U pip"
register: pip_latest_output
sudo: yes
changed_when: pip_latest_output.stdout.find('Requirement already up-to-date') == -1
when: pip_version == None or pip_version == "LATEST"

0 comments on commit 004b422

Please sign in to comment.