---
title: Gitlab Deploy Key
slug: homologacao-atmosphere/gitlab-deploy-key
description: Learn how to use a powerful script to effortlessly manage deploy keys in your GitLab project. This document offers a comprehensive summary of the script, including the required parameters and SSL certificate validation. With step-by-step examples, you'll 
createdAt: 2021-03-16T18:03:15.000Z
---

## Resumo

- Adiciona, atualiza e remove deploy keys de um projeto.

## Parâmetros

| **Parâmetro**                      | **Tipo** | **Escolhas \| Valor Padrão**                          | **Comentários**                                                                                                                         |
| ---------------------------------- | -------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| api\_token                         | string   |                                                       | Token GitLab para login.                                                                                                                |
| api\_url                           | string   |                                                       | O caminho da API em formato URL.                                                                                                        |
| can\_push                          | boolean  | Escolhas:<br />- false<br />(default)<br />- true     | Se essa chave pode ser enviada ao projeto.                                                                                              |
| key - *required*                   | string   |                                                       | Chave que será implantada.                                                                                                              |
| project - *required*               | string   |                                                       | Id ou caminho completo do projeto na forma de grupo / nome.                                                                             |
| state                              | string   | Escolhas:<br />- present<br />(default)<br />- absent | Quando present, a chave de implantação será adicionada ao projeto, se não existir. Quando absent, será removida do projeto, se existir. |
| title -*&#x20;required*            | string   |                                                       | Título da chave que será implantada.                                                                                                    |
| validate\_certs                    | boolean  | Escolhas:<br />- false<br />- true<br />(default)     | Se deve ou não validar certificados SSL ao fornecer uma url https.                                                                      |


Exemplos
--------

```yaml
# Exemplo: Adicionando deploy key em um projeto
  gitlab_deploy_key:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    project: "my_group/my_project"
    title: "Jenkins CI"
    state: present
    key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."

# Exemplo: Atualizando o parâmetro can_push da deploy key
  gitlab_deploy_key:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    project: "my_group/my_project"
    title: "Jenkins CI"
    state: present
    can_push: yes
    key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."

# Exemplo: Removendo deploy key de um projeto
  gitlab_deploy_key:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    project: "my_group/my_project"
    title: "Jenkins CI"
    state: absent
    key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."

```



## Valores retornados

| **Chave**    | **Tipo**   | **Retornado&#x20;**<br />**quando** | **Descrição**                                |
| ------------ | ---------- | ----------------------------------- | -------------------------------------------- |
| deploy\_key  | dictionary | Sempre                              | Objeto API.                                  |
| error        | string     | Falhar                              | A mensagem de erro devolvida pelo GitLab API |
| msg          | string     | Sempre                              | Mensagem de sucesso ou falha.                |
| result       | dictionary | Sempre                              | Resposta json do servidor.                   |




