Coder Social home page Coder Social logo

geerlingguy / ansible-role-pip Goto Github PK

View Code? Open in Web Editor NEW
194.0 8.0 129.0 50 KB

Ansible Role - Pip (for Python)

Home Page: https://galaxy.ansible.com/geerlingguy/pip/

License: MIT License

ansible role galaxy python pip packaging package-manager

ansible-role-pip's Introduction

Ansible Role: Pip (for Python)

CI

An Ansible Role that installs Pip on Linux.

Requirements

On RedHat/CentOS, you may need to have EPEL installed before running this role. You can use the geerlingguy.repo-epel role if you need a simple way to ensure it's installed.

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

pip_package: python3-pip

The name of the package to install to get pip on the system. For older systems that don't have Python 3 available, you can set this to python-pip.

pip_executable: pip3

The role will try to autodetect the pip executable based on the pip_package (e.g. pip for Python 2 and pip3 for Python 3). You can also override this explicitly, e.g. pip_executable: pip3.6.

pip_install_packages: []

A list of packages to install with pip. Examples below:

pip_install_packages:
  # Specify names and versions.
  - name: docker
    version: "1.2.3"
  - name: awscli
    version: "1.11.91"

  # Or specify bare packages to get the latest release.
  - docker
  - awscli

  # Or uninstall a package.
  - name: docker
    state: absent

  # Or update a package to the latest version.
  - name: docker
    state: latest

  # Or force a reinstall.
  - name: docker
    state: forcereinstall

  # Or install a package in a particular virtualenv.
  - name: docker
    virtualenv: /my_app/venv

  # Or pass through any extra arguments.
  - name: my_special_package_from_my_special_repo
    extra_args: --extra-index-url https://my-domain/pypi/pypi-master/simple

Dependencies

None.

Example Playbook

- hosts: all

  vars:
    pip_install_packages:
      - name: docker
      - name: awscli

  roles:
    - geerlingguy.pip

License

MIT / BSD

Author Information

This role was created in 2017 by Jeff Geerling, author of Ansible for DevOps.

ansible-role-pip's People

Contributors

barnabasbusa avatar blakeashleyjr avatar dmotte avatar ericsysmin avatar fgierlinger avatar geerlingguy avatar grahamlyons avatar kakawait avatar michaelpporter avatar slavoutich avatar sm-gravid-day avatar victorock avatar zloveless avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-pip's Issues

Be able to choose state for each package

Will be allow us to upgrade or uninstall pip packages.

Today there is no state, so fallback to default present.

like

pip_install_packages:
  # Specify names and versions.
  - name: docker
    version: "1.2.3"
  - name: awscli
    version: "1.11.91"
    state: forcereinstall
  # Or specify bare packages to get the latest release.
  - docker
    state: latest
  - awscli
    state: absent

CentOS 8 / EL 8, python-pip is not an available package

    centos8hv: fatal: [localhost]: FAILED! => {"changed": false, "failures": ["No package python-pip available."], "msg": "Failed to install some of the specified packages", "rc": 1, "results": []}

For CentOS 8 / EL 8, the correct package is python3-pip. I will fix this and make a PR.

[vagrant@centos8 ~]$ sudo dnf install python3-pip
Last metadata expiration check: 0:06:41 ago on Mon 28 Oct 2019 06:29:06 AM UTC.
Dependencies resolved.
===================================================================================================================== Package                Arch              Version                                         Repository            Size
=====================================================================================================================Installing:
 python3-pip            noarch            9.0.3-13.el8                                    AppStream             18 k
Installing dependencies:
 python36               x86_64            3.6.8-2.module_el8.0.0+33+0a10c0e1              AppStream             19 k
Enabling module streams:
 python36                                 3.6

How to install the latest 21.3.1 version of pip, and not 9.0.1 - cant install docker-compose on Ubuntu 18.04

I'm trying to use this role to install the pip release of docker-compose on an Ubuntu 18.04 machine, my playbook:

- hosts: all
  gather_facts: no
  become: yes

  vars:
    pip_package: python3-pip
    pip_install_packages:
      - name: docker
      - name: docker-compose==1.29.2

  roles:
    - geerlingguy.pip

Problem is, the role installs the old pip 9.0.1, which results in the following error when trying to install docker-compose:
ModuleNotFoundError: No module named 'setuptools_rust'

If i upgrade pip manually on the server to 21.3.1, the playbook works.

How can we get the latest version of pip from the role? Or is that not supported?

Role doesn't install multiple pip packages when included in another role

Given a role that has a dependency on geerlingguy.pip, and a task to include that role like this:

- name: Install pip packages
  include_role:
    name: geerlingguy.pip
    vars:
      pip_install_packages:
        - name: pip
          version: "9.0.1"
        - name: boto
          version: "2.48.0"

When the role is called in a playbook, no packages are installed; output from -vvvv:

virtualbox-iso: TASK [geerlingguy.pip : Ensure Pip is installed.] ******************************
    virtualbox-iso: task path: /Users/gaahrdner/Code/ansible/galaxy_roles/geerlingguy.pip/tasks/main.yml:2
    virtualbox-iso: Running yum
    virtualbox-iso: Using module file /Library/Python/2.7/site-packages/ansible/modules/packaging/os/yum.py
    virtualbox-iso: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: gaahrdner
    virtualbox-iso: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=50628 -o 'IdentityFile="/private/var/folders/4f/qzq9s9bn5_lcy422r6hs77y80000gp/T/ansible-key582220847"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=gaahrdner -o ConnectTimeout=10 -o ControlPath=/Users/gaahrdner/.ansible/cp/fb1bf13d91 127.0.0.1 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
    virtualbox-iso: <127.0.0.1> (0, '/home/vagrant\n', 'OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /Users/gaahrdner/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 53: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 8475\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
    virtualbox-iso: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: gaahrdner
    virtualbox-iso: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=50628 -o 'IdentityFile="/private/var/folders/4f/qzq9s9bn5_lcy422r6hs77y80000gp/T/ansible-key582220847"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=gaahrdner -o ConnectTimeout=10 -o ControlPath=/Users/gaahrdner/.ansible/cp/fb1bf13d91 127.0.0.1 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029 `" && echo ansible-tmp-1503427411.58-173635050943029="` echo /home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029 `" ) && sleep 0'"'"''
    virtualbox-iso: <127.0.0.1> (0, 'ansible-tmp-1503427411.58-173635050943029=/home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029\n', 'OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /Users/gaahrdner/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 53: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 8475\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
    virtualbox-iso: <127.0.0.1> PUT /var/folders/4f/qzq9s9bn5_lcy422r6hs77y80000gp/T/tmpOGJqhc TO /home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029/yum.py
    virtualbox-iso: <127.0.0.1> SSH: EXEC scp -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=50628 -o 'IdentityFile="/private/var/folders/4f/qzq9s9bn5_lcy422r6hs77y80000gp/T/ansible-key582220847"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=gaahrdner -o ConnectTimeout=10 -o ControlPath=/Users/gaahrdner/.ansible/cp/fb1bf13d91 /var/folders/4f/qzq9s9bn5_lcy422r6hs77y80000gp/T/tmpOGJqhc '[127.0.0.1]:/home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029/yum.py'
    virtualbox-iso: <127.0.0.1> (0, '', 'Executing: program /usr/bin/ssh host 127.0.0.1, user (unspecified), command scp -v -t /home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029/yum.py\nOpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /Users/gaahrdner/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 53: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 8475\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\nSending file modes: C0600 88566 tmpOGJqhc\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
    virtualbox-iso: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: gaahrdner
    virtualbox-iso: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=50628 -o 'IdentityFile="/private/var/folders/4f/qzq9s9bn5_lcy422r6hs77y80000gp/T/ansible-key582220847"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=gaahrdner -o ConnectTimeout=10 -o ControlPath=/Users/gaahrdner/.ansible/cp/fb1bf13d91 127.0.0.1 '/bin/sh -c '"'"'chmod u+x /home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029/ /home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029/yum.py && sleep 0'"'"''
    virtualbox-iso: <127.0.0.1> (0, '', 'OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /Users/gaahrdner/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 53: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 8475\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
    virtualbox-iso: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: gaahrdner
    virtualbox-iso: <127.0.0.1> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=50628 -o 'IdentityFile="/private/var/folders/4f/qzq9s9bn5_lcy422r6hs77y80000gp/T/ansible-key582220847"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=gaahrdner -o ConnectTimeout=10 -o ControlPath=/Users/gaahrdner/.ansible/cp/fb1bf13d91 -tt 127.0.0.1 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-izrgzdtzmlhokvceysehkylayltdknob; /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029/yum.py; rm -rf "/home/vagrant/.ansible/tmp/ansible-tmp-1503427411.58-173635050943029/" > /dev/null 2>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''
    virtualbox-iso: <127.0.0.1> (0, '\n{"msg": "", "invocation": {"module_args": {"name": ["python-pip"], "list": null, "install_repoquery": true, "conf_file": null, "disable_gpg_check": false, "state": "present", "disablerepo": null, "update_cache": false, "enablerepo": null, "exclude": null, "validate_certs": true, "installroot": "/", "skip_broken": false}}, "changed": false, "results": ["python2-pip-8.1.2-5.el7.noarch providing python-pip is already installed"], "rc": 0}\n', 'OpenSSH_7.4p1, LibreSSL 2.5.0\r\ndebug1: Reading configuration data /Users/gaahrdner/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 53: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 8475\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 127.0.0.1 closed.\r\n')
    virtualbox-iso: ok: [default] => {
    virtualbox-iso:     "changed": false,
    virtualbox-iso:     "invocation": {
    virtualbox-iso:         "module_args": {
    virtualbox-iso:             "conf_file": null,
    virtualbox-iso:             "disable_gpg_check": false,
    virtualbox-iso:             "disablerepo": null,
    virtualbox-iso:             "enablerepo": null,
    virtualbox-iso:             "exclude": null,
    virtualbox-iso:             "install_repoquery": true,
    virtualbox-iso:             "installroot": "/",
    virtualbox-iso:             "list": null,
    virtualbox-iso:             "name": [
    virtualbox-iso:                 "python-pip"
    virtualbox-iso:             ],
    virtualbox-iso:             "skip_broken": false,
    virtualbox-iso:             "state": "present",
    virtualbox-iso:             "update_cache": false,
    virtualbox-iso:             "validate_certs": true
    virtualbox-iso:         }
    virtualbox-iso:     },
    virtualbox-iso:     "msg": "",
    virtualbox-iso:     "rc": 0,
    virtualbox-iso:     "results": [
    virtualbox-iso:         "python2-pip-8.1.2-5.el7.noarch providing python-pip is already installed"
    virtualbox-iso:     ]
    virtualbox-iso: }
    virtualbox-iso:
    virtualbox-iso: TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] ************
    virtualbox-iso: task path: /Users/gaahrdner/Code/ansible/galaxy_roles/geerlingguy.pip/tasks/main.yml:5

I'm not super sure why the boto package isn't included in the with_items array either.

Install pip3 on python3

Is it possible to add a configuration variable in order to install pip3 instead of pip ?

Something like that

- name: Ensure Pip is installed.
  package: name="{{ 'python3-pip' if python_version == 3 else 'python-pip' }}" state=present

Can't install docker using pip on Debian 12

Using the following playbook worked just fine using Debian 11, but it seems to break on Debian 12:

- hosts: all
  become: true
  roles:
    - role: geerlingguy.pip
      vars:
      pip_install_packages:
        - name: docker

Error:

โ”‚ TASK [geerlingguy.pip : Ensure Pip is installed.] ******************************
โ”‚ changed: [49.X.X.X]
โ”‚ 
โ”‚ TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] ************
โ”‚ failed: [49.X.X.X] (item={'name': 'docker'}) => {"ansible_loop_var": "item", "changed": false, "cmd": ["/usr/bin/pip3", "install",
โ”‚ "docker"], "item": {"name": "docker"}, "msg": "\n:stderr: error: externally-managed-environment\n\nร— This environment is externally
โ”‚ managed\nโ•ฐโ”€> To install Python packages system-wide, try apt install\n    python3-xyz, where xyz is the package you are trying to\n
โ”‚ install.\n    \n    If you wish to install a non-Debian-packaged Python package,\n    create a virtual environment using python3 -m
โ”‚ venv path/to/venv.\n    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make\n    sure you have python3-full installed.\n
โ”‚ \n    If you wish to install a non-Debian packaged Python application,\n    it may be easiest to use pipx install xyz, which will
โ”‚ manage a\n    virtual environment for you. Make sure you have pipx installed.\n    \n    See /usr/share/doc/python3.11/README.venv
โ”‚ for more information.\n\nnote: If you believe this is a mistake, please contact your Python installation or OS distribution provider.
โ”‚ You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.\nhint: See PEP 668
โ”‚ for the detailed specification.\n"}

Should I pass the option --break-system-packages as the error message suggests or should I use a virtualenv. I am not very familiar with the Python package manager or virtualenvs and I just need to be able to use Ansible to manage Docker.

Thanks for your Videos and Open Source efforts ๐Ÿซถ๐Ÿผ

Support for additional options in pip

Support for the following:

  • pip_state: Useful when needed to specify the state of the pip package itself (Ex: latest)
  • extra_args Useful when modules must be upgraded (Ex: --upgrade)
  • executable Useful when multiple pip version are installed (Ex: pip3)

Getting a 404 error when download the .deb

when running this role my raspberry pis try to download the following .deb
http://raspbian.raspberrypi.org/raspbian/pool/main/p/python3.7/libpython3.7-dev_3.7.3-2+deb10u1_armhf.deb

but searching the FTP server i can only see deb10u2 and not dev10u1. this is resulting in a 404 error.

i am using the current vars:

    vars:
      pip_package: python3-pip
      pip_executable: pip3
      pip_install_packages:
        - name: docker

and here is an output from the full error

fatal: [192.168.0.200]: FAILED! => {"cache_update_time": 1590563370, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"      install 'python3-pip'' failed: E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/python3.7/libpython3.7-dev_3.7.3-2+deb10u1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]\nE: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/python3.7/python3.7-dev_3.7.3-2+deb10u1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]\nE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?\n", "rc": 100, "stderr": "E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/python3.7/libpython3.7-dev_3.7.3-2+deb10u1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]\nE: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/python3.7/python3.7-dev_3.7.3-2+deb10u1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]\nE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?\n", "stderr_lines": ["E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/python3.7/libpython3.7-dev_3.7.3-2+deb10u1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]", "E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/python3.7/python3.7-dev_3.7.3-2+deb10u1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]", "E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n  dh-python gir1.2-glib-2.0 libexpat1-dev libgirepository-1.0-1 libpython3-dev\n  libpython3.7-dev python-pip-whl python3-asn1crypto python3-cffi-backend\n  python3-crypto python3-cryptography python3-dbus python3-dev\n  python3-distutils python3-entrypoints python3-gi python3-keyring\n  python3-keyrings.alt python3-lib2to3 python3-secretstorage\n  python3-setuptools python3-wheel python3-xdg python3.7-dev\nSuggested packages:\n  python-crypto-doc python-cryptography-doc python3-cryptography-vectors\n  python-dbus-doc python3-dbus-dbg gnome-keyring libkf5wallet-bin\n  gir1.2-gnomekeyring-1.0 python-secretstorage-doc python-setuptools-doc\nThe following NEW packages will be installed:\n  dh-python gir1.2-glib-2.0 libexpat1-dev libgirepository-1.0-1 libpython3-dev\n  libpython3.7-dev python-pip-whl python3-asn1crypto python3-cffi-backend\n  python3-crypto python3-cryptography python3-dbus python3-dev\n  python3-distutils python3-entrypoints python3-gi python3-keyring\n  python3-keyrings.alt python3-lib2to3 python3-pip python3-secretstorage\n  python3-setuptools python3-wheel python3-xdg python3.7-dev\n0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 47.7 MB/51.4 MB of archives.\nAfter this operation, 84.3 MB of additional disk space will be used.\nErr:1 http://raspbian.raspberrypi.org/raspbian buster/main armhf libpython3.7-dev armhf 3.7.3-2+deb10u1\n  404  Not Found [IP: 93.93.128.193 80]\nErr:2 http://raspbian.raspberrypi.org/raspbian buster/main armhf python3.7-dev armhf 3.7.3-2+deb10u1\n  404  Not Found [IP: 93.93.128.193 80]\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following additional packages will be installed:", "  dh-python gir1.2-glib-2.0 libexpat1-dev libgirepository-1.0-1 libpython3-dev", "  libpython3.7-dev python-pip-whl python3-asn1crypto python3-cffi-backend", "  python3-crypto python3-cryptography python3-dbus python3-dev", "  python3-distutils python3-entrypoints python3-gi python3-keyring", "  python3-keyrings.alt python3-lib2to3 python3-secretstorage", "  python3-setuptools python3-wheel python3-xdg python3.7-dev", "Suggested packages:", "  python-crypto-doc python-cryptography-doc python3-cryptography-vectors", "  python-dbus-doc python3-dbus-dbg gnome-keyring libkf5wallet-bin", "  gir1.2-gnomekeyring-1.0 python-secretstorage-doc python-setuptools-doc", "The following NEW packages will be installed:", "  dh-python gir1.2-glib-2.0 libexpat1-dev libgirepository-1.0-1 libpython3-dev", "  libpython3.7-dev python-pip-whl python3-asn1crypto python3-cffi-backend", "  python3-crypto python3-cryptography python3-dbus python3-dev", "  python3-distutils python3-entrypoints python3-gi python3-keyring", "  python3-keyrings.alt python3-lib2to3 python3-pip python3-secretstorage", "  python3-setuptools python3-wheel python3-xdg python3.7-dev", "0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.", "Need to get 47.7 MB/51.4 MB of archives.", "After this operation, 84.3 MB of additional disk space will be used.", "Err:1 http://raspbian.raspberrypi.org/raspbian buster/main armhf libpython3.7-dev armhf 3.7.3-2+deb10u1", "  404  Not Found [IP: 93.93.128.193 80]", "Err:2 http://raspbian.raspberrypi.org/raspbian buster/main armhf python3.7-dev armhf 3.7.3-2+deb10u1", "  404  Not Found [IP: 93.93.128.193 80]"]}

let me know if you need any more information.

Parameters are mutually exclusive: executable|virtualenv

Hi. First of all, thanks a lot for this role ๐Ÿ˜‰ it's very useful

Using geerlingguy.pip role version: 2.2.0

Using Ansible core version 2.14.2

My Ansible task:

- name: Install some pip packages
  ansible.builtin.include_role: { name: geerlingguy.pip }
  vars:
    ansible_become: true
    pip_install_packages:
      - name: glances==3.*
        virtualenv: /opt/venv01

What I get:

TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] ************
failed: [default] (item={'name': 'glances==3.*', 'virtualenv': '/opt/venv01'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "glances==3.*", "virtualenv": "/opt/venv01"}, "msg": "parameters are mutually exclusive: executable|virtualenv"}

I believe the error is at: https://github.com/geerlingguy/ansible-role-pip/blob/master/tasks/main.yml#L14

Maybe the executable task parameter should be changed to "{{ pip_executable | default(omit) }}" and the pip_executable variable should be unset by default? Don't know, just proposing something

Can't install role from Ansible Galaxy: error: unable to compare role versions

Did something change with geerling.pip (latest)?
I'm getting errors all of a sudden, but it could just be on my end.

[WARNING]: - geerlingguy.pip was NOT installed successfully: Unable to compare
role versions (1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.2.2, 1.3.0, 2.0.0, 2.1.0, 2.2.0,
master) to determine the most recent version due to incompatible version
formats. Please contact the role author to resolve versioning conflicts, or
specify an explicit role version to install.
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

I wasn't specifying a version before--just the name. I imagine that means I'm using latest.
If I specify version2.2.0 it works for me again.

Fails on Ubuntu

DESCRIPTION

When installing packages on Ubuntu, this will fail if the user does not do an apt-get update outside of this role.

STEPS

  1. ansible-playbook provision/playbooks/common.yml -vvv
---
## common.yml
- hosts: all
  gather_facts: yes
  become: true
  roles:
    - geerlingguy.pip
  vars:
    pip_install_packages:
      - name: docker

EXPECTED RESULTS

I expected that any required system packages to be installed would be installed, where the role would take care of the required apt-get update.

If this is purposefully omitted for some reason, then I expected there would be a documented variable to enabled updates.

ACTUAL RESULTS

fatal: [client.test]: FAILED! => {
    "cache_update_time": 1602066390,
    "cache_updated": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "name": "python3-pip",
            "only_upgrade": false,
            "package": [
                "python3-pip"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    },
    "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"      install 'python3-pip'' failed: E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-48.52_amd64.deb  404  Not Found [IP: 91.189.91.38 80]\nE: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g-dev_1.2.11.dfsg-2ubuntu1.1_amd64.deb  404  Not Found [IP: 91.189.91.38 80]\nE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?\n",
    "rc": 100,
    "stderr": "E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-48.52_amd64.deb  404  Not Found [IP: 91.189.91.38 80]\nE: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g-dev_1.2.11.dfsg-2ubuntu1.1_amd64.deb  404  Not Found [IP: 91.189.91.38 80]\nE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?\n",
    "stderr_lines": [
        "E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-48.52_amd64.deb  404  Not Found [IP: 91.189.91.38 80]",
        "E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g-dev_1.2.11.dfsg-2ubuntu1.1_amd64.deb  404  Not Found [IP: 91.189.91.38 80]",
        "E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?"
    ],
    "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n  binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-9\n  dpkg-dev fakeroot g++ g++-9 gcc gcc-9 gcc-9-base libalgorithm-diff-perl\n  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1\n  libbinutils libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0\n  libctf0 libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl\n  libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libmpc3 libpython3-dev\n  libpython3.8-dev libquadmath0 libstdc++-9-dev libtsan0 libubsan1\n  linux-libc-dev make manpages-dev python-pip-whl python3-dev\n  python3-distutils python3-lib2to3 python3-setuptools python3-wheel\n  python3.8-dev zlib1g-dev\nSuggested packages:\n  binutils-doc cpp-doc gcc-9-locales debian-keyring g++-multilib\n  g++-9-multilib gcc-9-doc gcc-multilib autoconf automake libtool flex bison\n  gdb gcc-doc gcc-9-multilib glibc-doc bzr libstdc++-9-doc make-doc\n  python-setuptools-doc\nThe following NEW packages will be installed:\n  binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-9\n  dpkg-dev fakeroot g++ g++-9 gcc gcc-9 gcc-9-base libalgorithm-diff-perl\n  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1\n  libbinutils libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0\n  libctf0 libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl\n  libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libmpc3 libpython3-dev\n  libpython3.8-dev libquadmath0 libstdc++-9-dev libtsan0 libubsan1\n  linux-libc-dev make manpages-dev python-pip-whl python3-dev\n  python3-distutils python3-lib2to3 python3-pip python3-setuptools\n  python3-wheel python3.8-dev zlib1g-dev\n0 upgraded, 53 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 1293 kB/47.3 MB of archives.\nAfter this operation, 204 MB of additional disk space will be used.\nIgn:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-48.52\nErr:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.1\n  404  Not Found [IP: 91.189.91.38 80]\nErr:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-48.52\n  404  Not Found [IP: 91.189.91.38 80]\n",
    "stdout_lines": [
        "Reading package lists...",
        "Building dependency tree...",
        "Reading state information...",
        "The following additional packages will be installed:",
        "  binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-9",
        "  dpkg-dev fakeroot g++ g++-9 gcc gcc-9 gcc-9-base libalgorithm-diff-perl",
        "  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1",
        "  libbinutils libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0",
        "  libctf0 libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl",
        "  libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libmpc3 libpython3-dev",
        "  libpython3.8-dev libquadmath0 libstdc++-9-dev libtsan0 libubsan1",
        "  linux-libc-dev make manpages-dev python-pip-whl python3-dev",
        "  python3-distutils python3-lib2to3 python3-setuptools python3-wheel",
        "  python3.8-dev zlib1g-dev",
        "Suggested packages:",
        "  binutils-doc cpp-doc gcc-9-locales debian-keyring g++-multilib",
        "  g++-9-multilib gcc-9-doc gcc-multilib autoconf automake libtool flex bison",
        "  gdb gcc-doc gcc-9-multilib glibc-doc bzr libstdc++-9-doc make-doc",
        "  python-setuptools-doc",
        "The following NEW packages will be installed:",
        "  binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-9",
        "  dpkg-dev fakeroot g++ g++-9 gcc gcc-9 gcc-9-base libalgorithm-diff-perl",
        "  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1",
        "  libbinutils libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0",
        "  libctf0 libdpkg-perl libexpat1-dev libfakeroot libfile-fcntllock-perl",
        "  libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libmpc3 libpython3-dev",
        "  libpython3.8-dev libquadmath0 libstdc++-9-dev libtsan0 libubsan1",
        "  linux-libc-dev make manpages-dev python-pip-whl python3-dev",
        "  python3-distutils python3-lib2to3 python3-pip python3-setuptools",
        "  python3-wheel python3.8-dev zlib1g-dev",
        "0 upgraded, 53 newly installed, 0 to remove and 0 not upgraded.",
        "Need to get 1293 kB/47.3 MB of archives.",
        "After this operation, 204 MB of additional disk space will be used.",
        "Ign:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-48.52",
        "Err:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.1",
        "  404  Not Found [IP: 91.189.91.38 80]",
        "Err:1 http://security.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-48.52",
        "  404  Not Found [IP: 91.189.91.38 80]"
    ]
}

[DEPRECATION WARNING]: Invoking "pip" only once while using a loop via squash_actions is deprecated

Hi Jeff

I'm getting following warning when using the role:

[DEPRECATION WARNING]: Invoking "pip" only once while using a loop via
squash_actions is deprecated. Instead of using a loop to supply multiple items
and specifying `name: "{{ item.name | default(item) }}"`, please use `name: '{{
 pip_install_packages }}'` and remove the loop. This feature will be removed in
 version 2.11.

I'm setting variable like this in group_vars file:

pip_install_packages:
      - docker
      - docker-compose

roles

  • geerlingguy.docker, 2.9.0
  • geerlingguy.pip, 2.0.0

dont set pip module executable by default

If your playbook sets the python interpreter to python3 like

ansible_python_interpreter: /usr/bin/python3

and then you use this role without setting

pip_package: python3-pip

It will use pip by default:

executable: "{{ 'pip3' if pip_package == 'python3-pip' else 'pip' }}"

imho I feel it would be better not to set a default executable and omit it unless one is specifically set since the pip module will then use whatever python interpreter ansible is using.

in short i do not agree the executable should have a default value :)

docker-compose pip package installation fails on Debian 12.

Installing other pip packages like docker works thanks to the fix in PR: #58.
However, docker-compose pip package still fails with the following error:

TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] ************************************************************************************************************************************************************************************************************************************************
changed: [bootnode-1] => (item={'name': 'docker'})
failed: [bootnode-1] (item={'name': 'docker-compose'}) => changed=false 
  ansible_loop_var: item
  cmd:
  - /usr/bin/pip3
  - install
  - docker-compose
  item:
    name: docker-compose
  msg: |-
    stdout: Collecting docker-compose
      Downloading docker_compose-1.29.2-py2.py3-none-any.whl (114 kB)
         โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 114.8/114.8 kB 4.0 MB/s eta 0:00:00
    Collecting PyYAML<6,>=3.10
      Downloading PyYAML-5.4.1.tar.gz (175 kB)
         โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 175.1/175.1 kB 16.9 MB/s eta 0:00:00
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'error'
  
    :stderr:   error: subprocess-exited-with-error
  
      ร— Getting requirements to build wheel did not run successfully.
      โ”‚ exit code: 1
      โ•ฐโ”€> [68 lines of output]
          /tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
          !!
  
                  ********************************************************************************
                  The license_file parameter is deprecated, use license_files instead.
  
                  By 2023-Oct-30, you need to update your project and remove deprecated calls
                  or your builds will no longer be supported.
  
                  See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
                  ********************************************************************************
  
          !!
            parsed = self.parsers.get(option_name, lambda x: x)(value)
          running egg_info
          writing lib3/PyYAML.egg-info/PKG-INFO
          writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
          writing top-level names to lib3/PyYAML.egg-info/top_level.txt
          Traceback (most recent call last):
            File "/usr/lib/python3/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/usr/lib/python3/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/usr/lib/python3/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
              return hook(config_settings)
                     ^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
              return self._get_build_requires(config_settings, requirements=['wheel'])
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/build_meta.py", line 323, in _get_build_requires
              self.run_setup()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/build_meta.py", line 338, in run_setup
              exec(code, locals())
            File "<string>", line 271, in <module>
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/__init__.py", line 107, in setup
              return distutils.core.setup(**attrs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/_distutils/core.py", line 185, in setup
              return run_commands(dist)
                     ^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/_distutils/core.py", line 201, in run_commands
              dist.run_commands()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/_distutils/dist.py", line 969, in run_commands
              self.run_command(cmd)
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/dist.py", line 1234, in run_command
              super().run_command(command)
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/command/egg_info.py", line 314, in run
              self.find_sources()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/command/egg_info.py", line 322, in find_sources
              mm.run()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/command/egg_info.py", line 551, in run
              self.add_defaults()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/command/egg_info.py", line 589, in add_defaults
              sdist.add_defaults(self)
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/command/sdist.py", line 104, in add_defaults
              super().add_defaults()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
              self._add_defaults_ext()
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
              self.filelist.extend(build_ext.get_source_files())
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "<string>", line 201, in get_source_files
            File "/tmp/pip-build-env-_z4rty73/overlay/local/lib/python3.11/dist-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
              raise AttributeError(attr)
          AttributeError: cython_sources
          [end of output]
  
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error
  
    ร— Getting requirements to build wheel did not run successfully.
    โ”‚ exit code: 1
    โ•ฐโ”€> See above for output.
  
    note: This error originates from a subprocess, and is likely not a problem with pip.

Wrong Repo URL

On RedHat EL 7, role fails with:

TASK [geerlingguy.pip : Ensure Pip is installed.] ****************************************************************************************************
fatal: [SelfServ20582]: FAILED! => {"changed": false, "msg": "Failure talking to yum: failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.\nhttps://download.docker.com/linux/centos/7Server/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found"}

It looks like the repository URL is no longer valid. The URL:
https://download.docker.com/linux/centos/7Server/x86_64/stable/repodata/repomd.xml
should probably be:
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml

Looks like this has something to do with Centos8 release and renaming things:
docker/for-linux#1111

This also affects your Docker role.

find_packages() got an unexpected keyword argument 'include'

Trying to install openshift, I keep getting this error. Pip installs fine, but it seems to install version 8.1.2. Running the standard pip ansible module, I get the same error, so it may be related to the version of pip that's installed?

TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] **************************************************************************************************************************
[DEPRECATION WARNING]: Invoking "pip" only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply multiple items and specifying `name: "{{ item.name | 
default(item) }}"`, please use `name: '{{ pip_install_packages }}'` and remove the loop. This feature will be removed in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
failed: [10.0.169.36] (item=[u'openshift']) => {"ansible_loop_var": "item", "changed": false, "cmd": ["/bin/pip", "install", "openshift"], "item": ["openshift"], "msg": "stdout: Collecting openshift\n  Using cached https://files.pythonhosted.org/packages/a9/9f/bda22613bec8fc7d6ab21cee95e83649456866cb8c93f611f45f49dba75a/openshift-0.9.2.tar.gz\n    Complete output from command python setup.py egg_info:\n    Traceback (most recent call last):\n      File \"<string>\", line 1, in <module>\n      File \"/tmp/pip-build-NsDM3C/openshift/setup.py\", line 50, in <module>\n        packages=find_packages(include='openshift.*'),\n    TypeError: find_packages() got an unexpected keyword argument 'include'\n    \n    ----------------------------------------\n\n:stderr: Command \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-build-NsDM3C/openshift/\nYou are using pip version 8.1.2, however version 19.2.3 is available.\nYou should consider upgrading via the 'pip install --upgrade pip' command.\n"}

Would it be possible to allow us to pass extra_args?

I'm specifically interested in extra_args: --user.

Is there any specific way to do it right now without editing the role itself?
If no, any plans for adding support for this? I don't mind doing it if there is interest (fair warning: I'n new to Ansible).

Edit: Saw the stale PR. Forking off it for now.

Failed install on debian10

I play the ansible in Vagrant

servtest.vm.box = "generic/debian10"

and failed "TASK [geerlingguy.pip : Ensure pip_install_packages are installed."

`

  • name: install pip
    include_role:
    name: geerlingguy.pip
    apply:
    become: yes
    vars:
    pip_install_packages:
    - name: docker
    - name: docker-compose
    - name: passlib
    pip_executable: /usr/bin/pip3
    `
    Adjunt normal log...
    ansible_output.log

and adjunt verbose log

ansible_output.log

thanks

Support installing packages from requirements.txt

Now there is an option to install packages with pip_install_packages, but it will be great if this role can also support installing packages from different locations of requirements.txt, something like this:

---
- name: Install pip3 files
  pip:
    requirements: "{{ item }}/requirements.txt"
  with_items: "{{ dirs }}"

What do you think? Any reason why we shouldn't do it?

PIP install should not set ansible PPA

Ubuntu 20.04 LTS there is no ppa:ansible/ansible repo.
Installing the latest ansible on 20.04 must be done with PIP.
The task always tries to add the PPA, and always fails.

- name: Add ansible repository.
  apt_repository: repo='ppa:ansible/ansible'

Suggest that when installing using PIP no repo is registered.

E.g.

- name: Set up Ansible on Ubuntu.
  include_tasks: setup-Ubuntu.yml
  when: ansible_distribution == 'Ubuntu' # AND ansible_install_method != 'pip'

Setting `virtualenv` leads to "parameters are mutually exclusive: executable|virtualenv"

Having this in my playbook:

---
- hosts: webservers
  roles:
    - role: geerlingguy.pip
      tags:
        - work-in-progress
      vars:
        pip_install_packages:
          - name: docker
            virtualenv: /myapp/venv
          - name: docker-compose
            virtualenv: /myapp/venv
          - name: passlib
            virtualenv: /myapp/venv

Fails with the following error:

TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] *******************************************************************************************
failed: [staging] (item={'name': 'docker', 'virtualenv': '/myapp/venv'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "docker", "virtualenv": "/myapp/venv"}, "msg": "parameters are mutually exclusive: executable|virtualenv"}
failed: [staging] (item={'name': 'docker-compose', 'virtualenv': '/myapp/venv'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "docker-compose", "virtualenv": "/myapp/venv"}, "msg": "parameters are mutually exclusive: executable|virtualenv"}
failed: [staging] (item={'name': 'passlib', 'virtualenv': '/myapp/venv'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "passlib", "virtualenv": "/myapp/venv"}, "msg": "parameters are mutually exclusive: executable|virtualenv"}

I assume this line:

    executable: "{{ pip_executable }}"

Should be:

    executable: "{{ pip_executable | default(omit) }}"

pip breaks after running geerlingguy.pip

Hi. After I use geerlingguy.pip to install docker, docker-compose using the following role,

- name: Ensure servers are configured
  hosts: host001
  become: true
  roles:
  - { 
        role: geerlingguy.pip,
        pip_install_packages: [docker, docker-compose] 
    }

pip breaks with this error:

# pip install requests
Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.exceptions import CommandError
  File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
    from pip._vendor.six import iteritems
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 65, in <module>
    vendored("cachecontrol")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl/cachecontrol/adapter.py", line 5, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl/requests/__init__.py", line 95, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1553, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 32, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 12, in <module>
    import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket
  File "/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py", line 1, in <module>
    import requests
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl/requests/__init__.py", line 95, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1553, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.exceptions import CommandError
  File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
    from pip._vendor.six import iteritems
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 65, in <module>
    vendored("cachecontrol")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl/cachecontrol/adapter.py", line 5, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl/requests/__init__.py", line 95, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1553, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

why?

The solution to fix this problem is here: https://stackoverflow.com/questions/73830524/attributeerror-module-lib-has-no-attribute-x509-v-flag-cb-issuer-check
But I wonder why does it happen and if there is something I can do to fix it or prevent it of happening.

--
Target OS (host001): Ubuntu 20.04 LTS
Ansible version: 2.10.8

centos7

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "No package matching 'python3-pip' found available, installed or updated", "rc": 126, "results": ["No package matching 'python3-pip' found available, installed or updated"]}

Ubuntu 18.04 Server - python3-pip not working

When I run this role with pip_package set to "python3-pip" on a Ubuntu 18.04 Server I get the following error.

TASK [geerlingguy.pip : Ensure Pip is installed.] *******************************************************************************************************************************************************************************************
fatal: []: FAILED! => {"changed": false, "msg": "No package matching 'python3-pip' is available"}

Ubuntu 18.04 Server - python3-pip not working

TASK [geerlingguy.pip : Ensure Pip is installed.] ******************************************************************************************************************
 [WARNING]: Updating cache and auto-installing missing dependency: python3-apt

fatal: []: FAILED! => {"changed": false, "msg": "Could not import python modules: apt, apt_pkg. Please install python3-apt package."}

tried a bunch of things in vars...

    pip_install_packages:
      - name: pyopenssl
    pip_package: python3-apt
    pip_executable: pip3

Deprecation warning in Ansible 2.7

TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] ****************************************************
[DEPRECATION WARNING]: Invoking "pip" only once while using a loop via squash_actions is deprecated. Instead of using a
 loop to supply multiple items and specifying `name: {{ item.name | default(item) }}`, please use `name: u'{{ 
pip_install_packages }}'` and remove the loop. This feature will be removed in version 2.11. Deprecation warnings can 
be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [server] => (item=[u'docker'])

Barfs out with "ImportError: No module named pkg_resources"

TASK [geerlingguy.pip : Ensure pip_install_packages are installed.] ********************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pkg_resources
failed: [jenkins] (item={'name': 'setuptools'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "setuptools"}, "msg": "Failed to import the required Python library (setuptools) on jenkins-machine's Python /usr/bin/python. Please read module documentation and install in the appropriate location"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pkg_resources
failed: [jenkins] (item={'name': 'docker'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "docker"}, "msg": "Failed to import the required Python library (setuptools) on jenkins-machine's Python /usr/bin/python. Please read module documentation and install in the appropriate location"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pkg_resources
failed: [jenkins] (item={'name': 'docker-compose'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "docker-compose"}, "msg": "Failed to import the required Python library (setuptools) on jenkins-machine's Python /usr/bin/python. Please read module documentation and install in the appropriate location"}

The file up until the error:

- hosts: "{{ setupHosts }}"
  vars_prompt:
    - name: "setupHosts"
      prompt: "Which hosts would you like to setup?"
      private: no

  gather_facts: yes

  tasks:
    - name: add universe repository for bionic
      become: yes
      apt_repository:
        repo: deb http://archive.ubuntu.com/ubuntu bionic universe
        state: present
      when: ansible_distribution_release == 'bionic'

    - name: install pip
      become: yes
      import_role:
        name: geerlingguy.pip
      vars:
        pip_package: python3-pip
        pip_install_packages:
          - name: setuptools
          - name: docker
          - name: docker-compose

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.