33

I want to pip install with --upgrade, using Ansible.

What's the syntax?

3 Answers 3

42
- name: install the package, force upgrade
  pip: 
    name: <your package name>
    state: latest

Or with:

- name: install the package, force reinstall to the latest version
  pip: 
    name: <your package name>
    state: forcereinstall
1
17

Eventually found the answer here: https://groups.google.com/forum/#!topic/ansible-project/a19JEpdXzck

this is the syntax:

- name: install the package, force upgrade
  pip: 
    name: <your package name>
    extra_args: --upgrade
1
  • Thank you, I was using shell: > pip install --upgrade pip and this is better due I am avoid the ansible-lint rule for shell commands.
    – Robert
    Apr 12, 2019 at 19:48
15

If you need upgrade pip for other python version, you can use executable parameter:

- name: install the package, force upgrade
  pip:
    name: pip
    executable: pip3
    state: latest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.