In a setup with RHEL 7.9, Ansible 2.9.27, Python 2.7.5, I am not able to produce an issue. A minimal example playbook
---
- hosts: localhost
become: true
gather_facts: false
vars:
PASSWORD: TEST
tasks:
- name: Configure or update user
user:
name: "TestUser"
password: "{{ PASSWORD | password_hash('sha512', 'salt') }}"
results into an output of
TASK [Configure or update user] ******
changed: [localhost]
Other Example
Just a note ...
When utilizing the password
option of the ansible.builtin.user
module to provide an encrypted password, playbook runs fine but Ansible displays ...
---
- hosts: localhost
become: true
gather_facts: false
vars:
PASSWORD: TEST
tasks:
- name: Configure or update user
user:
name: "TestUser"
password: "{{ PASSWORD }}"
will result into an output of
TASK [Configure or update user] ******
[WARNING]: The input password appears not to have been hashed. ...
It is a WARNING message not an ERROR. It means you should provide the password hashed. Furthermore it is not possible to provide an encrypted password (string) without former decryption. See user
module – Manage user accounts - Parameter password
If provided, set the user’s password to the provided encrypted hash (Linux) or plain text password (macOS).
Please take note about the fundamental difference between Hashing and Encryption algorithms.