Pip module does nothing when state=absent

17 views
Skip to first unread message

Guy Knights

unread,
Apr 18, 2018, 4:59:56 PM4/18/18
to Ansible Project

I recently upgraded to Ansible 2.4 and have run into a weird problem. I added a task to remove a python package that was breaking pip on one of our servers, the task is below:


- name: Remove pip package ndg-httpsclient as it breaks pip
  pip:
    name: ndg-httpsclient
    state: absent

When this task is run on a server that definitely has ndg-httpsclient installed (as per pip freeze), it does not register a change. If I check the package list after the run, it's still listed as installed (and pip is still broken).

Here's a screenshot of the output of pip freeze before the ansible run:


Here's the task output from the ansible run:


Here's the output of pip freeze after the run:


Can anyone explain why state: absent isn't working as expected?


Thanks,

Guy

Guy Knights

unread,
Apr 18, 2018, 5:09:07 PM4/18/18
to Ansible Project
Right after I posted this I tried uninstalling ndg-httpsclient manually (should've tried that first I guess) and I got this error:

Not uninstalling ndg-httpsclient at /usr/lib/python2.7/dist-packages, owned by OS

This was while logged in as root too. Anyway, I ended up having to manually remove the package files in /usr/lib/python2.7/dist-packages which finally worked.

Just noting this here in case it's useful info.

Thanks,
Guy

Kai Stian Olstad

unread,
Apr 19, 2018, 1:59:40 AM4/19/18
to ansible...@googlegroups.com
On 18.04.2018 23:09, Guy Knights wrote:
> Right after I posted this I tried uninstalling ndg-httpsclient manually
> (should've tried that first I guess) and I got this error:
>
> Not uninstalling ndg-httpsclient at /usr/lib/python2.7/dist-packages,
> owned
> by OS
>
> This was while logged in as root too. Anyway, I ended up having to
> manually
> remove the package files in /usr/lib/python2.7/dist-packages which
> finally
> worked.

pip wont uninstall packages installed by the OS package system.
Bassed on the path I'm guessing you are using Debian or a Debian based
distro, to uninstall you need to use the apt module, the package name is
python-ndg-httpsclient.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages