Ansible This module requires the passlib Python library

To install the latest version of passlib use pip

- name: Install latest passlib with pip
  pip: name=passlib

More on this you can read here


In order task htpasswd module to work. server needs to have python-passlib package installed. This can be done via:

- name: Make sure we can use htpasswd module
  apt: "pkg=python-passlib state=installed"

Make sure that you're using the version of passlib that matches the version of python you're using.

I had to install python3-passlib instead of python-passlib.