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?
2
Answers
I also had this issue today. I had to pip install passlib on the ansible server itself, not the target host. (Feel free to omit
--break-system-packages
as needed.Use "inject" argument for add passlib in venv ansible