community.general.gitlab_label module – Creates/updates/deletes GitLab Labels belonging to project or group.
Note
This module is part of the community.general collection (version 9.4.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.gitlab_label
.
New in community.general 8.3.0
Synopsis
When a label does not exist, it will be created.
When a label does exist, its value will be updated when the values are different.
Labels can be purged.
Requirements
The below requirements are needed on the host that executes this module.
python-gitlab python module
requests (Python library https://pypi.org/project/requests/)
Parameters
Parameter |
Comments |
---|---|
GitLab CI job token for logging in. |
|
GitLab OAuth token for logging in. |
|
The password to use for authentication against the API. |
|
GitLab access token with API permissions. |
|
The resolvable endpoint for the API. |
|
The username to use for authentication against the API. |
|
The CA certificates bundle to use to verify GitLab server certificate. |
|
The path of the group. Either this or |
|
A list of dictionaries that represents gitlab project’s or group’s labels. Default: |
|
The color of the label. Required when |
|
Label’s description. |
|
The name of the label. |
|
Optional field to change label’s name. |
|
Integer value to give priority to the label. |
|
The path and name of the project. Either this or |
|
When set to Choices:
|
|
Create or delete project or group label. Choices:
|
|
Whether or not to validate SSL certs when supplying a HTTPS endpoint. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
# same project's task can be executed for group
- name: Create one Label
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
labels:
- name: label_one
color: "#123456"
state: present
- name: Create many group labels
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
group: "group1"
labels:
- name: label_one
color: "#123456"
description: this is a label
priority: 20
- name: label_two
color: "#554422"
state: present
- name: Create many project labels
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
labels:
- name: label_one
color: "#123456"
description: this is a label
priority: 20
- name: label_two
color: "#554422"
state: present
- name: Set or update some labels
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
labels:
- name: label_one
color: "#224488"
state: present
- name: Add label in check mode
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
labels:
- name: label_one
color: "#224488"
check_mode: true
- name: Delete Label
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
labels:
- name: label_one
state: absent
- name: Change Label name
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
labels:
- name: label_one
new_name: label_two
state: absent
- name: Purge all labels
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
purge: true
- name: Delete many labels
community.general.gitlab_label:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
state: absent
labels:
- name: label-abc123
- name: label-two
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Four lists of the labels which were added, updated, removed or exist. Returned: success |
|
A list of labels which were created. Returned: always Sample: |
|
A list of labels which were deleted. Returned: always Sample: |
|
A list of labels which exist. Returned: always Sample: |
|
A list pre-existing labels whose values have been set. Returned: always Sample: |
|
API object. Returned: success |