DOCUMENTATION:
  name: password_hash
  version_added: "historical"
  short_description: convert input password into password_hash
  description:
    - Returns a password_hash of a secret.
  positional: _input
  notes:
    - Algorithms available might be restricted by the system.
    - Algorithms may restrict salt length or content. For example, Blowfish/bcrypt requires a 22-character salt.
  options:
    _input:
      description: Secret to hash.
      type: string
      required: true
    hashtype:
      description: Hashing algorithm to use.
      type: string
      default: sha512
      choices: [ md5, blowfish, sha256, sha512, bcrypt ]
    salt:
      description: 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]+)).
      type: string
    rounds:
      description: Number of encryption rounds, default varies by algorithm used.
      type: int
    ident:
      description: Algorithm identifier.
      type: string

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:
  _value:
    description: The resulting password hash.
    type: string
