Ansible - pip not found

Eduardo picture Eduardo · Aug 24, 2018 · Viewed 13.1k times · Source

I am getting this error:

    TASK [pip] *********************************************************************
    failed: [default] (item=urllib3) => 
{"changed": false, "item": "urllib3", 
"msg": "Unable to find any of pip2, pip to use.  pip needs to be installed."}

Upon a suggestion I run following command:

ansible default -a "which pip"

I get an error:

default | FAILED | rc=1 >>
non-zero return code

So I guess that means no pip installed. I tried installing pip using:

ansible default -a "easy_install pip"

I get the following error:

default | FAILED | rc=2 >>
[Errno 2] No such file or directory

Any ideas?

UPDATE In play_local.yaml, I have the following task:

- name: Prepare system
  hosts: default
  become: yes
  gather_facts: false
  pre_tasks:
    - raw: sudo apt-get -y install python python-setuptools python-pip build-essential libssl-dev libffi-dev python-dev easyinstall pip
    - file: path=/etc/sudoers.d/ssh-auth-sock state=touch mode=0440
      #- lineinfile: line='Defaults env_keep += "SSH_AUTH_SOCK"' path=/etc/sudoers.d/ssh-auth-sock
    - replace:
        path: /etc/apt/sources.list
        regexp: 'br.'
        replace: ''

Shouldn't this task install pip?

Answer

iptizer picture iptizer · Aug 24, 2018

Seems like pip is not installed, you can use the following task to install it:

- name: Install pip
  apt:
    name: python-pip
    update_cache: yes
    state: present