Skip to content

password_hash

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version historical.

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 }}"

Return Values

Key Data Type Description Returned
_value string The resulting password hash.