Bootstrap FreeKB - Ansible - pip module
Ansible - pip module

Updated:   |  Ansible articles

If you are not familiar with modules, check out Ansible - Getting Started with Modules.

The pip module can be used to use pip to do something, such as installing a Python package.

pip will need to be installed on your managed nodes. The yum module can be used to install pip on your managed nodes.

AVOID TROUBLE

There are 3 versions of pip

  • pip is used for Python version 2.6 and below
  • pip2 is used for Python version 2.7 and above
  • pip3 is used for Python version 3

For example, the /usr/bin/pip command (or just pip) would be used for Python version 2.6 and below.

In this example, pip will be used to install the latest version of pymysql.

- name: pip install the latest version of pymysql
  pip:
    name: pymysql
    state: latest

 

Or to install a specific version of pymysql.

- name: pip install pymysql version 0.10.1
  pip:
    name: pymysql=0.10.1

 

To install two (or more) packages.

- name: pip install the latest versions of pymysql and django
  pip:
    name:
      - pymysql
      - django
    state: latest

 

To uninstall pymysql.

- name: pip uninstall pymysql
  pip:
    name: pymysql
    state: absent

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 049dd3 in the box below so that we can be sure you are a human.