Pip module does nothing when state=absent

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

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

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.