gitlab_deploy_key - Manages GitLab project deploy keys.¶
New in version 2.6.
Parameters¶
Parameter | Choices/Defaults | Comments |
---|---|---|
access_token |
The oauth key provided by GitLab. One of access_token or private_token is required. See https://docs.gitlab.com/ee/api/oauth2.html
|
|
api_url
required |
GitLab API url, e.g. https://gitlab.example.com/api
|
|
can_push
bool |
|
Whether this key can push to the project
|
key
required |
Deploy key
|
|
private_token |
Personal access token to use. One of private_token or access_token is required. See https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html
|
|
project
required |
Numeric project id or name of project in the form of group/name
|
|
state
required |
|
When
present the deploy key added to the project if it doesn't exist.When
absent it will be removed from the project if it exists |
title
required |
Deploy key's title
|
Examples¶
# Example adding a project deploy key
- gitlab_deploy_key:
api_url: https://gitlab.example.com/api
access_token: "{{ access_token }}"
project: "my_group/my_project"
title: "Jenkins CI"
state: present
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."
# Update the above deploy key to add push access
- gitlab_deploy_key:
api_url: https://gitlab.example.com/api
access_token: "{{ access_token }}"
project: "my_group/my_project"
title: "Jenkins CI"
state: present
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."
can_push: yes
# Remove the previous deploy key from the project
- gitlab_deploy_key:
api_url: https://gitlab.example.com/api
access_token: "{{ access_token }}"
project: "my_group/my_project"
state: absent
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9w..."
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
error
string
|
failed |
the error message returned by the Gitlab API
Sample:
400: key is already in use
|
msg
string
|
always |
Success or failure message
Sample:
Success
|
previous_version
dict
|
changed |
object describing the state prior to this task
|
result
dict
|
always |
json parsed response from the server
|
Status¶
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Maintenance¶
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Author¶
- Marcus Watkins (@marwatk)
Hint
If you notice any issues in this documentation you can edit this document to improve it.