title: Ansible password_hash wont' use bcrypt even though passlib is installed
body: <p>I'm trying to call Ansible's <code>password_hash</code> function thusly...</p>
  
  <pre><code>{{ admin_password | password_hash('bcrypt') }}
  </code></pre>
  
  <p>and I've tried a dozen ways to tell Ansible where passlib and python 2.7 are but no matter what, I'm continuously getting the result...</p>
  
  <pre><code>"AnsibleFilterError: crypt.crypt does not support 'bcrypt' algorithm"
  </code></pre>
  
  <p>From what I can see, ansible used to only use <code>crypt</code>, but newer versions (I'm currently on 2.7.9) use <code>passlib</code> when it's there and passlib supports bcrypt as far as I understand (which is limited).  I've added the following to my hosts file...</p>
  
  <pre><code>ansible_python_interpreter = /usr/bin/python2.7
  </code></pre>
  
  <p>I'm installing PIP and Passlib like so...</p>
  
  <pre><code>- name: Install PY stuff...
    yum: 
      name: ['python2-pip','python2-passlib']
      state: present
  
  - name: Ensure bcrypt support is installed for python passlib
    pip:
     name: "passlib[bcrypt]"
     executable: pip-2.7
  </code></pre>
  
  <p>I would have expected the yum call to get passlib set up properly but it didn't work, so then I tried doing only via PIP, it didn't work either, so then I tried the above which still isn't working. I wasn't sure whether passlib included bcrypt when installed via yum, because it doesn't when using only PIP it seems, so just in case, I did both.  No joy.</p>
  
  <p>I should add that I'm in AWS on Amazon Linux 2, and I've enabled the epel repo, etc.</p>
  
  <hr>
  
  <p>EDIT: I've tried several of the suggestions from comments (using passlib 1.6, validating that bcrypt works with python) and while I can verify that passlib does work when testing within python, but I continue to get the same answer from Ansible <code>AnsibleFilterError: crypt.crypt does not support 'bcrypt' algorithm</code></p>
  
  <p>The only thing I've found relating to this is here: <a href="https://github.com/ansible/ansible/issues/17266" rel="nofollow noreferrer">https://github.com/ansible/ansible/issues/17266</a> but it describes the default it to look for passlib and only fallback on crypt.crypt when it's not present. So why does python see passlib when I run it manually, but not from the playbook?</p>