password_hash¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in versionhistorical.
Synopsis¶
- Returns a password_hash of a secret.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _input string required |
Secret to hash. | |
| hashtype string |
Default: sha512 Choices: md5, blowfish, sha256, sha512, bcrypt |
Hashing algorithm to use. |
| ident string |
Algorithm identifier. | |
| rounds int |
Number of encryption rounds, default varies by algorithm used. | |
| salt string |
Secret string used for the hashing. If none is provided a random one can be generated. Use only numbers and letters (characters matching V([./0-9A-Za-z]+)). |
Notes¶
Note
- Algorithms available might be restricted by the system.
- Algorithms may restrict salt length or content. For example, Blowfish/bcrypt requires a 22-character salt.
Examples¶
# pwdhash => "$6$/bQCntzQ7VrgVcFa$VaMkmevkY1dqrx8neaenUDlVU.6L/.ojRbrnI4ID.yBHU6XON1cB422scCiXfUL5wRucMdLgJU0Fn38uoeBni/"
pwdhash: "{{ 'testing' | password_hash }}"
# Using hash type
# wireguard_admin_password_hash => "$2b$12$ujYVRD9v9z87lpvLqeWNuOFDI4QzSSYHoRyYydW6XK4.kgqfwOXzO"
wireguard_admin_password_hash: "{{ 'vagrant-libvirt' | password_hash(hashtype='bcrypt') }}"
# Using salt value for idempotency
# wireguard_admin_password_hash => "$2b$12$abcdefghijklmnopqrstuuTEw8POU2MwwuYEM7WaKcjqZ948Hm7.W"
wireguard_admin_password_hash: "{{ 'vagrant-libvirt' | password_hash(hashtype='bcrypt', salt='abcdefghijklmnopqrstuv') }}"
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _value | string | The resulting password hash. |