---
title: Password
slug: homologacao-atmosphere/password
description: Learn how to generate random passwords with customizable characters, encryption schemes, and length using this comprehensive document. It includes examples and returned values, including the generated password. Boost your password security now!
createdAt: 2021-07-16T13:22:22.000Z
---

## Resumo

- Função que gera senhas aleatórias.

## Parâmetros

| **Parâmetro**                                  | **Tipo** | **Escolhas \| Valor Padrão**                                         | **Comentários**                                                                                                                                                                                                                                                                                                                                                                                           |
| ---------------------------------------------- | -------- | -------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| chars                                          | string   |                                                                      | Lista de símbolos que podem compor um conjunto de caracteres personalizados nas senhas geradas.<br /><br />Por padrão, as senhas geradas contêm uma combinação aleatória de letras ASCII maiúsculas e minúsculas, números de 0 a 9 e pontuação (".,: - \_").<br /><br />Para inserir a vírgula, use duas vírgulas ',,' em algum lugar - de preferência no final. Aspas e aspas duplas não são suportadas. |
| encrypt                                        | string   | - md5\_crypt<br />- bcrypt<br />- sha256\_crypt<br />- sha512\_crypt | Esquema de hash para criptografar a senha.<br /><br />Se não for fornecido, a senha será retornada em texto simples.<br /><br />A senha sempre é gerada como texto simples, apenas o seu retorno é criptografado.                                                                                                                                                                                         |
| length                                         | int      | Valor default:<br />**20**                                           | O comprimento da senha gerada.                                                                                                                                                                                                                                                                                                                                                                            |

## Exemplos

```yaml
- name: Generate password...
  debug:
    msg: |
    Same (random):    {{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=8')[0] }}
                        {{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=8')[0] }}
    -----------------------------------------------------------------------------------------
    Lowercase ascii:  {{ lookup('password', '/dev/null chars=ascii_lowercase length=8')[0] }}
    Digits:           {{ lookup('password', '/dev/null chars=digits length=8')[0] }}
    -----------------------------------------------------------------------------------------
    chars: ascii_lowercase,ascii_uppercase,digits,hexdigits,punctuation
    {{ lookup('password', '/dev/null chars=ascii_lowercase,ascii_uppercase,digits,punctuation length=30')[0] }}
    -----------------------------------------------------------------------------------------
    Encrypt:
    md5-crypt:
    {{ lookup('password', '/dev/null chars=ascii_lowercase,ascii_uppercase,digits,punctuation encrypt=md5_crypt length=30')[0] }}
    sha256_crypt:
    {{ lookup('password', '/dev/null chars=ascii_lowercase,ascii_uppercase,digits,punctuation encrypt=sha256_crypt length=30')[0] }}
    sha512_crypt:
    {{ lookup('password', '/dev/null chars=ascii_lowercase,ascii_uppercase,digits,punctuation encrypt=sha512_crypt length=30')[0] }}
```



## Valores retornados

| **Chave** | **Tipo** | **Retornado quando** | **Descrição** |
| --------- | -------- | -------------------- | ------------- |
| \_raw     | list     | Sucesso              | Senha gerada. |

