community.general.python_requirements_facts (0.1.4) — module

Show python path and assert dependency versions

Authors: Will Thames (@willthames), Ryan Scott Brown (@ryansb)

Install collection

Install with ansible-galaxy collection install community.general:==0.1.4


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.4

Description

Get info about available Python requirements on the target host, including listing required libraries and gathering versions.

This module was called C(python_requirements_facts) before Ansible 2.9. The usage did not change.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Show python lib/site paths
  python_requirements_info:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Check for modern boto3 and botocore versions
  python_requirements_info:
    dependencies:
    - boto3>1.6
    - botocore<2

Inputs

    
dependencies:
    description: 'A list of version-likes or module names to check for installation. Supported
      operators: <, >, <=, >=, or ==. The bare module name like I(ansible), the module
      with a specific version like I(boto3==1.6.1), or a partial version like I(requests>2)
      are all valid specifications.

      '

Outputs

mismatched:
  description: A dictionary of dependencies that did not satisfy the desired version
  returned: always
  sample:
    botocore:
      desired: botocore>2
      installed: 1.10.60
  type: dict
not_found:
  description: A list of packages that could not be imported at all, and are not installed
  returned: always
  sample:
  - boto4
  - requests
  type: list
python:
  description: path to python version used
  returned: always
  sample: /usr/local/opt/python@2/bin/python2.7
  type: str
python_system_path:
  description: List of paths python is looking for modules in
  returned: always
  sample:
  - /usr/local/opt/python@2/site-packages/
  - /usr/lib/python/site-packages/
  - /usr/lib/python/site-packages/
  type: list
python_version:
  description: version of python
  returned: always
  sample: 2.7.15 (default, May  1 2018, 16:44:08) [GCC 4.2.1 Compatible Apple LLVM
    9.1.0 (clang-902.0.39.1)]
  type: str
valid:
  description: A dictionary of dependencies that matched their desired versions. If
    no version was specified, then I(desired) will be null
  returned: always
  sample:
    boto3:
      desired: null
      installed: 1.7.60
    botocore:
      desired: botocore<2
      installed: 1.10.60
  type: dict