community.general.pip_package_info module – Pip package information

Note

This module is part of the community.general collection (version 8.5.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.pip_package_info.

Synopsis

  • Return information about installed pip packages

Aliases: packaging.language.pip_package_info

Requirements

The below requirements are needed on the host that executes this module.

  • The requested pip executables must be installed on the target.

Parameters

Parameter

Comments

clients

list / elements=path

A list of the pip executables that will be used to get the packages. They can be supplied with the full path or just the executable name, for example pip3.7.

Default: ["pip"]

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: N/A

This action does not modify state.

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Just get the list from default pip
  community.general.pip_package_info:

- name: Get the facts for default pip, pip2 and pip3.6
  community.general.pip_package_info:
    clients: ['pip', 'pip2', 'pip3.6']

- name: Get from specific paths (virtualenvs?)
  community.general.pip_package_info:
    clients: '/home/me/projec42/python/pip3.5'

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

packages

dictionary

a dictionary of installed package data

Returned: always

python

dictionary

A dictionary with each pip client which then contains a list of dicts with python package information

Returned: always

Sample: {"packages": {"pip": {"Babel": [{"name": "Babel", "source": "pip", "version": "2.6.0"}], "Flask": [{"name": "Flask", "source": "pip", "version": "1.0.2"}], "Flask-SQLAlchemy": [{"name": "Flask-SQLAlchemy", "source": "pip", "version": "2.3.2"}], "Jinja2": [{"name": "Jinja2", "source": "pip", "version": "2.10"}]}}}

Authors

  • Matthew Jones (@matburt)

  • Brian Coca (@bcoca)

  • Adam Miller (@maxamillion)