Search code examples
ansiblepasslib

Ansible Unable to encrypt nor hash, passlib must be installed


I want to use the ansible password_hash filter, but I got the following error message

TASK [setup : users | Set root user password as fallback] **********************
fatal: [pscloud.operations.nbg1-dc3.prod.ansible-jumphost01]: FAILED! => 
  msg: Unable to encrypt nor hash, passlib must be installed. No module named 'passlib'. Unable to encrypt nor hash, passlib must be installed. No module named 'passlib'

I installed ansible 2.17.0 with pipx. I tried installing python3-passlib via apt and passlib via pip but both dosent seem to solve the problem.

The task I want to execute is this

- name: users | Set root user password as fallback
  ansible.builtin.user:
    name: root
    password: "{{ __VAULT__ROOT_PASSWORD | string | password_hash('sha512', 'mysaltxxx') }}"

I tried this inside a gitlab pipeline on a ubuntu jammy image. Can anyone help me fix this?


Solution

  • Use "inject" argument for add passlib in venv ansible

    pipx inject ansible passlib